1 Clang attempts to guess file names based on the OS and distro (yes!),
2 but unfortunately, that doesn't work for us.
4 This patch makes it easy to insert libc's $libdir so that Clang passes the
5 correct absolute file name of crt1.o etc. to 'ld'. It also disables all
6 the distro-specific stuff and removes the hard-coded FHS directory names
7 to make sure Clang also works on non-GuixSD systems.
9 --- cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp
10 +++ cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp
12 PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
13 GCCInstallation.getTriple().str() + "/bin")
16 + // Comment out the distro-specific tweaks so that they don't bite when
17 + // using Guix on a foreign distro.
19 Distro Distro(D.getVFS());
21 if (Distro.IsAlpineLinux()) {
24 if (IsAndroid || Distro.IsOpenSUSE())
25 ExtraOpts.push_back("--enable-new-dtags");
28 // The selection of paths to try here is designed to match the patterns which
29 // the GCC driver itself uses, as this is part of the GCC-compatible driver.
31 addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
34 - addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
35 - addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
36 - addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
37 - addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
39 // Try walking via the GCC triple path in case of biarch or multiarch GCC
40 // installations with strange symlinks.
41 if (GCCInstallation.isValid()) {
42 + // The following code would end up adding things like
43 + // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path.
46 SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
49 BiarchSibling.gccSuffix(),
54 // See comments above on the multilib variant for details of why this is
55 // included even from outside the sysroot.
57 if (StringRef(D.Dir).startswith(SysRoot))
58 addPathIfExists(D, D.Dir + "/../lib", Paths);
60 - addPathIfExists(D, SysRoot + "/lib", Paths);
61 - addPathIfExists(D, SysRoot + "/usr/lib", Paths);
62 + // Add libc's lib/ directory to the search path, so that crt1.o, crti.o,
63 + // and friends can be found.
64 + addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
67 bool Linux::HasNativeLLVMSupport() const { return true; }