From patchwork Thu Oct 20 15:49:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Arsen_Arsenovi=C4=87?= X-Patchwork-Id: 6265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp185704wrr; Thu, 20 Oct 2022 08:53:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5O4EHiOPIfkZVNseFk1p8ZC9v84lM1sBnBuid5KrDx5eUXVYDKK04vtza2tQPvHIukqmG+ X-Received: by 2002:a05:6402:35cc:b0:45d:4a39:2a43 with SMTP id z12-20020a05640235cc00b0045d4a392a43mr12934744edc.304.1666281191407; Thu, 20 Oct 2022 08:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666281191; cv=none; d=google.com; s=arc-20160816; b=QX319zmHw2+hX/rRNqWyIjgBHhORyb79UAO8oxo0tUvQVkNs71yR722OJxFg9VSOdB 1j/jOOXkoxt+X+qckubP/2fynn0gjroxvNkqExdZKF/8EA6pBOjDG4a8jsj4I5UpMscO Zq2b+OLdawz0Z8JZXFMN62CbLe3NZiOneGCuy/b/qyF2sYqD2rW7cI19jP3dOTloaj8z cyU8LuT1baaTtEMoTbiPOcA/+fIiO1U+8SNv0+zC1jRRCyX1T9dD+FoqvzJIw7fbr8HB 5xX0F34UIQlCOIXGeWfeDF3fiL07gFUZ70NsBz3J6ngNVF6taPivyRzkeA+seCEwnhQ4 0SEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=D65Ep4QxBDubpjgtRuV7mtwLyHsQRWQ6OwfpVPav0kw=; b=mSNI+sNs7cwQg4eEBB8uzV0fRR1m0KgodDFGIAZnoAhPKonRpEbYrE/HHAnR9Z0Any XegpdlkIWeF6mAqDvMNNa4hCxU6QvlX9/2R/9OljVjYNj7pta4AXRUZ04mYhxY/Kyhe1 +NfJMo9bXaHWHaMRfqVw18N/YCltpBB7CuiZ2TiDjjE49K+kV6564xigrksDGWRpmfz1 QzgM2A2PxW7UeUwuhXAgT4HPlIEVTt8rd3UGU02DmcmStXKtOvJ5Y6cDgHtCmIo/L9mW ZAcwzGlpDa8yMD+riDElwOv2Pz2iniHMff517OkulOO+MmroZX4H4FUYYNajM6bsPnft KkFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kJzSk6h1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id sd23-20020a1709076e1700b007414886601asi15917569ejc.25.2022.10.20.08.53.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 08:53:11 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kJzSk6h1; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3967384F023 for ; Thu, 20 Oct 2022 15:53:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3967384F023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666281181; bh=D65Ep4QxBDubpjgtRuV7mtwLyHsQRWQ6OwfpVPav0kw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=kJzSk6h1vTgC4+tufonjWFCyT49kA9A1eXmjw+BDdFGKlmMyANJMuYLTPBqRudaus X3wI5a0Pnh7IWO+smSMEjK1Gu8qED0xQStcSaYdUXNIVjg97uKcZe0+mRYP2JwXdhs zTO7j+E7kaqzgz2a5OLq9KhKgcgMo5tDlgm7cizo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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) To: gcc-patches@gcc.gnu.org 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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Arsen_Arsenovi=C4=87_via_Gcc-patches?= From: =?utf-8?q?Arsen_Arsenovi=C4=87?= Reply-To: =?utf-8?q?Arsen_Arsenovi=C4=87?= Cc: libstdc++@gcc.gnu.org Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747222466249973401?= X-GMAIL-MSGID: =?utf-8?q?1747222466249973401?= 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(-) # Use special rules for the deprecated source files so that they find 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