gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / clang-10.0-libc-search-path.patch
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-Guix systems.
8
9 diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp
10 index bff1ab10..79e1477e 100644
11 --- a/lib/Driver/ToolChains/Linux.cpp
12 +++ b/lib/Driver/ToolChains/Linux.cpp
13 @@ -240,6 +240,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
14 .str());
15 }
16
17 +// Comment out the distro-specific tweaks so that they don't bite when
18 +// using Guix on a foreign distro.
19 +#if 0
20 Distro Distro(D.getVFS(), Triple);
21
22 if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
23 @@ -306,6 +309,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
24
25 if (IsAndroid || Distro.IsOpenSUSE())
26 ExtraOpts.push_back("--enable-new-dtags");
27 +#endif // Guix
28
29 // The selection of paths to try here is designed to match the patterns which
30 // the GCC driver itself uses, as this is part of the GCC-compatible driver.
31 @@ -363,7 +367,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
32 // the cross. Note that GCC does include some of these directories in some
33 // configurations but this seems somewhere between questionable and simply
34 // a bug.
35 - if (StringRef(LibPath).startswith(SysRoot)) {
36 + if (0) {
37 addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths);
38 addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths);
39 }
40 @@ -382,6 +386,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
41 addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
42 addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
43
44 +// This requires the commented distro tweaks above.
45 +#if 0
46 if (IsAndroid) {
47 // Android sysroots contain a library directory for each supported OS
48 // version as well as some unversioned libraries in the usual multiarch
49 @@ -410,10 +416,15 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
50 addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths);
51 addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Paths);
52 }
53 +#endif
54
55 // Try walking via the GCC triple path in case of biarch or multiarch GCC
56 // installations with strange symlinks.
57 if (GCCInstallation.isValid()) {
58 +
59 +// The following code would end up adding things like
60 +// "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path.
61 +#if 0
62 addPathIfExists(D,
63 SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
64 "/../../" + OSLibDir,
65 @@ -426,6 +437,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
66 BiarchSibling.gccSuffix(),
67 Paths);
68 }
69 +#endif
70
71 // See comments above on the multilib variant for details of why this is
72 // included even from outside the sysroot.
73 @@ -450,8 +462,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
74 if (StringRef(D.Dir).startswith(SysRoot))
75 addPathIfExists(D, D.Dir + "/../lib", Paths);
76
77 - addPathIfExists(D, SysRoot + "/lib", Paths);
78 - addPathIfExists(D, SysRoot + "/usr/lib", Paths);
79 + // Add libc's lib/ directory to the search path, so that crt1.o, crti.o,
80 + // and friends can be found.
81 + addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
82 }
83
84 ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const {