GNU logs - #38276, boring messages


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#38276] Fix kernel-headers path in clang
Resent-From: Mathieu Othacehe <m.othacehe@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Tue, 19 Nov 2019 16:20:02 +0000
Resent-Message-ID: <handler.38276.B.15741803507797 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 38276
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: 
To: 38276 <at> debbugs.gnu.org
X-Debbugs-Original-To: "guix-patches\@gnu.org" <guix-patches@HIDDEN> 
Received: via spool by submit <at> debbugs.gnu.org id=B.15741803507797
          (code B ref -1); Tue, 19 Nov 2019 16:20:02 +0000
Received: (at submit) by debbugs.gnu.org; 19 Nov 2019 16:19:10 +0000
Received: from localhost ([127.0.0.1]:48337 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iX6De-00021g-7D
	for submit <at> debbugs.gnu.org; Tue, 19 Nov 2019 11:19:10 -0500
Received: from lists.gnu.org ([209.51.188.17]:50474)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <m.othacehe@HIDDEN>) id 1iX6Dc-00021Z-DA
 for submit <at> debbugs.gnu.org; Tue, 19 Nov 2019 11:19:09 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:36793)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <m.othacehe@HIDDEN>) id 1iX6Da-0004ZS-Qd
 for guix-patches@HIDDEN; Tue, 19 Nov 2019 11:19:07 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <m.othacehe@HIDDEN>) id 1iX6DZ-000423-Jl
 for guix-patches@HIDDEN; Tue, 19 Nov 2019 11:19:06 -0500
Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:35050)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <m.othacehe@HIDDEN>)
 id 1iX6DZ-00040p-Bq
 for guix-patches@HIDDEN; Tue, 19 Nov 2019 11:19:05 -0500
Received: by mail-wm1-x330.google.com with SMTP id 8so4412372wmo.0
 for <guix-patches@HIDDEN>; Tue, 19 Nov 2019 08:19:05 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=user-agent:from:to:subject:date:message-id:mime-version;
 bh=uJ5cw7PgStC5DIA5uD02e4h8TCVh7uefVY+ZisFXdNA=;
 b=izd8uHSICGzoYo3iMI1NGWfkgYWY9xj2lUy2Qhr/3BuPr4Q4wl088f9QCv6IvbKwve
 mVoT6BtDSRADWwwKRxWf4NlVKrFsOl1UnvlRyuhZ+BbH4rxKdhBLPyYJmT2YOA9l6H3x
 SVAL4phHlVbR1x8wYDAIs1mfzyZ4P9ZT7eBDr6jGvSgnDZ3DRDo7UkhI3V18M2DiLIy4
 xZ8jJu22//iONz3yNoS+HEF6csla1Eq0gjm5r+6q5Q80Rf8oPL5hDslTOu0oeoeQaom0
 4hBtKMg7JqKij/462xUPYBKI6fT9XY3fb8HfeEOhXWhtxm2quj8xZV7BziYvNT4kIIgV
 65LQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:user-agent:from:to:subject:date:message-id
 :mime-version;
 bh=uJ5cw7PgStC5DIA5uD02e4h8TCVh7uefVY+ZisFXdNA=;
 b=DRYG86cNRw0eRwFqs1lNr1f+yqywNih/Eave8irMpsWlYrblPe66aSNhLEgF9Ee7xP
 dgWqWrqvVLobdfh6VrFtIOzw/6qupr1pEvs9LNMOzE0ZdGeqUJd63lrKYWsG5FmOyoyI
 UBS8pv/s+/yBMR+uovu3Yn5wo5gZImydFIvJb+d2b9WooFObRAoGYQDWTxiduDaJHuuZ
 zwzG10aavupHij/1MyJN3E/g/K9rgTMPMJlbhQsp8gse3Rgd7/mKHJZAkJHbmDRX73/f
 Mzr+RknFCUf5vt5uQ1nWaxF6uKR2at/B9lbO0vW8DwTKaF4zl/ljb/J6vq81mmatECSM
 RCMg==
X-Gm-Message-State: APjAAAWm4JyGrDI8Anz1964BTCNxw8zzGJC2s09awrPeLZTymL7uql55
 GmTKMnuKYX6kc0jMMpdFK8fgfpU4
X-Google-Smtp-Source: APXvYqwe0x0r/yhoRr0nm40PK9Ol8GpYdEA1JdLzy7kzNZPgGkrqU9GETxnzxaOjflaL2Wed4B58pg==
X-Received: by 2002:a1c:4e1a:: with SMTP id g26mr6880958wmh.138.1574180343863; 
 Tue, 19 Nov 2019 08:19:03 -0800 (PST)
Received: from meru ([90.114.75.61])
 by smtp.gmail.com with ESMTPSA id y6sm28328292wrn.21.2019.11.19.08.19.02
 for <guix-patches@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 19 Nov 2019 08:19:02 -0800 (PST)
User-agent: mu4e 1.2.0; emacs 26.3
From: Mathieu Othacehe <m.othacehe@HIDDEN>
Date: Tue, 19 Nov 2019 17:19:01 +0100
Message-ID: <871ru34z62.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2a00:1450:4864:20::330
X-Spam-Score: 0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain


Hello,

Indexing tools such as ccls use "clang" package (and more specifically
the libclang library it provides) to analyse code.

In that use case, clang cannot find kernel headers path. This is because
it is normally set as propagated inputs of gcc-toolchain and clang-toolchain, an
thus available via CPATH.

This patch proposes to hardcode kernel headers path into clang.

What do you think?

Mathieu

--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline;
 filename=0001-gnu-clang-from-llvm-Add-kernel-headers-to-default-in.patch

From 198e59f7645bffbc2ba1e68db2747b8c07997ad6 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <m.othacehe@HIDDEN>
Date: Tue, 19 Nov 2019 16:41:33 +0100
Subject: [PATCH] gnu: clang-from-llvm: Add kernel-headers to default include
 directories.

Stand-alone "clang" binary is not able to find kernel headers because they are
normally set as propagated inputs of gcc-toolchain and clang-toolchain, an
thus available via CPATH.

As some code indexers rely on libclang, kernel-headers include path needs to
be hard-coded.

* gnu/packages/llvm.scm (clang-from-llvm):
---
 gnu/packages/llvm.scm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 863d43d7d6..c5bc1e2c5c 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -195,6 +195,8 @@ compiler.  In LLVM this library is called \"compiler-rt\".")
              ;; Use a sane default include directory.
              (string-append "-DC_INCLUDE_DIRS="
                             (assoc-ref %build-inputs "libc")
+                            "/include:"
+                            (assoc-ref %build-inputs "kernel-headers")
                             "/include"))
 
        ;; Don't use '-g' during the build to save space.
