From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by sourceware.org (Postfix) with ESMTPS id 8D4A5385042A; Thu, 20 Oct 2022 15:52:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8D4A5385042A 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 smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (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-102.mailbox.org (Postfix) with ESMTPS id 4MtXCw2k59z9sYd; Thu, 20 Oct 2022 17:52:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aarsen.me; s=MBO0001; t=1666281132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=D65Ep4QxBDubpjgtRuV7mtwLyHsQRWQ6OwfpVPav0kw=; b=DEaCPF6BpEvjg6qtVSK25cU6xisZNR83op+CJTXkgmaGPmW6+3DirQzWeYjR6azwkJy/WS yKnGY4eqSpOlMCb1NUB2H1nsh16BfOuSfaGQ/C1Ips8hkSyniSv+IYgntx0B7vs40RGvl1 YtbwdJRfggVoRFGijGK4fgmTQigALH221L1QeA872hseQXQVzmJhEx0HEzdZkMyxwRXsEb 8viQb5L/wW2T5gSMSh5OY0Ta2luJMyLszP5B+TQWNERpfkptBYQkNinErgBxE69F4PMfZX VEwge+i1ReBZh3Bdu+k8gQ/l/UXncG0d/x5FDHky16aYOrBc+bVmZeE1O4QqTg== From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, =?UTF-8?q?Arsen=20Arsenovi=C4=87?= Subject: [PATCH] libstdc++: Enable building libstdc++.{a,so} when !HOSTED Date: Thu, 20 Oct 2022 17:49:50 +0200 Message-Id: <20221020154948.2511787-1-arsen@aarsen.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.5 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: This enables us to provide symbols for placeholders and numeric limits, and allows users to mess about with linker flags less. 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 that contains only library facilities available in freestanding (i.e. placeholders 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 implement. 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 = src doc po testsuite python + hosted_source = doc po testsuite python endif ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE. -SUBDIRS = include libsupc++ $(hosted_source) +SUBDIRS = include libsupc++ src $(hosted_source) ACLOCAL_AMFLAGS = -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 = \ ${cxx0x_compat_sources} \ ${ldbl_alt128_compat_sources} +if GLIBCXX_HOSTED libstdc___la_SOURCES = $(cxx98_sources) $(cxx11_sources) +else +# When freestanding, there's currently no compatibility to preserve. Should +# that change, any compatibility sources can be added here. +libstdc___la_SOURCES = +endif libstdc___la_LIBADD = \ $(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 = endif +sources_freestanding = \ + limits.cc \ + placeholders.cc + sources = \ chrono.cc \ codecvt.cc \ @@ -66,9 +70,7 @@ sources = \ 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 = $(sources) $(inst_sources) +if !GLIBCXX_HOSTED +libc__11convenience_la_SOURCES = $(sources_freestanding) +else +libc__11convenience_la_SOURCES = \ + $(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 = \ vpath % $(top_srcdir)/src/c++17 +if GLIBCXX_HOSTED libc__17convenience_la_SOURCES = $(sources) $(inst_sources) +else +libc__17convenience_la_SOURCES = +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 = vpath % $(top_srcdir)/src/c++20 +if GLIBCXX_HOSTED libc__20convenience_la_SOURCES = $(sources) $(inst_sources) +else +libc__20convenience_la_SOURCES = +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 = \ vpath % $(top_srcdir)/src/c++98 +if GLIBCXX_HOSTED libc__98convenience_la_SOURCES = $(sources) +else +libc__98convenience_la_SOURCES = +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