From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Wingo Subject: bug#22186: Use {C,CPLUS,OBJC}_INCLUDE_PATH instead of CPATH Date: Wed, 16 Dec 2015 14:41:11 +0000 Message-ID: <871tama22g.fsf@igalia.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9FAO-0003R0-Sa for bug-guix@gnu.org; Wed, 16 Dec 2015 11:43:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9FAL-0002zP-Vs for bug-guix@gnu.org; Wed, 16 Dec 2015 11:43:04 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:46163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9FAL-0002zL-Rx for bug-guix@gnu.org; Wed, 16 Dec 2015 11:43:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1a9FAL-0007pq-Pd for bug-guix@gnu.org; Wed, 16 Dec 2015 11:43:01 -0500 Sender: "Debbugs-submit" Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9DGd-0005sq-1u for bug-guix@gnu.org; Wed, 16 Dec 2015 09:41:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9DGY-0007Ks-MA for bug-guix@gnu.org; Wed, 16 Dec 2015 09:41:22 -0500 Received: from pb-sasl0.int.icgroup.com ([208.72.237.25]:58078 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9DGY-0007Je-HU for bug-guix@gnu.org; Wed, 16 Dec 2015 09:41:18 -0500 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl0.pobox.com (Postfix) with ESMTP id 3DDB22F43B for ; Wed, 16 Dec 2015 09:41:17 -0500 (EST) Received: from pb-sasl0.int.icgroup.com (unknown [127.0.0.1]) by pb-sasl0.pobox.com (Postfix) with ESMTP id 2912C2F43A for ; Wed, 16 Dec 2015 09:41:17 -0500 (EST) Received: from rusty (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl0.pobox.com (Postfix) with ESMTPSA id D72262F438 for ; Wed, 16 Dec 2015 09:41:15 -0500 (EST) List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: 22186@debbugs.gnu.org Hi, I am building GDB from git, because I want to hack on GDB. I have a few build-related things in my profile, including GCC. I enter an environment for GDB like this: guix environment gdb --ad-hoc flex autoconf-2.64 Cool. Very good. I build: mkdir +2.0 cd +2.0 ../configure --prefix=/opt/gdb make However, eventually: /bin/sh ./libtool --tag=CC --mode=compile ccache gcc -DHAVE_CONFIG_H -I. -I../../bfd -I. -I../../bfd -I../../bfd/../include -DHAVE_x86_64_elf64_vec -DHAVE_i386_elf32_vec -DHAVE_iamcu_elf32_vec -DHAVE_x86_64_elf32_vec -DHAVE_i386_aout_linux_vec -DHAVE_i386_pei_vec -DHAVE_x86_64_pei_vec -DHAVE_l1om_elf64_vec -DHAVE_k1om_elf64_vec -DHAVE_elf64_le_vec -DHAVE_elf64_be_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -DBINDIR='"/opt/guile-2.0/bin"' -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I../../bfd/../zlib -g -O2 -MT peigen.lo -MD -MP -MF .deps/peigen.Tpo -c -o peigen.lo peigen.c libtool: compile: ccache gcc -DHAVE_CONFIG_H -I. -I../../bfd -I. -I../../bfd -I../../bfd/../include -DHAVE_x86_64_elf64_vec -DHAVE_i386_elf32_vec -DHAVE_iamcu_elf32_vec -DHAVE_x86_64_elf32_vec -DHAVE_i386_aout_linux_vec -DHAVE_i386_pei_vec -DHAVE_x86_64_pei_vec -DHAVE_l1om_elf64_vec -DHAVE_k1om_elf64_vec -DHAVE_elf64_le_vec -DHAVE_elf64_be_vec -DHAVE_elf32_le_vec -DHAVE_elf32_be_vec -DHAVE_plugin_vec -DBINDIR=\"/opt/guile-2.0/bin\" -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -I../../bfd/../zlib -g -O2 -MT peigen.lo -MD -MP -MF .deps/peigen.Tpo -c peigen.c -o peigen.o In file included from peigen.c:66:0: /home/wingo/.guix-profile/include/wchar.h: In function 'wctob': /home/wingo/.guix-profile/include/wchar.h:397:47: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] { return (__builtin_constant_p (__wc) && __wc >= L'\0' && __wc <= L'\x7f' ^ This is an error, and the error is in wchar.h, not in the invocation or use of wchar.h. Let's see where this file comes from: ls -l /home/wingo/.guix-profile/include/wchar.h lrwxrwxrwx 21 root guixbuild 79 Jan 1 1970 /home/wingo/.guix-profile/include/wchar.h -> /gnu/store/q7k2dc3ylpjnjlhb59f01bxxab8fjxr6-gcc-toolchain-5.2.0/include/wchar.h So! gcc-toolchain-5.2. Why is there an error? Well, of course, although harmless, the "error" exists in the source, though perhaps GCC itself doesn't build with -Werror=type-limits, so they didn't see this error in the release. The error comes from the combination of the -Werror and warning flags that GDB is building with and the files from gcc-toolchain. Backing up a bit, it's not something that I actually care about right now. I'm working on GDB, the error is innocuous, and I can't easily fix GCC right now, nor do I care. I'm also surprised this is happening -- wouldn't it be caught by some other distro user? Well yes, except that normally this header is in /usr/include, and by default, all warnings are disabled for system headers. And there's the rub! Why am I getting a warning for code in ~/.guix-profile/include ? The answer is interesting! I quote the GCC manual, section "Environment Variables": Some additional environment variables affect the behavior of the preprocessor. 'CPATH' 'C_INCLUDE_PATH' 'CPLUS_INCLUDE_PATH' 'OBJC_INCLUDE_PATH' Each variable's value is a list of directories separated by a special character, much like 'PATH', in which to look for header files. The special character, 'PATH_SEPARATOR', is target-dependent and determined at GCC build time. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets it is a colon. 'CPATH' specifies a list of directories to be searched as if specified with '-I', but after any paths given with '-I' options on the command line. This environment variable is used regardless of which language is being preprocessed. The remaining environment variables apply only when preprocessing the particular language indicated. Each specifies a list of directories to be searched as if specified with '-isystem', but after any paths given with '-isystem' options on the command line. In all these variables, an empty element instructs the compiler to search its current working directory. Empty elements can appear at the beginning or end of a path. For instance, if the value of 'CPATH' is ':/special/include', that has the same effect as '-I. -I/special/include'. So! CPATH is like -I but C_INCLUDE_PATH et al are like -isystem. Here's the docs for -isystem ("Preprocessor Options"): '-isystem DIR' Search DIR for header files, after all directories specified by '-I' but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories. If DIR begins with '=', then the '=' will be replaced by the sysroot prefix; see '--sysroot' and '-isysroot'. What is a system directory? Well, it's searched for after all -I includes, but also header files in it are marked as system headers. Many warnings are not issued for system headers; search the manual for the phrase "system headers". For example: '-Wsystem-headers' Issue warnings for code in system headers. These are normally unhelpful in finding bugs in your own code, therefore suppressed. If you are responsible for the system library, you may want to see them. So. We should be using C_INCLUDE_PATH instead of CPATH, to mark system headers as system headers. Except that C_INCLUDE_PATH only works for C, so we need to also set CPLUS_INCLUDE_PATH and OBJC_INCLUDE_PATH. And that's the proposal of this bug :) Andy