-- 
2.24.0


--=-=-=--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Mathieu Othacehe <m.othacehe@HIDDEN>
Subject: bug#38276: Acknowledgement (Fix kernel-headers path in clang)
Message-ID: <handler.38276.B.15741803507797.ack <at> debbugs.gnu.org>
References: <871ru34z62.fsf@HIDDEN>
X-Gnu-PR-Message: ack 38276
X-Gnu-PR-Package: guix-patches
Reply-To: 38276 <at> debbugs.gnu.org
Date: Tue, 19 Nov 2019 16:20:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 guix-patches@HIDDEN

If you wish to submit further information on this problem, please
send it to 38276 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
38276: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D38276
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#38276] Fix kernel-headers path in clang
Resent-From: Carl Dong <contact@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Tue, 19 Nov 2019 16:53:01 +0000
Resent-Message-ID: <handler.38276.B38276.157418236511021 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 38276
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: 
To: Mathieu Othacehe <m.othacehe@HIDDEN>
Cc: 38276 <at> debbugs.gnu.org
Reply-To: Carl Dong <contact@HIDDEN>
Received: via spool by 38276-submit <at> debbugs.gnu.org id=B38276.157418236511021
          (code B ref 38276); Tue, 19 Nov 2019 16:53:01 +0000
Received: (at 38276) by debbugs.gnu.org; 19 Nov 2019 16:52:45 +0000
Received: from localhost ([127.0.0.1]:48394 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iX6k7-0002rg-Rh
	for submit <at> debbugs.gnu.org; Tue, 19 Nov 2019 11:52:44 -0500
Received: from mail-40132.protonmail.ch ([185.70.40.132]:16143)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <contact@HIDDEN>) id 1iX6k5-0002rF-0A
 for 38276 <at> debbugs.gnu.org; Tue, 19 Nov 2019 11:52:42 -0500
Date: Tue, 19 Nov 2019 16:52:25 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carldong.me;
 s=protonmail; t=1574182352;
 bh=WCrwu8RUxqQaxFTDdLqGEiBj4cn5Xumya4OvWXtPj60=;
 h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:
 Feedback-ID:From;
 b=mN5Up9s4nMVqcI/Yeq9XlIdbZBiaYzeazp8EGyBEPyOKrVoysbftMgDu44HwhTq/Z
 /QPh/Wm+AEVb+Qi1t6a50Z+4S+8UndH4DDfmS8FRfGTjba6uM3gkdCQK68NS0r0wR3
 50SqjlyWPRFJXVWNwBd7wSYvaSgGBH92tz+SYpMM=
From: Carl Dong <contact@HIDDEN>
Message-ID: <15D73ED1-72C9-4F58-B250-7A6426981752@HIDDEN>
In-Reply-To: <871ru34z62.fsf@HIDDEN>
References: <871ru34z62.fsf@HIDDEN>
Feedback-ID: a8j8tDUaJ4AYuDVBywMTwsJebN4w8TVXadJLsJb8td3t3dZi9RdXFlPaQvoFKnI9KgXySsPXcRkajVyY0cGTcA==:Ext:ProtonMail
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham
 autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi Mathieu!

I have been using the Guix clang with the following patch, which should acc=
omplish what you want and also allow for the proper handling of --sysroot. =
I included an extended explanation in the comments in the patch. Let me kno=
w what you think! :-)

Cheers,
Carl Dong
contact@HIDDEN
"I fight for the users=E2=80=9D

-----

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 9ee5062429..33fb53d65e 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -186,7 +186,12 @@ compiler.  In LLVM this library is called \"compiler-r=
t\".")
=20
              ;; Find libgcc_s, crtbegin.o, and crtend.o.
              (string-append "-DGCC_INSTALL_PREFIX=3D"
-                            (assoc-ref %build-inputs "gcc-lib")))
+                            (assoc-ref %build-inputs "gcc-lib"))
+
+             ;; Use a sane default include directory.
+             (string-append "-DC_INCLUDE_DIRS=3D"
+                            (assoc-ref %build-inputs "libc")
+                            "/include"))
=20
        ;; Don't use '-g' during the build to save space.
        #:build-type "Release"
