diff mbox series

[bug#54239,v3,02/10] gnu: clang-runtime: Fix cross-compilation.

Message ID 20220716194807.20378-2-julien@lepiller.eu
State New
Headers show
Series [bug#54239,v3,01/10] guix: Add build-system transformation for target. | expand

Commit Message

Julien Lepiller July 16, 2022, 7:47 p.m. UTC
* gnu/packages/llvm.scm (clang-runtime-from-llvm): Sanitie
  CROSS_CPLUS_INCLUDE_PATH in the same way as CPLUS_INCLUDE_PATH.
---
 gnu/packages/llvm.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 5a2f411eb2..6428391650 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -141,7 +141,7 @@  (define* (clang-runtime-from-llvm llvm
                     ;; Work around https://issues.guix.info/issue/36882.  We need to
                     ;; remove glibc from CPLUS_INCLUDE_PATH so that the one hardcoded
                     ;; in GCC, at the bottom of GCC include search-path is used.
-                    (lambda* (#:key inputs #:allow-other-keys)
+                    (lambda* (#:key inputs target #:allow-other-keys)
                       (let* ((filters '("libc"))
                              (input-directories
                               (filter-map (lambda (input)
@@ -153,7 +153,20 @@  (define* (clang-runtime-from-llvm llvm
                         (set-path-environment-variable "CPLUS_INCLUDE_PATH"
                                                        '("include")
                                                        input-directories)
-                        #t))))))
+                        (when target
+                          (let ((libc (assoc-ref inputs "cross-libc")))
+                            (setenv "CROSS_CPLUS_INCLUDE_PATH"
+                              (string-join
+                                (filter
+                                  (lambda (path)
+                                    (and
+                                      (not (equal? path
+                                                   (string-append libc "/include")))
+                                      (string-suffix? "include" path)))
+
+                                  (string-split (getenv "CROSS_CPLUS_INCLUDE_PATH")
+                                                #\:))
+                                           ":"))))))))))
     (home-page "https://compiler-rt.llvm.org")
     (synopsis "Runtime library for Clang/LLVM")
     (description