]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Make _GLIBCXX_HOSTED respect -ffreestanding [PR103626]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 20 Sep 2022 10:57:28 +0000 (11:57 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 3 Oct 2022 14:43:48 +0000 (15:43 +0100)
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.

libstdc++-v3/acinclude.m4
libstdc++-v3/configure
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/testsuite/lib/libstdc++.exp
libstdc++-v3/testsuite/libstdc++-abi/abi.exp

index 9aa81e1ac13a34355591cb22a46bb5e6f70c38d0..1b404d7df220c96d3120de4dc5f42bcc10e38678 100644 (file)
@@ -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,
index 07916d14d93dc48d514dff3db1377df00ae80982..1ff28af2c2c1810ad31b1a8c6f23733acb6abe10 100755 (executable)
@@ -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
 
 
index 3eeb407a57f0903b7850255832425d118fa5456b..3472e84f75c5b999a3f2a04b937c2255c12505db 100644 (file)
@@ -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 \
index e24563caaeda61d2e14d8017dd0077e36a7da1f6..39ef34fc3cedf0ce67e7884f7f62eaf3c691f28e 100644 (file)
@@ -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 \
index 0338b50897f5dc9e4544e7eda41c43c736b5b8c2..d3256b6c8c415986d2600a100effd8f049ab869b 100644 (file)
@@ -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"
            }
index 9e919e1d7a0bbf01408c792bfc89b3390332d8c8..66f19ea4514ca6f5a509dc2f94d8d19b0607071c 100644 (file)
@@ -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"
 }