@@ -197,8 +202,6 @@ compiler.  In LLVM this library is called \"compiler-rt=
\".")
                    (lambda* (#:key inputs #:allow-other-keys)
                      (let ((libc (assoc-ref inputs "libc"))
                            (compiler-rt (assoc-ref inputs "clang-runtime")=
)
-                           (gcc (assoc-ref inputs "gcc"))
-                           (kernel-headers (assoc-ref inputs "kernel-heade=
rs"))
                            (version
                             (string->number
                              ,(version-major (package-version clang-runtim=
e)))))
@@ -218,10 +221,7 @@ compiler.  In LLVM this library is called \"compiler-r=
t\".")
                             ;; Make sure libc's libdir is on the search pa=
th, to
                             ;; allow crt1.o & co. to be found.
                             (("@GLIBC_LIBDIR@")
-                             (string-append libc "/lib"))
-                            (("@C_EXTRA_INCLUDE_DIRS@")
-                             (string-append libc "/include" ":"
-                                            kernel-headers "/include"))))
+                             (string-append libc "/lib"))))
                          (else
                           (substitute* "lib/Driver/Tools.cpp"
                             ;; Patch the 'getLinuxDynamicLinker' function =
so that
diff --git a/gnu/packages/patches/clang-3.5-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-3.5-libc-search-path.patch
index 54fb9be7d8..50e4480239 100644
--- a/gnu/packages/patches/clang-3.5-libc-search-path.patch
+++ b/gnu/packages/patches/clang-3.5-libc-search-path.patch
@@ -8,7 +8,7 @@ to make sure Clang also works on non-GuixSD systems.
=20
 --- cfe-3.6.0.src/lib/Driver/ToolChains.cpp=092015-02-18 22:03:07.00000000=
0 +0100
 +++ cfe-3.6.0.src/lib/Driver/ToolChains.cpp=092015-06-19 16:37:20.45970104=
4 +0200
-@@ -3040,6 +3040,9 @@
+@@ -2931,6 +2931,9 @@ Linux::Linux(const Driver &D, const llvm
 =20
    Linker =3D GetLinkerPath();
 =20
@@ -18,7 +18,7 @@ to make sure Clang also works on non-GuixSD systems.
    Distro Distro =3D DetectDistro(Arch);
 =20
    if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
-@@ -3082,6 +3085,7 @@
+@@ -2973,6 +2976,7 @@ Linux::Linux(const Driver &D, const llvm
 =20
    if (IsOpenSUSE(Distro))
      ExtraOpts.push_back("--enable-new-dtags");
@@ -26,49 +26,41 @@ to make sure Clang also works on non-GuixSD systems.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -3194,6 +3198,10 @@
+@@ -3043,14 +3047,12 @@ Linux::Linux(const Driver &D, const llvm
+     addPathIfExists(D.Dir + "/../" + OSLibDir, Paths);
+   }
 =20
-   addPathIfExists(SysRoot + "/lib", Paths);
-   addPathIfExists(SysRoot + "/usr/lib", Paths);
-+
+-  addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
+-  addPathIfExists(SysRoot + "/lib/../" + OSLibDir, Paths);
+-  addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
+-  addPathIfExists(SysRoot + "/usr/lib/../" + OSLibDir, Paths);
+-
+   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
+   // installations with strange symlinks.
+   if (GCCInstallation.isValid()) {
++    // The following code would end up adding things like
++    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
++#if 0
+     addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
+                     "/../../" + OSLibDir, Paths);
+=20
+@@ -3060,6 +3062,7 @@ Linux::Linux(const Driver &D, const llvm
+       addPathIfExists(GCCInstallation.getInstallPath() +
+                       BiarchSibling.gccSuffix(), Paths);
+     }
++#endif
+=20
+     // See comments above on the multilib variant for details of why this=
 is
+     // included even from outside the sysroot.
+@@ -3083,8 +3086,9 @@ Linux::Linux(const Driver &D, const llvm
+   if (StringRef(D.Dir).startswith(SysRoot))
+     addPathIfExists(D.Dir + "/../lib", Paths);
+=20
+-  addPathIfExists(SysRoot + "/lib", Paths);
+-  addPathIfExists(SysRoot + "/usr/lib", Paths);
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists("@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const {
-@@ -3384,6 +3392,34 @@
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
-=20
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
-+
-+  // Check for configure-time "extra" C include directories. When constru=
cting a
-+  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
-+  // colon-separated string of the include dirs of libc and kernel header=
s.
-+  //
-+  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
-+  // because when a user supplies clang with --sysroot, the normal expect=
ation
-+  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
-+  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
-+  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
-+  // and not attempt to add the aforementioned search paths, which is not
-+  // desirable.
-+  //
-+  // By adding our configure-time "extra" C include directories here, aft=
er
-+  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
-+  // --sysroot is supplied on the command line, we pick up the expected s=
earch
-+  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
-+  // C include directories.
-+  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
-+  if (CExtraIncludeDirs !=3D "") {
-+      SmallVector<StringRef, 5> dirs;
-+      CExtraIncludeDirs.split(dirs, ":");
-+      for (StringRef dir : dirs) {
-+          StringRef Prefix =3D
-+              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
-+          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-+      }
-+  }
- }
-=20
- /// \brief Helper to add the variant paths of a libstdc++ installation.
diff --git a/gnu/packages/patches/clang-3.8-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-3.8-libc-search-path.patch
index 243d167755..0f7d0a4add 100644
--- a/gnu/packages/patches/clang-3.8-libc-search-path.patch
+++ b/gnu/packages/patches/clang-3.8-libc-search-path.patch
@@ -29,49 +29,41 @@ changes in clang 3.8.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -3817,6 +3821,10 @@
+@@ -3771,14 +3775,12 @@
+     addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
+   }
 =20
-   addPathIfExists(D, SysRoot + "/lib", Paths);
-   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
-+
+-  addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
+-  addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
+-  addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
+-  addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
+-
+   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
+   // installations with strange symlinks.
+   if (GCCInstallation.isValid()) {
++    // The following code would end up adding things like
++    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
++#if 0
+     addPathIfExists(D,
+                     SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
+                         "/../../" + OSLibDir,
+@@ -3791,6 +3793,7 @@
+                              BiarchSibling.gccSuffix(),
+                       Paths);
+     }
++#endif
+=20
+     // See comments above on the multilib variant for details of why this=
 is
+     // included even from outside the sysroot.
+@@ -3815,8 +3818,9 @@
+   if (StringRef(D.Dir).startswith(SysRoot))
+     addPathIfExists(D, D.Dir + "/../lib", Paths);
+=20
+-  addPathIfExists(D, SysRoot + "/lib", Paths);
+-  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const { return true; }
-@@ -4026,6 +4034,34 @@
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
-=20
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
-+
-+  // Check for configure-time "extra" C include directories. When constru=
cting a
-+  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
-+  // colon-separated string of the include dirs of libc and kernel header=
s.
-+  //
-+  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
-+  // because when a user supplies clang with --sysroot, the normal expect=
ation
-+  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
-+  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
-+  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
-+  // and not attempt to add the aforementioned search paths, which is not
-+  // desirable.
-+  //
-+  // By adding our configure-time "extra" C include directories here, aft=
er
-+  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
-+  // --sysroot is supplied on the command line, we pick up the expected s=
earch
-+  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
-+  // C include directories.
-+  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
-+  if (CExtraIncludeDirs !=3D "") {
-+      SmallVector<StringRef, 5> dirs;
-+      CExtraIncludeDirs.split(dirs, ":");
-+      for (StringRef dir : dirs) {
-+          StringRef Prefix =3D
-+              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
-+          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-+      }
-+  }
- }
-=20
-=20
diff --git a/gnu/packages/patches/clang-6.0-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-6.0-libc-search-path.patch
index d80c798467..a62e8063c2 100644
--- a/gnu/packages/patches/clang-6.0-libc-search-path.patch
+++ b/gnu/packages/patches/clang-6.0-libc-search-path.patch
@@ -8,17 +8,18 @@ to make sure Clang also works on non-GuixSD systems.
=20
 --- cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp
 +++ cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp
-@@ -208,6 +208,9 @@
+@@ -207,7 +207,9 @@
+   PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
                           GCCInstallation.getTriple().str() + "/bin")
                         .str());
-=20
+-
 +  // Comment out the distro-specific tweaks so that they don't bite when
 +  // using Guix on a foreign distro.
 +#if 0
    Distro Distro(D.getVFS());
 =20
    if (Distro.IsAlpineLinux()) {
-@@ -255,6 +258,7 @@
+@@ -255,6 +257,7 @@
 =20
    if (IsAndroid || Distro.IsOpenSUSE())
      ExtraOpts.push_back("--enable-new-dtags");
@@ -26,49 +27,41 @@ to make sure Clang also works on non-GuixSD systems.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -375,6 +379,10 @@
+@@ -329,14 +332,12 @@
+     addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
+   }
+=20
+-  addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
+-  addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
+-  addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
+-  addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
+-
+   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
+   // installations with strange symlinks.
+   if (GCCInstallation.isValid()) {
++    // The following code would end up adding things like
++    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
++#if 0
+     addPathIfExists(D,
+                     SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
+                         "/../../" + OSLibDir,
+@@ -349,6 +350,7 @@
+                              BiarchSibling.gccSuffix(),
+                       Paths);
+     }
++#endif
 =20
-   addPathIfExists(D, SysRoot + "/lib", Paths);
-   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
-+
+     // See comments above on the multilib variant for details of why this=
 is
+     // included even from outside the sysroot.
+@@ -373,8 +375,9 @@
+   if (StringRef(D.Dir).startswith(SysRoot))
+     addPathIfExists(D, D.Dir + "/../lib", Paths);
+=20
+-  addPathIfExists(D, SysRoot + "/lib", Paths);
+-  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const { return true; }
-@@ -710,6 +718,34 @@
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
-=20
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
-+
-+  // Check for configure-time "extra" C include directories. When constru=
cting a
-+  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
-+  // colon-separated string of the include dirs of libc and kernel header=
s.
-+  //
-+  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
-+  // because when a user supplies clang with --sysroot, the normal expect=
ation
-+  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
-+  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
-+  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
-+  // and not attempt to add the aforementioned search paths, which is not
-+  // desirable.
-+  //
-+  // By adding our configure-time "extra" C include directories here, aft=
er
-+  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
-+  // --sysroot is supplied on the command line, we pick up the expected s=
earch
-+  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
-+  // C include directories.
-+  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
-+  if (CExtraIncludeDirs !=3D "") {
-+      SmallVector<StringRef, 5> dirs;
-+      CExtraIncludeDirs.split(dirs, ":");
-+      for (StringRef dir : dirs) {
-+          StringRef Prefix =3D
-+              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
-+          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-+      }
-+  }
- }
-=20
- static std::string DetectLibcxxIncludePath(StringRef base) {
diff --git a/gnu/packages/patches/clang-7.0-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-7.0-libc-search-path.patch
index 445b5d17ac..07ff8c90bd 100644
--- a/gnu/packages/patches/clang-7.0-libc-search-path.patch
+++ b/gnu/packages/patches/clang-7.0-libc-search-path.patch
@@ -8,7 +8,7 @@ to make sure Clang also works on non-GuixSD systems.
=20
 --- a/lib/Driver/ToolChains/Linux.cpp
 +++ b/lib/Driver/ToolChains/Linux.cpp
-@@ -225,7 +225,9 @@
+@@ -225,7 +225,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
    PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
                           GCCInstallation.getTriple().str() + "/bin")
                         .str());
