Files
clang-p2996/lld/test/COFF/winsysroot.test
Martin Storsjö 241c290ad7 Reland [LLD] [COFF] Don't try to detect MSVC installations in mingw mode
In mingw mode, all linker paths are passed explicitly to the linker
by the compiler driver. Don't try to implicitly add linker paths
from the LIB environment variable or by detecting an MSVC
installation directory.

If the /winsysroot command line parameter is explicitly passed to
lld-link while /lldmingw is specified, it could be considered reasonable
to actually include those paths. However, modifying the code to
handle only the /winsysroot case but not the other ones, when the
mingw mode has been enabled, seems like much more code complexity
for a mostly hypothetical case.

Add a test for this when case when using LIB. (The code paths for
trying to detect an MSVC installation aren't really regression tested.)

Also fix an issue in the existing test for "Check that when /winsysroot
is specified, %LIB% is ignored.", where the LIB variable pointed
to a nonexistent directory, so the test would pass even if /winsysroot
wouldn't be specified.

Reland this after https://github.com/llvm/llvm-project/pull/68077 and
https://github.com/llvm/llvm-project/pull/69781 - the compiler-rt test
that used -lldmingw in MSVC environments has been updated to use a more
specific option.

Differential Revision: https://reviews.llvm.org/D144084
2023-10-21 22:36:11 +03:00

61 lines
2.9 KiB
Plaintext

Check that /winsysroot results in the correct machine-specific subdirectory
being searched for the defaultlibs, for a 32-bit .obj.
# RUN: yaml2obj %p/Inputs/hello32.yaml -o %t.obj
# RUN: mkdir -p %t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86
# RUN: mkdir -p %t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x64
# RUN: cp %p/Inputs/std32.lib %t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86
# RUN: cp %p/Inputs/std64.lib %t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x64
# RUN: lld-link %t.obj /winsysroot:%t.dir/sysroot \
# RUN: /defaultlib:std32 /entry:main@0
Check the same for a 64-bit input .obj.
# RUN: lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
# RUN: /defaultlib:std64 /entry:main
Check directly passed lib with /machine:
# RUN: lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot /machine:x64 \
# RUN: std64.lib /entry:main
# RUN: lld-link %t.obj /winsysroot:%t.dir/sysroot /machine:x86 \
# RUN: std32.lib /entry:main
Check directly passed lib without /machine: (should infer from obj arch)
# RUN: lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
# RUN: std64.lib /entry:main
# RUN: lld-link %t.obj /winsysroot:%t.dir/sysroot \
# RUN: std32.lib /entry:main
Check that passing a lib from /winsysroot twice is ok
# RUN: lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
# RUN: std64.lib std64.lib /entry:main
Check unknown library
# RUN: not lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
# RUN: notfound.lib /entry:main 2>&1 | FileCheck --check-prefix=UNKNOWNLIB %s
UNKNOWNLIB: could not open 'notfound.lib'
If winsysroot lib appears before we can detect arch we don't find it
# RUN: not lld-link std64.lib %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
# RUN: /entry:main 2>&1 | FileCheck --check-prefix=NO64 %s
Check we don't choose the wrong arch
# RUN: not lld-link %t.obj /winsysroot:%t.dir/sysroot \
# RUN: std64.lib /entry:main 2>&1 | FileCheck --check-prefix=NO64 %s
NO64: could not open 'std64.lib'
# RUN: not lld-link %p/Inputs/hello64.obj /winsysroot:%t.dir/sysroot \
# RUN: std32.lib /entry:main 2>&1 | FileCheck --check-prefix=NO32 %s
NO32: could not open 'std32.lib'
Check that when /winsysroot is specified, %LIB% is ignored.
# RUN: env LIB=%t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link %t.obj /winsysroot:%t.dir/doesnotexist /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED %s
LIBIGNORED: could not open 'std32.lib'
Check that when -lldmingw is specified, %LIB% is ignored.
# RUN: env LIB=%t.dir/sysroot/VC/Tools/MSVC/1.1.1.1/lib/x86 not lld-link -lldmingw %t.obj /defaultlib:std32 2>&1 | FileCheck -check-prefix=LIBIGNORED_MINGW %s
LIBIGNORED_MINGW: could not open 'libstd32.a'
# RUN: not lld-link -lldmingw %t.obj /defaultlib:std32 /winsysroot:%t.dir/sysroot 2>&1 | FileCheck -check-prefix=IGNORED_ARG %s
IGNORED_ARG: warning: ignoring /vctoolsdir or /winsysroot flags in MinGW mode