gnu: Add ruby-puma.
[jackhill/guix/guix.git] / gnu / packages / patches / clang-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 --- cfe-3.6.0.src/lib/Driver/ToolChains.cpp 2015-02-18 22:03:07.000000000 +0100
10 +++ cfe-3.6.0.src/lib/Driver/ToolChains.cpp 2015-06-19 16:37:20.459701044 +0200
11 @@ -2931,6 +2931,9 @@ Linux::Linux(const Driver &D, const llvm
12
13 Linker = GetLinkerPath();
14
15 + // Comment out the distro-specific tweaks so that they don't bite when
16 + // using Guix on a foreign distro.
17 +#if 0
18 Distro Distro = DetectDistro(Arch);
19
20 if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
21 @@ -2973,6 +2976,7 @@ Linux::Linux(const Driver &D, const llvm
22
23 if (IsOpenSUSE(Distro))
24 ExtraOpts.push_back("--enable-new-dtags");
25 +#endif
26
27 // The selection of paths to try here is designed to match the patterns which
28 // the GCC driver itself uses, as this is part of the GCC-compatible driver.
29 @@ -3043,14 +3047,12 @@ Linux::Linux(const Driver &D, const llvm
30 addPathIfExists(D.Dir + "/../" + OSLibDir, Paths);
31 }
32
33 - addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
34 - addPathIfExists(SysRoot + "/lib/../" + OSLibDir, Paths);
35 - addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
36 - addPathIfExists(SysRoot + "/usr/lib/../" + OSLibDir, Paths);
37 -
38 // Try walking via the GCC triple path in case of biarch or multiarch GCC
39 // installations with strange symlinks.
40 if (GCCInstallation.isValid()) {
41 + // The following code would end up adding things like
42 + // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path.
43 +#if 0
44 addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
45 "/../../" + OSLibDir, Paths);
46
47 @@ -3060,6 +3062,7 @@ Linux::Linux(const Driver &D, const llvm
48 addPathIfExists(GCCInstallation.getInstallPath() +
49 BiarchSibling.gccSuffix(), Paths);
50 }
51 +#endif
52
53 // See comments above on the multilib variant for details of why this is
54 // included even from outside the sysroot.
55 @@ -3083,8 +3086,9 @@ Linux::Linux(const Driver &D, const llvm
56 if (StringRef(D.Dir).startswith(SysRoot))
57 addPathIfExists(D.Dir + "/../lib", Paths);
58
59 - addPathIfExists(SysRoot + "/lib", Paths);
60 - addPathIfExists(SysRoot + "/usr/lib", Paths);
61 + // Add libc's lib/ directory to the search path, so that crt1.o, crti.o,
62 + // and friends can be found.
63 + addPathIfExists("@GLIBC_LIBDIR@", Paths);
64 }
65
66 bool Linux::HasNativeLLVMSupport() const {