@@ -19,7 +19,7 @@ to make sure Clang also works on non-GuixSD systems.
    Distro Distro(D.getVFS());
 =20
    if (Distro.IsAlpineLinux()) {
-@@ -284,6 +286,7 @@
+@@ -284,6 +286,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
 =20
    if (IsAndroid || Distro.IsOpenSUSE())
      ExtraOpts.push_back("--enable-new-dtags");
@@ -27,49 +27,56 @@ to make sure Clang also works on non-GuixSD systems.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -431,6 +434,10 @@
+@@ -342,7 +345,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
+     // the cross. Note that GCC does include some of these directories in=
 some
+     // configurations but this seems somewhere between questionable and s=
imply
+     // a bug.
+-    if (StringRef(LibPath).startswith(SysRoot)) {
++    if (0) {
+       addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths);
+       addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths);
+     }
+@@ -361,6 +364,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
+   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
+   addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
 =20
-   addPathIfExists(D, SysRoot + "/lib", Paths);
-   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
-+
++  // This requires the commented distro tweaks above.
++#if 0
+   if (IsAndroid) {
+     // Android sysroots contain a library directory for each supported OS
+     // version as well as some unversioned libraries in the usual multiar=
ch
+@@ -389,10 +394,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Tr=
iple, const ArgList &Args)
+     addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths);
+     addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Path=
s);
+   }
++#endif
+=20
+   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
+   // installations with strange symlinks.
+   if (GCCInstallation.isValid()) {
++    // The following code would end up adding things like
++    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
++#if 0
+     addPathIfExists(D,
+                     SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
+                         "/../../" + OSLibDir,
+@@ -405,6 +414,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
+                              BiarchSibling.gccSuffix(),
+                       Paths);
+     }
++#endif
+=20
+     // See comments above on the multilib variant for details of why this=
 is
