[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

Michael Kruse via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 8 06:09:30 PDT 2024


Meinersbur wrote:

Using git bisect, I tracked down Flang not working anymore on Windows to this PR:

```
> flang-new hello.f90 -o hello
flang-new version 19.0.0git
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Users\meinersbur\build\llvm-project\release\bin
Build config: +assertions
 "C:\\Users\\meinersbur\\build\\llvm-project\\release\\bin\\flang-new" -fc1 -triple x86_64-pc-windows-msvc19.40.33811 -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu x86-64 --dependent-lib=clang_rt.builtins-x86_64.lib -D_MT --dependent-lib=libcmt --dependent-lib=Fortran_main.static.lib --dependent-lib=FortranRuntime.static.lib --dependent-lib=FortranDecimal.static.lib -D_MSC_VER=1940 -D_MSC_FULL_VER=194033811 -D_WIN32 -D_M_X64=100 -mframe-pointer=none -o "C:\\Users\\MEINER~1\\AppData\\Local\\Temp\\hello-2ee671.o" -x f95-cpp-input hello.f90
 "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.40.33807\\bin\\Hostx64\\x64\\link.exe" -out:hello "-libpath:C:\\Users\\meinersbur\\build\\llvm-project\\release\\lib" /WHOLEARCHIVE:Fortran_main.static.lib /subsystem:console "-libpath:C:\\Users\\meinersbur\\build\\llvm-project\\release\\lib\\clang\\19\\lib\\windows" -nologo "C:\\Users\\MEINER~1\\AppData\\Local\\Temp\\hello-2ee671.o"
LINK : fatal error LNK1104: cannot open file 'clang_rt.builtins.lib'
flang-new: error: linker command failed with exit code 1104 (use -v to see invocation)
```

Before this commit, `/DEFAULTLIB:clang_rt.builtins-x86_64.lib` the linking directive, now it is `/DEFAULTLIB:clang_rt.builtins-x86_64.lib`. Turns out, `clang_rt.builtins-x86_64.lib` is actually shipped with the MSVC compiler (`C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\<version>\lib\x64`, possibly for Sanitizer support in MSVC), which makes the former work, but not the latter.

With `-DLLVM_ENABLE_PROJECTS=compiler-rt`, the resource-dir `build\llvm-project\release\lib\clang\19\lib\windows` is filled with `clang_rt.builtins-x86_64.lib` et.al., but also changes it back to `/DEFAULTLIB:clang_rt.builtins-x86_64.lib`, and it works again.





https://github.com/llvm/llvm-project/pull/87866


More information about the cfe-commits mailing list