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 8B9893898C69 for ; Tue, 15 Nov 2022 15:58:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8B9893898C69 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668527901; 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=oUvsmnHchLOn+T851nOCLYEfykMIZ8RSU4LX0TB9cLs=; b=WQqijupZt34qjoAZK6IPjKwzK8dNfZA+pjY4lumDG0lH8XQ9ogA0bucJ0ri9/g5fGwNs0J uxrINh5IfX4e7/4tG+/q/LiV9LGW4QwZsT4BOoceYif2ITFeoJgbUh7xsdC7LZ3f5cqOai YYgVQ0kTftwqXpaJYcnK7Qu0ZYRGSM0= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-358-l7g3hVWiNqGWLjAqVMaR4A-1; Tue, 15 Nov 2022 10:58:20 -0500 X-MC-Unique: l7g3hVWiNqGWLjAqVMaR4A-1 Received: by mail-ed1-f70.google.com with SMTP id dz9-20020a0564021d4900b0045d9a3aded4so10452155edb.22 for ; Tue, 15 Nov 2022 07:58:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oUvsmnHchLOn+T851nOCLYEfykMIZ8RSU4LX0TB9cLs=; b=CsabDfgNRh2B6Jf12MTntma2Vyx7t3zwRKU4X2IY2Xk9KEWdYMnxnUIwbRW7MAppT+ rlPUd5EMg67PS3Xf/sNADi2JPtAMNwRCLtZHe+rqY1kpxx8gs9/3ASOm/ocVHj7MfTlx FZqQWz1EWOVAWcxdokSKz/UHTh/jSIzrCVzKabsmrNoXpFoD4zNF1csFidgptl7lpGqT c7R5xQ7SoZ7HWM0m1Elq9GYvkyXs6daQuGCeOP4cWg3mL7A4tsCKjoLWDaaxkIPQS11+ Nf+19sH3CwLRSSfikQ5ixd7aBxWnbZWDaYab4uKOrPDya/OWx9yn7/BH84jY8KvUMIvL aJOg== X-Gm-Message-State: ANoB5pnfKorlX8IzWN8do/ldUplMVbeBk4wbXWM7bvBH5j/BNRps1WU0 T+5Ei2yat4sNxCD2CLiAju64OeME/Xv8qt8kIlW93KUivcQmXRJFvClU5MLhcvQNX4K6K4FPnz9 tVsdeWNl2X0Msy4/kszxexivm7nM5VcU= X-Received: by 2002:a17:906:1ed0:b0:78d:9e77:1f8c with SMTP id m16-20020a1709061ed000b0078d9e771f8cmr14297535ejj.236.1668527898901; Tue, 15 Nov 2022 07:58:18 -0800 (PST) X-Google-Smtp-Source: AA0mqf6PPguwGg9tev8GDVUAiRCJogYps7Muu/WxL7jqAvHvwSz5cvEqjjKq3pqqRhRsSskbZrI4Wby/vrP2akcel+U= X-Received: by 2002:a17:906:1ed0:b0:78d:9e77:1f8c with SMTP id m16-20020a1709061ed000b0078d9e771f8cmr14297521ejj.236.1668527898608; Tue, 15 Nov 2022 07:58:18 -0800 (PST) MIME-Version: 1.0 References: <20221020154948.2511787-1-arsen@aarsen.me> In-Reply-To: <20221020154948.2511787-1-arsen@aarsen.me> From: Jonathan Wakely Date: Tue, 15 Nov 2022 15:58:07 +0000 Message-ID: Subject: Re: [PATCH] libstdc++: Enable building libstdc++.{a,so} when !HOSTED To: =?UTF-8?Q?Arsen_Arsenovi=C4=87?= Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: On Thu, 20 Oct 2022 at 16:53, Arsen Arsenovi=C4=87 via Libstdc++ wrote: > > This enables us to provide symbols for placeholders and numeric limits, I'm not convinced this is worth doing. The placeholders and the numeric_limits members are all inline variables for C++17 and later, and C++17 is the compiler's default mode. The placeholders aren't even required to exist for freestanding prior to C++23. For the numeric_limits definitions, I suppose it is a problem that users can't take their address in freestanding today unless they compile as C++17. > and allows users to mess about with linker flags less. i.e. they don't have to use -nostdlib and/or link with gcc -lsupc++, but can just use g++? That seems more compelling than providing definitions of the placeholders and limits members. > > libstdc++-v3/ChangeLog: > > * Makefile.am [!_GLIBCXX_HOSTED]: Enable src/ subdirectory. > * Makefile.in: Regenerate. > * src/Makefile.am [!_GLIBCXX_HOSTED]: Omit compatibility files. > There's no history to be compatible with. > * src/c++11/Makefile.am [!_GLIBCXX_HOSTED]: Omit hosted-only > source files from the build. > * src/c++17/Makefile.am [!_GLIBCXX_HOSTED]: Likewise. > * src/c++20/Makefile.am [!_GLIBCXX_HOSTED]: Likewise. > * src/c++98/Makefile.am [!_GLIBCXX_HOSTED]: Likewise. > * 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. > --- > Afternoon, > > With these changes, when we aren't hosted, we get a libstdc++ library tha= t > contains only library facilities available in freestanding (i.e. placehol= ders > and limits.cc). This is, AFAICT, the only code in libstdc++.{a,so} that = can > (and should) be available in freestanding. > > As an implementation note, this could be a little bit faster (at > build/configure time), though not necessarily nicer, by having > src/Makefile.am not try to build convenience libraries for versions of > C++ that provide nothing. I opted not to do this since it'd make > src/Makefile.am even more complex, and make future changes harder to impl= ement. > libstdc++ also isn't that slow to build, anyway. > > Tested on i686-elf. > > Have a good day! > > libstdc++-v3/Makefile.am | 4 ++-- > libstdc++-v3/Makefile.in | 4 ++-- > libstdc++-v3/src/Makefile.am | 6 +++++ > libstdc++-v3/src/Makefile.in | 8 +++++-- > libstdc++-v3/src/c++11/Makefile.am | 16 ++++++++++--- > libstdc++-v3/src/c++11/Makefile.in | 37 +++++++++++++++++++----------- > libstdc++-v3/src/c++17/Makefile.am | 4 ++++ > libstdc++-v3/src/c++17/Makefile.in | 6 +++-- > libstdc++-v3/src/c++20/Makefile.am | 4 ++++ > libstdc++-v3/src/c++20/Makefile.in | 6 +++-- > libstdc++-v3/src/c++98/Makefile.am | 4 ++++ > libstdc++-v3/src/c++98/Makefile.in | 6 +++-- > 12 files changed, 77 insertions(+), 28 deletions(-) > > diff --git a/libstdc++-v3/Makefile.am b/libstdc++-v3/Makefile.am > index 0d147ad3ffe..d7f2b6e76a5 100644 > --- a/libstdc++-v3/Makefile.am > +++ b/libstdc++-v3/Makefile.am > @@ -24,11 +24,11 @@ include $(top_srcdir)/fragment.am > > if GLIBCXX_HOSTED > ## Note that python must come after src. > - hosted_source =3D src doc po testsuite python > + hosted_source =3D doc po testsuite python > endif > > ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE. > -SUBDIRS =3D include libsupc++ $(hosted_source) > +SUBDIRS =3D include libsupc++ src $(hosted_source) > > ACLOCAL_AMFLAGS =3D -I . -I .. -I ../config > > diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am > index b83c222d51d..4eb78e76297 100644 > --- a/libstdc++-v3/src/Makefile.am > +++ b/libstdc++-v3/src/Makefile.am > @@ -121,7 +121,13 @@ cxx11_sources =3D \ > ${cxx0x_compat_sources} \ > ${ldbl_alt128_compat_sources} > > +if GLIBCXX_HOSTED > libstdc___la_SOURCES =3D $(cxx98_sources) $(cxx11_sources) > +else > +# When freestanding, there's currently no compatibility to preserve. Sh= ould > +# that change, any compatibility sources can be added here. > +libstdc___la_SOURCES =3D > +endif > > libstdc___la_LIBADD =3D \ > $(GLIBCXX_LIBS) \ > diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/= Makefile.am > index ecd46aafc01..72f05100c98 100644 > --- a/libstdc++-v3/src/c++11/Makefile.am > +++ b/libstdc++-v3/src/c++11/Makefile.am > @@ -51,6 +51,10 @@ else > cxx11_abi_sources =3D > endif > > +sources_freestanding =3D \ > + limits.cc \ > + placeholders.cc > + > sources =3D \ > chrono.cc \ > codecvt.cc \ > @@ -66,9 +70,7 @@ sources =3D \ > hashtable_c++0x.cc \ > ios.cc \ > ios_errcat.cc \ > - limits.cc \ > mutex.cc \ > - placeholders.cc \ > random.cc \ > regex.cc \ > shared_ptr.cc \ > @@ -118,7 +120,15 @@ endif > > vpath % $(top_srcdir)/src/c++11 > > -libc__11convenience_la_SOURCES =3D $(sources) $(inst_sources) > +if !GLIBCXX_HOSTED > +libc__11convenience_la_SOURCES =3D $(sources_freestanding) > +else > +libc__11convenience_la_SOURCES =3D \ > + $(sources_freestanding) \ > + $(sources) \ > + $(inst_sources) > +endif > + > > # Use special rules for the hashtable.cc file so that all > # the generated template functions are also instantiated. > diff --git a/libstdc++-v3/src/c++17/Makefile.am b/libstdc++-v3/src/c++17/= Makefile.am > index 3d53f652fac..72095f5b087 100644 > --- a/libstdc++-v3/src/c++17/Makefile.am > +++ b/libstdc++-v3/src/c++17/Makefile.am > @@ -60,7 +60,11 @@ sources =3D \ > > vpath % $(top_srcdir)/src/c++17 > > +if GLIBCXX_HOSTED > libc__17convenience_la_SOURCES =3D $(sources) $(inst_sources) > +else > +libc__17convenience_la_SOURCES =3D > +endif > > if GLIBCXX_LDBL_ALT128_COMPAT > floating_from_chars.lo: floating_from_chars.cc > diff --git a/libstdc++-v3/src/c++20/Makefile.am b/libstdc++-v3/src/c++20/= Makefile.am > index d4c1e26e40e..5c937f7e804 100644 > --- a/libstdc++-v3/src/c++20/Makefile.am > +++ b/libstdc++-v3/src/c++20/Makefile.am > @@ -40,7 +40,11 @@ sources =3D > > vpath % $(top_srcdir)/src/c++20 > > +if GLIBCXX_HOSTED > libc__20convenience_la_SOURCES =3D $(sources) $(inst_sources) > +else > +libc__20convenience_la_SOURCES =3D > +endif > > # AM_CXXFLAGS needs to be in each subdirectory so that it can be > # modified in a per-library or per-sub-library way. Need to manually > diff --git a/libstdc++-v3/src/c++98/Makefile.am b/libstdc++-v3/src/c++98/= Makefile.am > index b96588bd95c..f7134d80027 100644 > --- a/libstdc++-v3/src/c++98/Makefile.am > +++ b/libstdc++-v3/src/c++98/Makefile.am > @@ -148,7 +148,11 @@ sources =3D \ > > vpath % $(top_srcdir)/src/c++98 > > +if GLIBCXX_HOSTED > libc__98convenience_la_SOURCES =3D $(sources) > +else > +libc__98convenience_la_SOURCES =3D > +endif > > # Use special rules to compile with -fimplicit-templates. > c++locale.lo: c++locale.cc > # Use special rules for the deprecated source files so that they find > -- > 2.38.1 >