+     // included even from outside the sysroot.
+@@ -429,8 +439,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
+   if (StringRef(D.Dir).startswith(SysRoot))
+     addPathIfExists(D, D.Dir + "/../lib", Paths);
+=20
+-  addPathIfExists(D, SysRoot + "/lib", Paths);
+-  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const { return true; }
-@@ -794,6 +801,34 @@
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
-=20
-   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
-+
-+  // Check for configure-time "extra" C include directories. When constru=
cting a
-+  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
-+  // colon-separated string of the include dirs of libc and kernel header=
s.
-+  //
-+  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
-+  // because when a user supplies clang with --sysroot, the normal expect=
ation
-+  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
-+  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
-+  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
-+  // and not attempt to add the aforementioned search paths, which is not
-+  // desirable.
-+  //
-+  // By adding our configure-time "extra" C include directories here, aft=
er
-+  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
-+  // --sysroot is supplied on the command line, we pick up the expected s=
earch
-+  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
-+  // C include directories.
-+  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
-+  if (CExtraIncludeDirs !=3D "") {
-+      SmallVector<StringRef, 5> dirs;
-+      CExtraIncludeDirs.split(dirs, ":");
-+      for (StringRef dir : dirs) {
-+          StringRef Prefix =3D
-+              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
-+          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-+      }
-+  }
- }
-=20
- static std::string DetectLibcxxIncludePath(StringRef base) {






Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#38276] Fix kernel-headers path in clang
Resent-From: Mathieu Othacehe <m.othacehe@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Wed, 20 Nov 2019 14:05:04 +0000
Resent-Message-ID: <handler.38276.B38276.157425865329630 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 38276
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: 
To: Carl Dong <contact@HIDDEN>
Cc: 38276 <at> debbugs.gnu.org
Received: via spool by 38276-submit <at> debbugs.gnu.org id=B38276.157425865329630
          (code B ref 38276); Wed, 20 Nov 2019 14:05:04 +0000
Received: (at 38276) by debbugs.gnu.org; 20 Nov 2019 14:04:13 +0000
Received: from localhost ([127.0.0.1]:49173 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iXQab-0007hq-Kb
	for submit <at> debbugs.gnu.org; Wed, 20 Nov 2019 09:04:13 -0500
Received: from mail-wr1-f52.google.com ([209.85.221.52]:46433)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <m.othacehe@HIDDEN>) id 1iXQaZ-0007hd-HM
 for 38276 <at> debbugs.gnu.org; Wed, 20 Nov 2019 09:04:11 -0500
Received: by mail-wr1-f52.google.com with SMTP id b3so28293091wrs.13
 for <38276 <at> debbugs.gnu.org>; Wed, 20 Nov 2019 06:04:11 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=references:user-agent:from:to:cc:subject:in-reply-to:date
 :message-id:mime-version;
 bh=ov1BTNoSUnyHDLt3yz++bDWtYv15Y0ORjHpyHoQT1tg=;
 b=WEuoLoWK0mtf/EcJjzekg0fc8OehiRRaD31YFLVZu6nizGQOmnsl7IuFX/N6Lssn2u
 fd7mIeInWnZ/P7rF2Fbt+6iXboiyT2SAJ5tH9LgXba7hdGizcPQOvEcJz4rdis5bJGKa
 j8/+82sna5f1njdXmG/TEWbdSyeWipNSKKUz/Ns9hT61QpPGE618M/m6mwZ7opvBhSxJ
 tBw4X3Dq6VrooHk8kkL+m0UkGbPI4FvWjqv9izkIRd12rRApCnsoY4JNKJAV/3CF6m37
 L1JjxJ+PcDF30MVObcmrPOi7zOGIgwxXjCMwgqlZYCKn0yAcO0gARYI3vBy902c5sNQ/
 2EAg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:references:user-agent:from:to:cc:subject
 :in-reply-to:date:message-id:mime-version;
 bh=ov1BTNoSUnyHDLt3yz++bDWtYv15Y0ORjHpyHoQT1tg=;
 b=uapfwm7dDSAkLAkhAoLSc546bISxwWDgoYzzK3CVVPQeHHAhFbFgLF4yfEWqWFrK5X
 oyaCWXUx9/b81L5er7JFX03fVaGxyJ++8HSjXILQITpXUEl1BWUvk4jctSUSdvN3Xzob
 5laT67A4RSMVAFuUJHv6I0j7v6W4Ua3TuyIKZI7O3bc0HY5Xjx8zXsiKkjmlbuSm1YyE
 zmnHgCWwdHltz3N2UAQGEIZygYMKJZCWVpVVUVJY7Grh9TclOOwIm3fPJXd80iFyOLna
 Ywj5wKznvkBTfLN646NT/GG5s2RwyJmwPWZjQ0EzDL/HtnVKochyMshYY1xutnvBHy7e
 uJNA==
X-Gm-Message-State: APjAAAWZfvuIyMBDwvgZkztq3OY0nPCo8f/4ft28UPNVEi1gd/0L90YF
 O39ewEWfxbpxIDSlzD/gB6N3lcVl
X-Google-Smtp-Source: APXvYqzNRv1T0mAkmzwG7rbsErcQTypIOyEZi0gr01LI6e2fgHc27IsXoZ442lkX3Wd5EtBkJXVdqQ==
X-Received: by 2002:adf:e444:: with SMTP id t4mr3640322wrm.50.1574258645389;
 Wed, 20 Nov 2019 06:04:05 -0800 (PST)
Received: from meru ([90.114.75.61])
 by smtp.gmail.com with ESMTPSA id z11sm36746222wrg.0.2019.11.20.06.04.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 20 Nov 2019 06:04:04 -0800 (PST)
References: <871ru34z62.fsf@HIDDEN>
 <15D73ED1-72C9-4F58-B250-7A6426981752@HIDDEN>
User-agent: mu4e 1.2.0; emacs 26.3
From: Mathieu Othacehe <m.othacehe@HIDDEN>
In-reply-to: <15D73ED1-72C9-4F58-B250-7A6426981752@HIDDEN>
Date: Wed, 20 Nov 2019 15:04:01 +0100
Message-ID: <87pnhmwsoe.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Hello Carl,

> +-  addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
> +-  addPathIfExists(SysRoot + "/lib/../" + OSLibDir, Paths);
> +-  addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
> +-  addPathIfExists(SysRoot + "/usr/lib/../" + OSLibDir, Paths);

I'm not sure to understand the benefit of this patch versus hardcoding
libc and kernel-headers path into clang at build time.

Plus, in general patching so heavily the sources of a package proves to
be very hard to maintain.

Mathieu




Message sent to guix-patches@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: [bug#38276] Fix kernel-headers path in clang
Resent-From: Carl Dong <contact@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: guix-patches@HIDDEN
Resent-Date: Wed, 20 Nov 2019 21:29:02 +0000
Resent-Message-ID: <handler.38276.B38276.157428531015217 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 38276
X-GNU-PR-Package: guix-patches
X-GNU-PR-Keywords: 
To: Mathieu Othacehe <m.othacehe@HIDDEN>
Cc: 38276 <at> debbugs.gnu.org
Reply-To: Carl Dong <contact@HIDDEN>
Received: via spool by 38276-submit <at> debbugs.gnu.org id=B38276.157428531015217
          (code B ref 38276); Wed, 20 Nov 2019 21:29:02 +0000
Received: (at 38276) by debbugs.gnu.org; 20 Nov 2019 21:28:30 +0000
Received: from localhost ([127.0.0.1]:50980 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iXXWT-0003xI-Rp
	for submit <at> debbugs.gnu.org; Wed, 20 Nov 2019 16:28:26 -0500
Received: from mail-40131.protonmail.ch ([185.70.40.131]:19277)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <contact@HIDDEN>) id 1iXXWK-0003wx-UI
 for 38276 <at> debbugs.gnu.org; Wed, 20 Nov 2019 16:28:18 -0500
Date: Wed, 20 Nov 2019 21:28:08 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=carldong.me;
 s=protonmail; t=1574285289;
 bh=5fbEHR2DQ35MB9LJeIscU4m+enRWiP0JSZM8SZjyZXU=;
 h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:
 Feedback-ID:From;
 b=FRozjMd5vLWAN2bDxQkvqJCiGonY2yvNiXCYgNc+GSJ3eyD3A0gN2NJbSZkbzrSMr
 r5mMVM9Hp4QxlYNDsfvdaDIO8h8JC3OI4de8ggzecJRoQvSrLSdhTKTVS6eQKsGfrl
 eV7vqzS5fwquJ6tYuSD1odYAVpSexw8U7uPr0GY8=
From: Carl Dong <contact@HIDDEN>
Message-ID: <079E8E67-5A3F-4B08-AB9E-2880559C0570@HIDDEN>
In-Reply-To: <87pnhmwsoe.fsf@HIDDEN>
References: <871ru34z62.fsf@HIDDEN>
 <15D73ED1-72C9-4F58-B250-7A6426981752@HIDDEN>
 <87pnhmwsoe.fsf@HIDDEN>
Feedback-ID: a8j8tDUaJ4AYuDVBywMTwsJebN4w8TVXadJLsJb8td3t3dZi9RdXFlPaQvoFKnI9KgXySsPXcRkajVyY0cGTcA==:Ext:ProtonMail
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Status: No, score=-1.2 required=7.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF autolearn=ham
 autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.protonmail.ch
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Mathieu,

I want to apologize for the confusion with that last patch I sent=E2=80=
=A6 That was actually the exact opposite patch of what I intended :-)
I=E2=80=99ve attached the correct patch below, and some explanation:

> Plus, in general patching so heavily the sources of a package proves to
> be very hard to maintain.

These are already patches that we carry (see gnu/packages/patches/clang-*-l=
ibc-search-path.patch), I=E2=80=99m simply modifying them.

> I'm not sure to understand the benefit of this patch versus hardcoding
> libc and kernel-headers path into clang at build time.

This patch _does_ hardcode libc and kernel-headers path into clang at build=
 time, BUT it does so in a way that also retains sane behaviour when --sysr=
oot is supplied to clang. Explanation from the patch:

> ++  // Check for configure-time "extra" C include directories. When const=
ructing a
> ++  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with somethin=
g like a
> ++  // colon-separated string of the include dirs of libc and kernel head=
ers.
> ++  //
> ++  // The reason why we use this mechanism instead of C_INCLUDE_DIRS abo=
ve is
> ++  // because when a user supplies clang with --sysroot, the normal expe=
ctation
> ++  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHIN=
CL,
> ++  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search p=
aths.
> ++  // However, if C_INCLUDE_DIRS is not empty, this function will return=
 early
> ++  // and not attempt to add the aforementioned search paths, which is n=
ot
> ++  // desirable.
> ++  //
> ++  // By adding our configure-time "extra" C include directories here, a=
fter
> ++  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sur=
e that IF
> ++  // --sysroot is supplied on the command line, we pick up the expected=
 search
> ++  // paths in the $SYSROOT, and that they come before our configure-tim=
e "extra"
> ++  // C include directories.

Again, sorry for the confusion, and I look forward to hearing what you and =
others think!

Cheers,
Carl Dong

-----

diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm
index 33fb53d65e..9ee5062429 100644
--- a/gnu/packages/llvm.scm
+++ b/gnu/packages/llvm.scm
@@ -186,12 +186,7 @@ compiler.  In LLVM this library is called \"compiler-r=
t\".")
=20
              ;; Find libgcc_s, crtbegin.o, and crtend.o.
              (string-append "-DGCC_INSTALL_PREFIX=3D"
-                            (assoc-ref %build-inputs "gcc-lib"))
-
-             ;; Use a sane default include directory.
-             (string-append "-DC_INCLUDE_DIRS=3D"
-                            (assoc-ref %build-inputs "libc")
-                            "/include"))
+                            (assoc-ref %build-inputs "gcc-lib")))
=20
        ;; Don't use '-g' during the build to save space.
        #:build-type "Release"
