From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id C88413858D37 for ; Sat, 12 Feb 2022 07:23:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C88413858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id 67A213432FC; Sat, 12 Feb 2022 07:23:36 +0000 (UTC) From: Mike Frysinger To: newlib@sourceware.org Subject: [PATCH/RFC] libgloss: build with -nostdinc Date: Sat, 12 Feb 2022 02:23:37 -0500 Message-Id: <20220212072337.21734-1-vapier@gentoo.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_STOCKGEN, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Feb 2022 07:23:41 -0000 We don't want libgloss building against C library headers that happened to be installed with the toolchain, so add -nostdinc to the build. We still need access to the compiler internal headers, so probe those and include them via -isystem. This uses a similar probing style as glibc, which has used it for over a decade, so it should be safe & stable. This should prevent any latent bugs due to testing with a toolchain that is fully configured & installed already. --- NB: tested against these targets: aarch64-elf arc-elf arm-eabi bfin-elf cr16-elf cris-elf csky-elf epiphany-elf frv-elf h8300-elf i686-pc-cygwin iq2000-elf m68k-elf microblaze-elf mips-elf mn10300-elf moxie-elf nds32le-elf or1k-elf powerpc-elf sparc-elf sparc-rtems v850e-elf visium-elf libgloss/configure | 20 ++++++++++++++++++++ libgloss/configure.ac | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/libgloss/configure b/libgloss/configure index 08b2609062f3..6cdd4842ae9d 100755 --- a/libgloss/configure +++ b/libgloss/configure @@ -4998,6 +4998,26 @@ $as_echo "#define MISSING_SYSCALL_NAMES 1" >>confdefs.h esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler search settings" >&5 +$as_echo_n "checking for compiler search settings... " >&6; } +if ${libc_cv_compiler_isystem+:} false; then : + $as_echo_n "(cached) " >&6 +else + for subdir in include include-fixed; do + if dir=`$CC -print-file-name=$subdir`; then : + if test -n "$dir"; then : + libc_cv_compiler_isystem="$libc_cv_compiler_isystem -isystem $dir" + +fi + +fi + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_compiler_isystem" >&5 +$as_echo "$libc_cv_compiler_isystem" >&6; } +CC="$CC -nostdinc $libc_cv_compiler_isystem" + host_makefile_frag_path=$host_makefile_frag diff --git a/libgloss/configure.ac b/libgloss/configure.ac index 486492b7bf0d..e26f295f5d00 100644 --- a/libgloss/configure.ac +++ b/libgloss/configure.ac @@ -323,6 +323,17 @@ AC_DEFINE_UNQUOTED(__SYMBOL_PREFIX, "$libc_cv_symbol_prefix", [symbol prefix]) m4_include([libnosys/acinclude.m4]) +AC_CACHE_CHECK([for compiler search settings], libc_cv_compiler_isystem, [dnl + for subdir in include include-fixed; do + AS_IF([dir=`$CC -print-file-name=$subdir`], [dnl + AS_IF([test -n "$dir"], [dnl + libc_cv_compiler_isystem="$libc_cv_compiler_isystem -isystem $dir" + ]) + ]) + done +]) +CC="$CC -nostdinc $libc_cv_compiler_isystem" + dnl We have to assign the same value to other variables because autoconf dnl doesn't provide a mechanism to substitute a replacement keyword with dnl arbitrary data or pathnames. -- 2.34.1