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