@@ -202,6 +197,8 @@ compiler.  In LLVM this library is called \"compiler-rt=
\".")
                    (lambda* (#:key inputs #:allow-other-keys)
                      (let ((libc (assoc-ref inputs "libc"))
                            (compiler-rt (assoc-ref inputs "clang-runtime")=
)
+                           (gcc (assoc-ref inputs "gcc"))
+                           (kernel-headers (assoc-ref inputs "kernel-heade=
rs"))
                            (version
                             (string->number
                              ,(version-major (package-version clang-runtim=
e)))))
@@ -221,7 +218,10 @@ compiler.  In LLVM this library is called \"compiler-r=
t\".")
                             ;; Make sure libc's libdir is on the search pa=
th, to
                             ;; allow crt1.o & co. to be found.
                             (("@GLIBC_LIBDIR@")
-                             (string-append libc "/lib"))))
+                             (string-append libc "/lib"))
+                            (("@C_EXTRA_INCLUDE_DIRS@")
+                             (string-append libc "/include" ":"
+                                            kernel-headers "/include"))))
                          (else
                           (substitute* "lib/Driver/Tools.cpp"
                             ;; Patch the 'getLinuxDynamicLinker' function =
so that
diff --git a/gnu/packages/patches/clang-3.5-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-3.5-libc-search-path.patch
index 50e4480239..54fb9be7d8 100644
--- a/gnu/packages/patches/clang-3.5-libc-search-path.patch
+++ b/gnu/packages/patches/clang-3.5-libc-search-path.patch
@@ -8,7 +8,7 @@ to make sure Clang also works on non-GuixSD systems.
=20
 --- cfe-3.6.0.src/lib/Driver/ToolChains.cpp=092015-02-18 22:03:07.00000000=
0 +0100
 +++ cfe-3.6.0.src/lib/Driver/ToolChains.cpp=092015-06-19 16:37:20.45970104=
4 +0200
-@@ -2931,6 +2931,9 @@ Linux::Linux(const Driver &D, const llvm
+@@ -3040,6 +3040,9 @@
 =20
    Linker =3D GetLinkerPath();
 =20
@@ -18,7 +18,7 @@ to make sure Clang also works on non-GuixSD systems.
    Distro Distro =3D DetectDistro(Arch);
 =20
    if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
-@@ -2973,6 +2976,7 @@ Linux::Linux(const Driver &D, const llvm
+@@ -3082,6 +3085,7 @@
 =20
    if (IsOpenSUSE(Distro))
      ExtraOpts.push_back("--enable-new-dtags");
@@ -26,41 +26,49 @@ to make sure Clang also works on non-GuixSD systems.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -3043,14 +3047,12 @@ Linux::Linux(const Driver &D, const llvm
-     addPathIfExists(D.Dir + "/../" + OSLibDir, Paths);
-   }
+@@ -3194,6 +3198,10 @@
 =20
--  addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
--  addPathIfExists(SysRoot + "/lib/../" + OSLibDir, Paths);
--  addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
--  addPathIfExists(SysRoot + "/usr/lib/../" + OSLibDir, Paths);
--
-   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
-   // installations with strange symlinks.
-   if (GCCInstallation.isValid()) {
-+    // The following code would end up adding things like
-+    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
-+#if 0
-     addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
-                     "/../../" + OSLibDir, Paths);
-=20
-@@ -3060,6 +3062,7 @@ Linux::Linux(const Driver &D, const llvm
-       addPathIfExists(GCCInstallation.getInstallPath() +
-                       BiarchSibling.gccSuffix(), Paths);
-     }
-+#endif
-=20
-     // See comments above on the multilib variant for details of why this=
 is
-     // included even from outside the sysroot.
-@@ -3083,8 +3086,9 @@ Linux::Linux(const Driver &D, const llvm
-   if (StringRef(D.Dir).startswith(SysRoot))
-     addPathIfExists(D.Dir + "/../lib", Paths);
-=20
--  addPathIfExists(SysRoot + "/lib", Paths);
--  addPathIfExists(SysRoot + "/usr/lib", Paths);
+   addPathIfExists(SysRoot + "/lib", Paths);
+   addPathIfExists(SysRoot + "/usr/lib", Paths);
++
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists("@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const {
+@@ -3384,6 +3392,34 @@
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
+=20
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
++
++  // Check for configure-time "extra" C include directories. When constru=
cting a
++  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
++  // colon-separated string of the include dirs of libc and kernel header=
s.
++  //
++  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
++  // because when a user supplies clang with --sysroot, the normal expect=
ation
++  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
++  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
++  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
++  // and not attempt to add the aforementioned search paths, which is not
++  // desirable.
++  //
++  // By adding our configure-time "extra" C include directories here, aft=
er
++  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
++  // --sysroot is supplied on the command line, we pick up the expected s=
earch
++  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
++  // C include directories.
++  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
++  if (CExtraIncludeDirs !=3D "") {
++      SmallVector<StringRef, 5> dirs;
++      CExtraIncludeDirs.split(dirs, ":");
++      for (StringRef dir : dirs) {
++          StringRef Prefix =3D
++              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
++          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
++      }
++  }
+ }
+=20
+ /// \brief Helper to add the variant paths of a libstdc++ installation.
diff --git a/gnu/packages/patches/clang-3.8-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-3.8-libc-search-path.patch
index 0f7d0a4add..243d167755 100644
--- a/gnu/packages/patches/clang-3.8-libc-search-path.patch
+++ b/gnu/packages/patches/clang-3.8-libc-search-path.patch
@@ -29,41 +29,49 @@ changes in clang 3.8.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -3771,14 +3775,12 @@
-     addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
-   }
+@@ -3817,6 +3821,10 @@
 =20
--  addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
--  addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
--  addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
--  addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
--
-   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
-   // installations with strange symlinks.
-   if (GCCInstallation.isValid()) {
-+    // The following code would end up adding things like
-+    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
-+#if 0
-     addPathIfExists(D,
-                     SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
-                         "/../../" + OSLibDir,
-@@ -3791,6 +3793,7 @@
-                              BiarchSibling.gccSuffix(),
-                       Paths);
-     }
-+#endif
-=20
-     // See comments above on the multilib variant for details of why this=
 is
-     // included even from outside the sysroot.
-@@ -3815,8 +3818,9 @@
-   if (StringRef(D.Dir).startswith(SysRoot))
-     addPathIfExists(D, D.Dir + "/../lib", Paths);
-=20
--  addPathIfExists(D, SysRoot + "/lib", Paths);
--  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+   addPathIfExists(D, SysRoot + "/lib", Paths);
+   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
++
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const { return true; }
+@@ -4026,6 +4034,34 @@
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
+=20
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
++
++  // Check for configure-time "extra" C include directories. When constru=
cting a
++  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
++  // colon-separated string of the include dirs of libc and kernel header=
s.
++  //
++  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
++  // because when a user supplies clang with --sysroot, the normal expect=
ation
++  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
++  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
++  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
++  // and not attempt to add the aforementioned search paths, which is not
++  // desirable.
++  //
++  // By adding our configure-time "extra" C include directories here, aft=
er
++  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
++  // --sysroot is supplied on the command line, we pick up the expected s=
earch
++  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
++  // C include directories.
++  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
++  if (CExtraIncludeDirs !=3D "") {
++      SmallVector<StringRef, 5> dirs;
++      CExtraIncludeDirs.split(dirs, ":");
++      for (StringRef dir : dirs) {
++          StringRef Prefix =3D
++              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
++          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
++      }
++  }
+ }
+=20
+=20
diff --git a/gnu/packages/patches/clang-6.0-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-6.0-libc-search-path.patch
index a62e8063c2..d80c798467 100644
--- a/gnu/packages/patches/clang-6.0-libc-search-path.patch
+++ b/gnu/packages/patches/clang-6.0-libc-search-path.patch
@@ -8,18 +8,17 @@ to make sure Clang also works on non-GuixSD systems.
=20
 --- cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp
 +++ cfe-6.0.0.src/lib/Driver/ToolChains/Linux.cpp
-@@ -207,7 +207,9 @@
-   PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
+@@ -208,6 +208,9 @@
                           GCCInstallation.getTriple().str() + "/bin")
                         .str());
--
+=20
 +  // Comment out the distro-specific tweaks so that they don't bite when
 +  // using Guix on a foreign distro.
 +#if 0
    Distro Distro(D.getVFS());
 =20
    if (Distro.IsAlpineLinux()) {
-@@ -255,6 +257,7 @@
+@@ -255,6 +258,7 @@
 =20
    if (IsAndroid || Distro.IsOpenSUSE())
      ExtraOpts.push_back("--enable-new-dtags");
@@ -27,41 +26,49 @@ to make sure Clang also works on non-GuixSD systems.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -329,14 +332,12 @@
-     addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
-   }
-=20
--  addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
--  addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
--  addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
--  addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
--
-   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
-   // installations with strange symlinks.
-   if (GCCInstallation.isValid()) {
-+    // The following code would end up adding things like
-+    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
-+#if 0
-     addPathIfExists(D,
-                     SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
-                         "/../../" + OSLibDir,
-@@ -349,6 +350,7 @@
-                              BiarchSibling.gccSuffix(),
-                       Paths);
-     }
-+#endif
+@@ -375,6 +379,10 @@
 =20
-     // See comments above on the multilib variant for details of why this=
 is
-     // included even from outside the sysroot.
-@@ -373,8 +375,9 @@
-   if (StringRef(D.Dir).startswith(SysRoot))
-     addPathIfExists(D, D.Dir + "/../lib", Paths);
-=20
--  addPathIfExists(D, SysRoot + "/lib", Paths);
--  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+   addPathIfExists(D, SysRoot + "/lib", Paths);
+   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
++
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const { return true; }
+@@ -710,6 +718,34 @@
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
+=20
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
++
++  // Check for configure-time "extra" C include directories. When constru=
cting a
++  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
++  // colon-separated string of the include dirs of libc and kernel header=
s.
++  //
++  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
++  // because when a user supplies clang with --sysroot, the normal expect=
ation
++  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
++  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
++  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
++  // and not attempt to add the aforementioned search paths, which is not
++  // desirable.
++  //
++  // By adding our configure-time "extra" C include directories here, aft=
er
++  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
++  // --sysroot is supplied on the command line, we pick up the expected s=
earch
++  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
++  // C include directories.
++  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
++  if (CExtraIncludeDirs !=3D "") {
++      SmallVector<StringRef, 5> dirs;
++      CExtraIncludeDirs.split(dirs, ":");
++      for (StringRef dir : dirs) {
++          StringRef Prefix =3D
++              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
++          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
++      }
++  }
+ }
+=20
+ static std::string DetectLibcxxIncludePath(StringRef base) {
diff --git a/gnu/packages/patches/clang-7.0-libc-search-path.patch b/gnu/pa=
ckages/patches/clang-7.0-libc-search-path.patch
index 07ff8c90bd..445b5d17ac 100644
--- a/gnu/packages/patches/clang-7.0-libc-search-path.patch
+++ b/gnu/packages/patches/clang-7.0-libc-search-path.patch
@@ -8,7 +8,7 @@ to make sure Clang also works on non-GuixSD systems.
=20
 --- a/lib/Driver/ToolChains/Linux.cpp
 +++ b/lib/Driver/ToolChains/Linux.cpp
-@@ -225,7 +225,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
+@@ -225,7 +225,9 @@
    PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
                           GCCInstallation.getTriple().str() + "/bin")
                         .str());
