Subject: bug#72669: gcc-toolchain environment variables

From: creightor <[email-masked]>
Date: Fri, 16 Aug 2024 12:02:35 +0300

Hi, it looks like having the C_INCLUDE_PATH and CPLUS_INCLUDE_PATH 
environment variables set by the gcc-toolchain package in a profile can 
cause issues.

For example, I have gcc-toolchain installed, compiled a cross-binutils 
for aarch64-elf and then tried to compile a gcc cross-compiler for the 
same target using those binutils.

These are the flags I used for binutils:

--target=aarch64-none-elf --disable-multilib

and for the gcc cross-compiler:

--target=aarch64-none-elf --disable-multilib --disable-bootstrap 
--enable-languages=c,c++ --without-headers --with-newlib 
--disable-hosted-libstdcxx --disable-libssp --disable-libsanitizer

 From what I understand, there should be no headers available when 
creating a cross-compiler for a freestanding platform like this.

Since these include paths were added with C_INCLUDE_PATH and 
CPLUS_INCLUDE_PATH, something like `#if __has_include(<sys/auxv.h>)` in 
gcc's libgcc/config/aarch64/cpuinfo.c evaluated to true and the rest of 
the build would fail.

Unsetting them didn't work since apparently gcc-toolchain relies on them 
set so I had these two variables unset in BASE_TARGET_EXPORTS in gcc's 
root Makefile.in which should only apply to the newly built gcc 
cross-compiler and so the build finished fine.