Commit | Line | Data |
---|---|---|
9bdbabe9 MB |
1 | Clang attempts to guess file names based on the OS and distro (yes!), |
2 | but unfortunately, that doesn't work for us. | |
3 | ||
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. | |
8 | ||
9 | --- cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp | |
10 | +++ cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp | |
11 | @@ -207,7 +207,9 @@ | |
12 | PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" + | |
13 | GCCInstallation.getTriple().str() + "/bin") | |
14 | .str()); | |
15 | - | |
16 | + // Comment out the distro-specific tweaks so that they don't bite when | |
17 | + // using Guix on a foreign distro. | |
18 | +#if 0 | |
19 | Distro Distro(D.getVFS()); | |
20 | ||
21 | if (Distro.IsAlpineLinux()) { | |
22 | @@ -255,6 +257,7 @@ | |
23 | ||
24 | if (IsAndroid || Distro.IsOpenSUSE()) | |
25 | ExtraOpts.push_back("--enable-new-dtags"); | |
26 | +#endif | |
27 | ||
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. | |
30 | @@ -329,14 +332,12 @@ | |
31 | addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths); | |
32 | } | |
33 | ||
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); | |
38 | - | |
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. | |
44 | +#if 0 | |
45 | addPathIfExists(D, | |
46 | SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() + | |
47 | "/../../" + OSLibDir, | |
48 | @@ -349,6 +350,7 @@ | |
49 | BiarchSibling.gccSuffix(), | |
50 | Paths); | |
51 | } | |
52 | +#endif | |
53 | ||
54 | // See comments above on the multilib variant for details of why this is | |
55 | // included even from outside the sysroot. | |
56 | @@ -373,8 +375,9 @@ | |
57 | if (StringRef(D.Dir).startswith(SysRoot)) | |
58 | addPathIfExists(D, D.Dir + "/../lib", Paths); | |
59 | ||
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); | |
65 | } | |
66 | ||
67 | bool Linux::HasNativeLLVMSupport() const { return true; } |