@@ -19,7 +19,7 @@ to make sure Clang also works on non-GuixSD systems.
    Distro Distro(D.getVFS());
 =20
    if (Distro.IsAlpineLinux()) {
-@@ -284,6 +286,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
+@@ -284,6 +286,7 @@
 =20
    if (IsAndroid || Distro.IsOpenSUSE())
      ExtraOpts.push_back("--enable-new-dtags");
@@ -27,56 +27,49 @@ to make sure Clang also works on non-GuixSD systems.
 =20
    // The selection of paths to try here is designed to match the patterns=
 which
    // the GCC driver itself uses, as this is part of the GCC-compatible dr=
iver.
-@@ -342,7 +345,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
-     // the cross. Note that GCC does include some of these directories in=
 some
-     // configurations but this seems somewhere between questionable and s=
imply
-     // a bug.
--    if (StringRef(LibPath).startswith(SysRoot)) {
-+    if (0) {
-       addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths);
-       addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths);
-     }
-@@ -361,6 +364,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
-   addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
-   addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
+@@ -431,6 +434,10 @@
 =20
-+  // This requires the commented distro tweaks above.
-+#if 0
-   if (IsAndroid) {
-     // Android sysroots contain a library directory for each supported OS
-     // version as well as some unversioned libraries in the usual multiar=
ch
-@@ -389,10 +394,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Tr=
iple, const ArgList &Args)
-     addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths);
-     addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Path=
s);
-   }
-+#endif
-=20
-   // Try walking via the GCC triple path in case of biarch or multiarch G=
CC
-   // installations with strange symlinks.
-   if (GCCInstallation.isValid()) {
-+    // The following code would end up adding things like
-+    // "/usr/lib/x86_64-unknown-linux-gnu/../../lib64" to the search path=
.
-+#if 0
-     addPathIfExists(D,
-                     SysRoot + "/usr/lib/" + GCCInstallation.getTriple().s=
tr() +
-                         "/../../" + OSLibDir,
-@@ -405,6 +414,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
-                              BiarchSibling.gccSuffix(),
-                       Paths);
-     }
-+#endif
-=20
-     // See comments above on the multilib variant for details of why this=
 is
