From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 03 04:01:11 2020 Received: (at 30756) by debbugs.gnu.org; 3 Feb 2020 09:01:11 +0000 Received: from localhost ([127.0.0.1]:40865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iyXbO-0004ww-VA for submit@debbugs.gnu.org; Mon, 03 Feb 2020 04:01:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:35207) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iyXbN-0004wM-Ht for 30756@debbugs.gnu.org; Mon, 03 Feb 2020 04:01:06 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]:34960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iyXbI-0001LL-1F; Mon, 03 Feb 2020 04:01:00 -0500 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55934 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1iyXb2-0002DK-RI; Mon, 03 Feb 2020 04:00:47 -0500 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Maxim Cournoyer Subject: Re: bug#30756: GCC >= 6 '-isystem' and C_INCLUDE_PATH behavior changed, breaking References: <87y2u3qh8b.fsf@gnu.org> <87r1zulsgc.fsf@gmail.com> <87sgkaik08.fsf@gnu.org> <878sm0kx8b.fsf@gmail.com> <87wo9hnbp9.fsf@gnu.org> Date: Mon, 03 Feb 2020 10:00:42 +0100 In-Reply-To: <87wo9hnbp9.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Thu, 23 Jan 2020 21:45:54 +0100") Message-ID: <87blqg2gg5.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 30756 Cc: reza.housseini@gmx.ch, 30756@debbugs.gnu.org, Marius Bakke , Reza Housseini X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello comrades! (+Cc: Marius.) Ludovic Court=C3=A8s skribis: > =E2=80=98%final-inputs=E2=80=99 order actually looks good: > > scheme@(gnu packages commencement)> (map car %final-inputs) > $2 =3D ("tar" "gzip" "bzip2" "xz" "file" "diffutils" "patch" "findutils" = "gawk" "sed" "grep" "coreutils" "make" "bash" "ld-wrapper" "binutils" "gcc"= "libc" "libc:static" "locales") > > > But then it breaks when we add everything: > > scheme@(guile-user)> (map car (bag-transitive-inputs (package->bag coreut= ils))) > $5 =3D ("source" "perl" "tar" "gzip" "bzip2" "xz" "file" "diffutils" "pat= ch" "findutils" "gawk" "sed" "grep" "coreutils" "make" "bash" "ld-wrapper" = "binutils" "gcc" "libc" "libc:static" "locales" "acl" "gmp" "libcap" "kerne= l-headers") > > Here acl, gmp, and libcap should be before libc and all > (=E2=80=98bag-transitive-inputs=E2=80=99 is used by =E2=80=98bag->derivat= ion=E2=80=99.) > > So I think we should arrange to have the right order in > =E2=80=98bag->derivation=E2=80=99. The attached patch does three things: 1. Fix the order of inputs computed by (@@ (guix build-system gnu) lower) so that implicit inputs come last. In particular, this ensures that libc headers and kernel headers come last. All user libraries passed as =E2=80=98inputs=E2=80=99 appear before libc, so th= ey can #include_next a libc header. 2. Add =E2=80=9Cinclude/c++=E2=80=9D to the list of directories of =E2=80=98CPLUS_INCLUDE_PATH=E2=80=99. This is a not-so-elegant hack; = the main purpose here is to make sure the gcc/libstdc++ include directory appears twice in the search path, so that this chain of include works as expected: (GCC): #include_next =E2=86=92 (GCC): #include_next =E2=86=92 (libc) 3. Switch back to =E2=80=98C_INCLUDE_PATH=E2=80=99 & co. instead of =E2= =80=98CPATH=E2=80=99 (yay!). I=E2=80=99ve tested it with =E2=80=9Cguix build coreutils=E2=80=9D, which i= nvolved building GMP with its C++ bindings, making it a rather good test. However, more testing is needed. There=E2=80=99s potential for breakage in all the places where we=E2=80=99v= e manually fiddled with C{,PLUS}_INCLUDE_PATH. I guess we=E2=80=99ll have to review a= ll of them. Since it fixes a rather serious issue for C/C++ developers (they=E2=80=99d rather not see warnings about system headers) but also for packaging (=E2=80=98-Werror=E2=80=99 breaks for warnings that shouldn=E2=80=99t be th= ere in the first place), I=E2=80=99d like to propose merging it in this =E2=80=98core-update= s=E2=80=99 cycle. But let=E2=80=99s face it: it=E2=80=99ll keep us busy for a bit. :-) Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index 851bb02163..473d6b8345 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovi= c Court=C3=A8s +;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 = Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2014 Andreas Enge ;;; Copyright =C2=A9 2012 Nikita Karetnikov ;;; Copyright =C2=A9 2014, 2015, 2017 Mark H Weaver @@ -2303,15 +2303,6 @@ exec ~a/bin/~a-~a -B~a/lib -Wl,-dynamic-linker -Wl,~= a/~a \"$@\"~%" char-set:letter) ,(package-name lib))) (list gmp-6.0 mpfr mpc)) - #t))) - (add-before 'configure 'treat-glibc-as-system-header - (lambda* (#:key inputs #:allow-other-keys) - (let ((libc (assoc-ref inputs "libc"))) - ;; Make sure Glibc is treated as a "system header" so - ;; #include_next does the right thing. - (for-each (lambda (var) - (setenv var (string-append libc "/includ= e"))) - '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) #t)))))))) =20 ;; This time we want Texinfo, so we get the manual. Add diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index 40cc9ed631..4c4b63dbd1 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovi= c Court=C3=A8s +;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 = Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2014, 2015, 2018 Mark H Weaver ;;; Copyright =C2=A9 2014, 2015, 2016, 2017, 2019 Ricardo Wurmus ;;; Copyright =C2=A9 2015 Andreas Enge @@ -340,7 +340,9 @@ where the OS part is overloaded to denote a specific AB= I---into GCC (files '("include"))) (search-path-specification (variable "CPLUS_INCLUDE_PATH") - (files '("include"))) + ;; Add 'include/c++' here so that 's "#include_next + ;; " finds GCC's , not libc's. + (files '("include/c++" "include"))) (search-path-specification (variable "LIBRARY_PATH") (files '("lib" "lib64"))))) @@ -476,17 +478,7 @@ Go. It also includes runtime support libraries for th= ese languages.") "gcc-5.0-libvtv-runpath.patch")))) (inputs `(("isl" ,isl) - ,@(package-inputs gcc-4.7))) - - (native-search-paths - ;; We have to use 'CPATH' for GCC > 5, not 'C_INCLUDE_PATH' & co., du= e to - ;; . - (list (search-path-specification - (variable "CPATH") - (files '("include"))) - (search-path-specification - (variable "LIBRARY_PATH") - (files '("lib" "lib64"))))))) + ,@(package-inputs gcc-4.7))))) =20 (define-public gcc-7 (package diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index 3cc89f8852..6e66f5ffce 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2019 Ludovic Cour= t=C3=A8s +;;; Copyright =C2=A9 2012, 2013, 2014, 2015, 2016, 2017, 2019, 2020 Ludovi= c Court=C3=A8s ;;; ;;; This file is part of GNU Guix. ;;; @@ -296,13 +296,19 @@ standard packages used as implicit inputs of the GNU = build system." `(("source" ,source)) '()) ,@native-inputs + + ;; When not cross-compiling, ensure implicit inputs co= me + ;; last. That way, libc headers come last, which allo= ws + ;; #include_next to work correctly; see + ;; . + ,@(if target '() inputs) ,@(if (and target implicit-cross-inputs?) (standard-cross-packages target 'host) '()) ,@(if implicit-inputs? (standard-packages) '()))) - (host-inputs inputs) + (host-inputs (if target inputs '())) =20 ;; The cross-libc is really a target package, but for bootstrapping ;; reasons, we can't put it in 'host-inputs'. Namely, 'cross-gcc' is a --=-=-=--