From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) by sourceware.org (Postfix) with ESMTPS id 11D173858C55; Fri, 30 Sep 2022 16:46:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 11D173858C55 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=aarsen.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=aarsen.me Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4MfGMX2jZzz9sTR; Fri, 30 Sep 2022 18:46:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1664556376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=55if0+o2UDG8fxmnabh2tmWl9wv7iX1yq/x6oBf/7FI=; b=zEemca1PdJfsmAJGZpG3apaJNGMpNu5Rvo4pCXPwG0jq6aO1lB/dKHl1a57ppopGsAOoZA jxOH28izFUcABl5vrymcTTJw//nMQ5AM+kkqlde2DHOQvqK1X4pzqf5e2EmqoIb9dekB6b R3FYfZ4kVqqiTp6m7QiF2WC4vFoZG/wknahZ4XYDbb7PwZDugaURTZW6U7RBsi/d8utYL3 FTIVSlagQ+STburx6MNhxTH3hO6GLKoTIoE1BooMZjSh3olxRdYAh/OqAWldrXgXo9Trke XbOVj9/4j2TnwgqfDUPzGxlpEvLOlE0/6XacI2a+yo3bX1qJ5kqkuKcPAWKGYw== From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Jonathan Wakely , =?UTF-8?q?Arsen=20Arsenovi=C4=87?= Subject: [PATCH 01/10] libstdc++: Make _GLIBCXX_HOSTED respect -ffreestanding [PR103626] Date: Fri, 30 Sep 2022 18:45:47 +0200 Message-Id: <20220930164556.1198044-2-arsen@aarsen.me> In-Reply-To: <20220930164556.1198044-1-arsen@aarsen.me> References: <20220930164556.1198044-1-arsen@aarsen.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_INFOUSMEBIZ,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Jonathan Wakely This allows the library to switch to freestanding mode when compiling with the -ffreestanding flag. This means you don't need a separate libstdc++ build configured with --disable-hosted-libstdcxx in order to compile for a freestanding environment. The testsuite support files cannot be compiled for freestanding, so add -fno-freestanding to override any -ffreestanding in the test flags. libstdc++-v3/ChangeLog: PR libstdc++/103626 * acinclude.m4 (GLIBCXX_ENABLE_HOSTED): Define _GLIBCXX_HOSTED to __STDC_HOSTED__ for non-freestanding installations. * configure: Regenerate. * include/Makefile.am (${host_builddir}/c++config.h): Adjust grep pattern. * include/Makefile.in: Regenerate. * testsuite/lib/libstdc++.exp (v3-build_support): Use -fno-freestanding. * testsuite/libstdc++-abi/abi.exp: Likewise. Signed-off-by: Arsen Arsenović --- libstdc++-v3/acinclude.m4 | 2 +- libstdc++-v3/configure | 2 +- libstdc++-v3/include/Makefile.am | 2 +- libstdc++-v3/include/Makefile.in | 2 +- libstdc++-v3/testsuite/lib/libstdc++.exp | 4 ++-- libstdc++-v3/testsuite/libstdc++-abi/abi.exp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 9aa81e1ac13..1b404d7df22 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -2992,7 +2992,7 @@ AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [ fi else is_hosted=yes - hosted_define=1 + hosted_define=__STDC_HOSTED__ fi GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes) AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define, diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index 07916d14d93..1ff28af2c2c 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -15651,7 +15651,7 @@ $as_echo "$as_me: Only freestanding libraries will be built" >&6;} fi else is_hosted=yes - hosted_define=1 + hosted_define=__STDC_HOSTED__ fi diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 3eeb407a57f..3472e84f75c 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -1326,7 +1326,7 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \ ${CONFIG_HEADER} > /dev/null 2>&1 \ && ldbl_alt128_compat='s,^#undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT$$,#define _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 1,' ;\ verbose_assert='s,g,g,' ; \ - grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_HOSTED[ ][ ]*1[ ]*$$" \ + grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_HOSTED[ ][ ]*__STDC_HOSTED__[ ]*$$" \ ${CONFIG_HEADER} > /dev/null 2>&1 \ && grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_VERBOSE[ ][ ]*1[ ]*$$" \ ${CONFIG_HEADER} > /dev/null 2>&1 \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index e24563caaed..39ef34fc3ce 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -1820,7 +1820,7 @@ ${host_builddir}/c++config.h: ${CONFIG_HEADER} \ ${CONFIG_HEADER} > /dev/null 2>&1 \ && ldbl_alt128_compat='s,^#undef _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT$$,#define _GLIBCXX_LONG_DOUBLE_ALT128_COMPAT 1,' ;\ verbose_assert='s,g,g,' ; \ - grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_HOSTED[ ][ ]*1[ ]*$$" \ + grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_HOSTED[ ][ ]*__STDC_HOSTED__[ ]*$$" \ ${CONFIG_HEADER} > /dev/null 2>&1 \ && grep "^[ ]*#[ ]*define[ ][ ]*_GLIBCXX_VERBOSE[ ][ ]*1[ ]*$$" \ ${CONFIG_HEADER} > /dev/null 2>&1 \ diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 0338b50897f..d3256b6c8c4 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -654,7 +654,7 @@ proc v3-build_support { } { # do not prevent compilation. # Disable LTO so that ar/ranlib don't need the LTO plugin. if { [v3_target_compile $srcdir/util/$f $object_file "object" \ - [list "incdir=$srcdir" "additional_flags=-w -fno-lto"]] + [list "incdir=$srcdir" "additional_flags=-w -fno-lto -fno-freestanding"]] != "" } { error "could not compile $f" } @@ -693,7 +693,7 @@ proc v3-build_support { } { # Compile with "-w" so that warnings issued by the compiler # do not prevent compilation. if { [v3_target_compile $srcdir/util/$f $object_file "sharedlib" \ - [list "incdir=$srcdir" "additional_flags=-fno-inline -w -shared -fPIC -DPIC -std=gnu++98"]] + [list "incdir=$srcdir" "additional_flags=-fno-inline -w -shared -fPIC -DPIC -std=gnu++98 -fno-freestanding"]] != "" } { error "could not compile $f" } diff --git a/libstdc++-v3/testsuite/libstdc++-abi/abi.exp b/libstdc++-v3/testsuite/libstdc++-abi/abi.exp index 9e919e1d7a0..66f19ea4514 100644 --- a/libstdc++-v3/testsuite/libstdc++-abi/abi.exp +++ b/libstdc++-v3/testsuite/libstdc++-abi/abi.exp @@ -60,7 +60,7 @@ remote_exec "build" "$blddir/scripts/extract_symvers" \ # Build the abi_check program. if { [v3_target_compile "$srcdir/util/testsuite_abi_check.cc" "abi_check" \ - "executable" [list "additional_flags=-w"]] != "" } { + "executable" [list "additional_flags=-w -fno-freestanding"]] != "" } { error "could not compile testsuite_abi_check.cc" } -- 2.37.3