| 1 | Author: Danny Milosavljevic <[email protected]>
|
| 2 | Date: 2025-10-20
|
| 3 | Subject: Fix libc search path
|
| 4 |
|
| 5 | Swift LLVM 5.7.3 (based on LLVM 14.0) - libc search path fix
|
| 6 |
|
| 7 | This patch makes it easy to insert libc's $libdir so that Clang passes the
|
| 8 | correct absolute file name of crt1.o etc. to 'ld'. It removes the hard-coded
|
| 9 | FHS directory names to make sure Clang also works on foreign distros.
|
| 10 |
|
| 11 | |
| 12 | |
| 13 | @@ -297,21 +297,12 @@
|
| 14 |
|
| 15 | Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
|
| 16 |
|
| 17 | - // Similar to the logic for GCC above, if we are currently running Clang
|
| 18 | - // inside of the requested system root, add its parent library path to those
|
| 19 | - // searched.
|
| 20 | - // FIXME: It's not clear whether we should use the driver's installed
|
| 21 | - // directory ('Dir' below) or the ResourceDir.
|
| 22 | - if (StringRef(D.Dir).startswith(SysRoot)) {
|
| 23 | - // Even if OSLibDir != "lib", this is needed for Clang in the build
|
| 24 | - // directory (not installed) to find libc++.
|
| 25 | - addPathIfExists(D, D.Dir + "/../lib", Paths);
|
| 26 | - if (OSLibDir != "lib")
|
| 27 | - addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
|
| 28 | - }
|
| 29 | + // Add libc's lib/ directory to the search path, so that crt1.o, crti.o,
|
| 30 | + // and friends can be found.
|
| 31 | + addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
|
| 32 |
|
| 33 | - addPathIfExists(D, SysRoot + "/lib", Paths);
|
| 34 | - addPathIfExists(D, SysRoot + "/usr/lib", Paths);
|
| 35 | + // Add GCC's lib/ directory so libstdc++.so can be found.
|
| 36 | + addPathIfExists(D, GCCInstallation.getParentLibPath(), Paths);
|
| 37 | }
|
| 38 |
|
| 39 | ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {
|