From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C14F83899401 for ; Mon, 10 Jan 2022 12:25:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C14F83899401 Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-662-fhfquTQfNw6igny_CKzDAA-1; Mon, 10 Jan 2022 07:25:42 -0500 X-MC-Unique: fhfquTQfNw6igny_CKzDAA-1 Received: by mail-yb1-f197.google.com with SMTP id n2-20020a255902000000b0060f9d75eafeso26962016ybb.1 for ; Mon, 10 Jan 2022 04:25:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rXvM28o4VA9aR6vFa6RdPnA+5LBSz3FhajfeqJy4HI0=; b=7uQPTm5gm3YwAhimukGv3jyY2iJpL05cr2cbRD1QdqDYHmhprv/3eH4e8EQojhLkzn wssvf8tBRJDidBtstme2ZXcKVvSqo1rjydeLipLaqiw/uEgufVXRkB3vCKUgHeYFDqHa jR9G34zdlnHKiwH6KCdqSuudHJSZHXzz0ZSrKKZIcp1siQnbX3ryFjED6pSTMTj27S7j Q9B0e274xRbVONunbGoWfC2V5oyz/TcwCfEnr9nKIXguHuJfUQo1fY/GczTcvz2v1IKo vcFPThJe2vdxHArBdWoIDyRtbmgS9mL1C3pDzxfcbX45aVHK1qleQd494lYlViBMweM6 EQ5g== X-Gm-Message-State: AOAM530QecAKM+ZZy+oYlwdtKCMFfcgtYOTfRdfR/MR09e3Ft/prICH6 7KiTOaobuaO97CN1mQzeqvXVvZeT5JrYfR9/KQmiSEONrBdJuDRrcIp6Los+mWsu4zPR6IPurYu uxf/t9cKuVNNveLHfjvTuR5PX7Mn4CRE= X-Received: by 2002:a25:4dd4:: with SMTP id a203mr63227584ybb.580.1641817539437; Mon, 10 Jan 2022 04:25:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQlNBClgRB0zUAmp+BYqixKoQKZp5f1wdox2keJu+2rPAJcVxXOpV/alRo4r2swjDddLxa86k869ZeH1fBSwk= X-Received: by 2002:a25:4dd4:: with SMTP id a203mr63227559ybb.580.1641817539215; Mon, 10 Jan 2022 04:25:39 -0800 (PST) MIME-Version: 1.0 References: <20220107134459.2024774-1-jwakely@redhat.com> In-Reply-To: <20220107134459.2024774-1-jwakely@redhat.com> From: Jonathan Wakely Date: Mon, 10 Jan 2022 12:25:28 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Fix and simplify freestanding configuration [PR103866] To: Jonathan Wakely Cc: "libstdc++" , gcc Patches X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2022 12:25:47 -0000 On Fri, 7 Jan 2022 at 13:46, Jonathan Wakely via Libstdc++ < libstdc++@gcc.gnu.org> wrote: > Tested powerpc64le-linux and by building a mips-none-elf cross with > --disable-hosted-libstdcxx --without-headers (which fails currently). > > Any objections? > Pushed to trunk. > > 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 > available. Unlike most headers, which get a HAVE_FOO_H macro, > 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 types done by GCC_HEADER_STDINT try > to include 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 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 will use 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. > --- > libstdc++-v3/Makefile.in | 1 + > libstdc++-v3/acinclude.m4 | 8 ++++++ > libstdc++-v3/configure | 35 ++++++++++++++++++------- > libstdc++-v3/configure.ac | 10 +++++-- > libstdc++-v3/doc/Makefile.in | 1 + > libstdc++-v3/include/Makefile.in | 1 + > libstdc++-v3/libsupc++/Makefile.am | 2 +- > libstdc++-v3/libsupc++/Makefile.in | 3 ++- > libstdc++-v3/po/Makefile.in | 1 + > libstdc++-v3/python/Makefile.in | 1 + > libstdc++-v3/src/Makefile.in | 1 + > libstdc++-v3/src/c++11/Makefile.in | 1 + > libstdc++-v3/src/c++17/Makefile.in | 1 + > libstdc++-v3/src/c++20/Makefile.in | 1 + > libstdc++-v3/src/c++98/Makefile.in | 1 + > libstdc++-v3/src/filesystem/Makefile.in | 1 + > libstdc++-v3/testsuite/Makefile.in | 1 + > 17 files changed, 56 insertions(+), 14 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 ], > @@ -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) > ]) > > > diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac > index 5b3c92f4bd7..827d770f444 100644 > --- a/libstdc++-v3/configure.ac > +++ b/libstdc++-v3/configure.ac > @@ -90,7 +90,9 @@ AC_SYS_LARGEFILE > GLIBCXX_CONFIGURE > > # Libtool setup. > -if test "x${with_newlib}" != "xyes" && test "x${with_avrlibc}" != "xyes"; > then > +if test "x${with_newlib}" != "xyes" && > + test "x${with_avrlibc}" != "xyes" && > + test "x$with_headers" != "xno"; then > AC_LIBTOOL_DLOPEN > fi > AM_PROG_LIBTOOL > @@ -351,7 +353,7 @@ else > > AC_DEFINE(HAVE_ICONV) > AC_DEFINE(HAVE_MEMALIGN) > - else > + elif test "x$with_headers" != "xno"; then > GLIBCXX_CROSSCONFIG > fi > > @@ -390,7 +392,11 @@ GCC_CHECK_UNWIND_GETIPINFO > > GCC_LINUX_FUTEX([AC_DEFINE(HAVE_LINUX_FUTEX, 1, [Define if futex syscall > is available.])]) > > +if test "$is_hosted" = yes; then > +# TODO: remove this and change src/c++11/compatibility-atomic-c++0x.cc to > +# use instead of . > GCC_HEADER_STDINT(include/gstdint.h) > +fi > > GLIBCXX_ENABLE_SYMVERS([yes]) > AC_SUBST(libtool_VERSION) > diff --git a/libstdc++-v3/libsupc++/Makefile.am > b/libstdc++-v3/libsupc++/Makefile.am > index 2a69a1cf677..65b5c1a87fd 100644 > --- a/libstdc++-v3/libsupc++/Makefile.am > +++ b/libstdc++-v3/libsupc++/Makefile.am > @@ -139,7 +139,7 @@ atomicity.cc: ${atomicity_file} > # as the occasion call for it. > AM_CXXFLAGS = \ > $(glibcxx_lt_pic_flag) $(glibcxx_compiler_shared_flag) \ > - $(XTEMPLATE_FLAGS) \ > + $(XTEMPLATE_FLAGS) $(FREESTANDING_FLAGS) \ > $(WARN_CXXFLAGS) $(OPTIMIZE_CXXFLAGS) $(CONFIG_CXXFLAGS) > > AM_MAKEFLAGS = \ > >