diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2015-06-19 17:18:03 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2015-06-19 17:23:48 +0200 |
| commit | fd6ae1b9836ffe74105f26930d101d1297849740 (patch) | |
| tree | 16c1a0ba29c5a5883b88f186148ecefc3f91c7af /gnu | |
| parent | ef11ac87013a67f2c4454adf7d477a5c602a14b3 (diff) | |
gnu: clang: Allow 'clang' to link executables.
* gnu/packages/patches/clang-libc-search-path.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/llvm.scm (clang-from-llvm)[source]: Use it.
[inputs]: Add "gcc-lib".
[arguments]. Add -DGCC_INSTALL_PREFIX and -DC_INCLUDE_DIRS to
#:configure-flags. Add #:phases argument.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/packages/llvm.scm | 37 | ||||
| -rw-r--r-- | gnu/packages/patches/clang-libc-search-path.patch | 19 |
2 files changed, 54 insertions, 2 deletions
diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 946773c91e7..1755f9c0141 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm | |||
| @@ -26,6 +26,8 @@ | |||
| 26 | #:use-module (guix build-system gnu) | 26 | #:use-module (guix build-system gnu) |
| 27 | #:use-module (guix build-system cmake) | 27 | #:use-module (guix build-system cmake) |
| 28 | #:use-module (gnu packages) | 28 | #:use-module (gnu packages) |
| 29 | #:use-module (gnu packages gcc) | ||
| 30 | #:use-module (gnu packages bootstrap) ;glibc-dynamic-linker | ||
| 29 | #:use-module (gnu packages perl) | 31 | #:use-module (gnu packages perl) |
| 30 | #:use-module (gnu packages python) | 32 | #:use-module (gnu packages python) |
| 31 | #:use-module (gnu packages xml)) | 33 | #:use-module (gnu packages xml)) |
| @@ -85,7 +87,8 @@ tools as well as libraries with equivalent functionality.") | |||
| 85 | (method url-fetch) | 87 | (method url-fetch) |
| 86 | (uri (string-append "http://llvm.org/releases/" | 88 | (uri (string-append "http://llvm.org/releases/" |
| 87 | version "/cfe-" version ".src.tar.xz")) | 89 | version "/cfe-" version ".src.tar.xz")) |
| 88 | (sha256 (base32 hash)))) | 90 | (sha256 (base32 hash)) |
| 91 | (patches (list (search-patch "clang-libc-search-path.patch"))))) | ||
| 89 | ;; Using cmake allows us to treat llvm as an external library. There | 92 | ;; Using cmake allows us to treat llvm as an external library. There |
| 90 | ;; doesn't seem to be any way to do this with clang's autotools-based | 93 | ;; doesn't seem to be any way to do this with clang's autotools-based |
| 91 | ;; build system. | 94 | ;; build system. |
| @@ -93,10 +96,40 @@ tools as well as libraries with equivalent functionality.") | |||
| 93 | (native-inputs (package-native-inputs llvm)) | 96 | (native-inputs (package-native-inputs llvm)) |
| 94 | (inputs | 97 | (inputs |
| 95 | `(("libxml2" ,libxml2) | 98 | `(("libxml2" ,libxml2) |
| 99 | ("gcc-lib" ,gcc-4.9 "lib") | ||
| 96 | ,@(package-inputs llvm))) | 100 | ,@(package-inputs llvm))) |
| 97 | (propagated-inputs | 101 | (propagated-inputs |
| 98 | `(("llvm" ,llvm))) | 102 | `(("llvm" ,llvm))) |
| 99 | (arguments `(#:configure-flags '("-DCLANG_INCLUDE_TESTS=True"))) | 103 | (arguments |
| 104 | `(#:configure-flags | ||
| 105 | (list "-DCLANG_INCLUDE_TESTS=True" | ||
| 106 | |||
| 107 | ;; Find libgcc_s, crtbegin.o, and crtend.o. | ||
| 108 | (string-append "-DGCC_INSTALL_PREFIX=" | ||
| 109 | (assoc-ref %build-inputs "gcc-lib")) | ||
| 110 | |||
| 111 | ;; Use a sane default include directory. | ||
| 112 | (string-append "-DC_INCLUDE_DIRS=" | ||
| 113 | (assoc-ref %build-inputs "libc") | ||
| 114 | "/include")) | ||
| 115 | |||
| 116 | #:phases (modify-phases %standard-phases | ||
| 117 | (add-after | ||
| 118 | 'unpack 'set-glibc-file-names | ||
| 119 | (lambda* (#:key inputs #:allow-other-keys) | ||
| 120 | (let ((libc (assoc-ref inputs "libc"))) | ||
| 121 | ;; Patch the 'getLinuxDynamicLinker' function to that | ||
| 122 | ;; it uses the right dynamic linker file name. | ||
| 123 | (substitute* "lib/Driver/Tools.cpp" | ||
| 124 | (("/lib64/ld-linux-x86-64.so.2") | ||
| 125 | (string-append libc | ||
| 126 | ,(glibc-dynamic-linker)))) | ||
| 127 | |||
| 128 | ;; Same for libc's libdir, to allow crt1.o & co. to be | ||
| 129 | ;; found. | ||
| 130 | (substitute* "lib/Driver/ToolChains.cpp" | ||
| 131 | (("@GLIBC_LIBDIR@") | ||
| 132 | (string-append libc "/lib"))))))))) | ||
| 100 | 133 | ||
| 101 | ;; Clang supports the same environment variables as GCC. | 134 | ;; Clang supports the same environment variables as GCC. |
| 102 | (native-search-paths | 135 | (native-search-paths |
diff --git a/gnu/packages/patches/clang-libc-search-path.patch b/gnu/packages/patches/clang-libc-search-path.patch new file mode 100644 index 00000000000..327336ac090 --- /dev/null +++ b/gnu/packages/patches/clang-libc-search-path.patch | |||
| @@ -0,0 +1,19 @@ | |||
| 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'. | ||
| 6 | |||
| 7 | --- cfe-3.6.0.src/lib/Driver/ToolChains.cpp 2015-02-18 22:03:07.000000000 +0100 | ||
| 8 | +++ cfe-3.6.0.src/lib/Driver/ToolChains.cpp 2015-06-19 16:37:20.459701044 +0200 | ||
| 9 | @@ -3085,6 +3085,10 @@ Linux::Linux(const Driver &D, const llvm | ||
| 10 | |||
| 11 | addPathIfExists(SysRoot + "/lib", Paths); | ||
| 12 | addPathIfExists(SysRoot + "/usr/lib", Paths); | ||
| 13 | + | ||
| 14 | + // Add libc's lib/ directory to the search path, so that crt1.o, crti.o, | ||
| 15 | + // and friends can be found. | ||
| 16 | + addPathIfExists("@GLIBC_LIBDIR@", Paths); | ||
| 17 | } | ||
| 18 | |||
| 19 | bool Linux::HasNativeLLVMSupport() const { | ||
