diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-01-06 13:54:53 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-01-10 12:18:14 +0000 |
commit | 68c2e9e9234cb301e9e81792cad233a41e797792 (patch) | |
tree | 2509b991e1905d0c30a30bbecdc8105e091e7739 /libstdc++-v3/acinclude.m4 | |
parent | e54dda45f9acc96f9898b0ed514d7cc1020dd7a4 (diff) | |
download | gcc-68c2e9e9234cb301e9e81792cad233a41e797792.tar.gz |
libstdc++: Fix and simplify freestanding configuration [PR103866]
This fixes the --disable-hosted-libstdcxx build so that it works with
--without-headers. Currently you need to also use --with-newlib, which
is confusing for users who aren't actually using newlib.
The AM_PROG_LIBTOOL checks are currently skipped for --with-newlib and
--with-avrlibc builds, with this change they are also skipped when using
--without-headers. It would be nice if using --disable-hosted-libstdcxx
automatically skipped those checks, but GLIBCXX_ENABLE_HOSTED comes too
late to make the AM_PROG_LIBTOOL checks depend on $is_hosted.
The checks for EOF, SEEK_CUR etc. cause the build to fail if there is no
<stdio.h> available. Unlike most headers, which get a HAVE_FOO_H macro,
<stdio.h> is in autoconf's default includes, so every check tries to
include it unconditionally. This change skips those checks for
freestanding builds.
Similarly, the checks for <stdint.h> types done by GCC_HEADER_STDINT try
to include <stdio.h> and fail for --without-headers builds. This change
skips the use of GCC_HEADER_STDINT for freestanding. We can probably
stop using GCC_HEADER_STDINT entirely, since only one file uses the
gstdint.h header that is generated, and that could easily be changed to
use <stdint.h> instead. That can wait for stage 1.
We also need to skip the GLIBCXX_CROSSCONFIG stage if --without-headers
was used, since we don't have any of the functions it deals with.
The end result of the changes above is that it should not be necessary
for a --disable-hosted-libstdcxx --without-headers build to also use
--with-newlib.
Finally, compile libsupc++ with -ffreestanding when --without-headers is
used, so that <stdint.h> will use <gcc-stdint.h> instead of expecting it
to come from libc.
libstdc++-v3/ChangeLog:
PR libstdc++/103866
* acinclude.m4 (GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS): Do
nothing for freestanding builds.
(GLIBCXX_ENABLE_HOSTED): Define FREESTANDING_FLAGS.
* configure.ac: Do not use AC_LIBTOOL_DLOPEN when configured
with --without-headers. Do not use GCC_HEADER_STDINT for
freestanding builds.
* libsupc++/Makefile.am (HOSTED_CXXFLAGS): Use -ffreestanding
for freestanding builds.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* include/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* python/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* src/c++11/Makefile.in: Regenerate.
* src/c++17/Makefile.in: Regenerate.
* src/c++20/Makefile.in: Regenerate.
* src/c++98/Makefile.in: Regenerate.
* src/filesystem/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
Diffstat (limited to 'libstdc++-v3/acinclude.m4')
-rw-r--r-- | libstdc++-v3/acinclude.m4 | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 635168d7e25..b770d5bcdc4 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -2081,6 +2081,7 @@ dnl Compute the EOF, SEEK_CUR, and SEEK_END integer constants. dnl AC_DEFUN([GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS], [ +if test "$is_hosted" = yes; then AC_CACHE_CHECK([for the value of EOF], glibcxx_cv_stdio_eof, [ AC_COMPUTE_INT([glibcxx_cv_stdio_eof], [[EOF]], [#include <stdio.h>], @@ -2104,6 +2105,7 @@ AC_DEFUN([GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS], [ ]) AC_DEFINE_UNQUOTED(_GLIBCXX_STDIO_SEEK_END, $glibcxx_cv_stdio_seek_end, [Define to the value of the SEEK_END integer constant.]) +fi ]) dnl @@ -2923,12 +2925,16 @@ AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [ enable_hosted_libstdcxx=yes ;; esac]) + freestanding_flags= if test "$enable_hosted_libstdcxx" = no; then AC_MSG_NOTICE([Only freestanding libraries will be built]) is_hosted=no hosted_define=0 enable_abi_check=no enable_libstdcxx_pch=no + if test "x$with_headers" = xno; then + freestanding_flags="-ffreestanding" + fi else is_hosted=yes hosted_define=1 @@ -2936,6 +2942,8 @@ AC_DEFUN([GLIBCXX_ENABLE_HOSTED], [ GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes) AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define, [Define to 1 if a full hosted library is built, or 0 if freestanding.]) + FREESTANDING_FLAGS="$freestanding_flags" + AC_SUBST(FREESTANDING_FLAGS) ]) |