public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Enable building libstdc++.{a,so} when !HOSTED
@ 2022-10-20 15:49 Arsen Arsenović
  2022-11-14 18:34 ` Ping: " Arsen Arsenović
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arsen Arsenović @ 2022-10-20 15:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Arsen Arsenović

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-06 14:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-20 15:49 [PATCH] libstdc++: Enable building libstdc++.{a,so} when !HOSTED Arsen Arsenović
2022-11-14 18:34 ` Ping: " Arsen Arsenović
2022-11-15 15:58 ` Jonathan Wakely
2022-11-15 18:03   ` Arsen Arsenović
2023-02-06 14:24 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).