-     // included even from outside the sysroot.
-@@ -429,8 +439,9 @@ Linux::Linux(const Driver &D, const llvm::Triple &Trip=
le, const ArgList &Args)
-   if (StringRef(D.Dir).startswith(SysRoot))
-     addPathIfExists(D, D.Dir + "/../lib", Paths);
-=20
--  addPathIfExists(D, SysRoot + "/lib", Paths);
--  addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+   addPathIfExists(D, SysRoot + "/lib", Paths);
+   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
++
 +  // Add libc's lib/ directory to the search path, so that crt1.o, crti.o=
,
 +  // and friends can be found.
 +  addPathIfExists(D, "@GLIBC_LIBDIR@", Paths);
  }
 =20
  bool Linux::HasNativeLLVMSupport() const { return true; }
+@@ -794,6 +801,34 @@
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
+=20
+   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
++
++  // Check for configure-time "extra" C include directories. When constru=
cting a
++  // toolchain, @C_EXTRA_INCLUDE_DIRS@ should be replaced with something =
like a
++  // colon-separated string of the include dirs of libc and kernel header=
s.
++  //
++  // The reason why we use this mechanism instead of C_INCLUDE_DIRS above=
 is
++  // because when a user supplies clang with --sysroot, the normal expect=
ation
++  // is that clang will detect and add the proper $SYSROOT/$MULTIARCHINCL=
,
++  // $SYSROOT/include, and $SYSROOT/usr/include to its list of search pat=
hs.
++  // However, if C_INCLUDE_DIRS is not empty, this function will return e=
arly
++  // and not attempt to add the aforementioned search paths, which is not
++  // desirable.
++  //
++  // By adding our configure-time "extra" C include directories here, aft=
er
++  // we've added $SYSROOT/include and $SYSROOT/usr/include, we make sure =
that IF
++  // --sysroot is supplied on the command line, we pick up the expected s=
earch
++  // paths in the $SYSROOT, and that they come before our configure-time =
"extra"
++  // C include directories.
++  StringRef CExtraIncludeDirs("@C_EXTRA_INCLUDE_DIRS@");
++  if (CExtraIncludeDirs !=3D "") {
++      SmallVector<StringRef, 5> dirs;
++      CExtraIncludeDirs.split(dirs, ":");
++      for (StringRef dir : dirs) {
++          StringRef Prefix =3D
++              llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : ""=
;
++          addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
++      }
++  }
+ }
+=20
+ static std::string DetectLibcxxIncludePath(StringRef base) {







Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.