public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] [libstdc++] introduce --disable-compat-libstdcxx-abi
@ 2024-04-19 13:15 Alexandre Oliva
  0 siblings, 0 replies; only message in thread
From: Alexandre Oliva @ 2024-04-19 13:15 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:4c6efa350d11a66674d85046cc7b7cbc69f6dbe1

commit 4c6efa350d11a66674d85046cc7b7cbc69f6dbe1
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Tue Apr 16 01:26:20 2024 -0300

    [libstdc++] introduce --disable-compat-libstdcxx-abi
    
    A number of libstdc++ tests that implicitly instantiate
    __to_chars_i<unsigned int128_t> and also link floating_to_chars.o in
    fail on vxworks kernel mode.  The platform doesn't support undefweak
    symbols (the kernel module loader fails to load modules containing
    them), and because creating such modules doesn't involve final
    linking, only -r linking.  The vague-linkage weak defs with abi-v2
    mangling that get discarded from floating_to_chars.o because the same
    comdat section is present in the main executable.  But since the
    alternate mangling is not defined in the main executable, the weak
    definition decays to a weak undefined symbol in the partially-linked
    kernel module, and then the kernel module loader barfs.
    
    Since our vxworks toolchains have little use for the compat ABI
    symbols, I thought we could work around this problem by getting rid of
    them.  Absent a configure option to control that, I added one.
    
    
    for  libstdc++-v3/ChangeLog
    
            * acinclude.m4 (GLIBCXX_EXPORT_FLAGS): Split -Wabi=2...
            (GLIBCXX_ENABLE_WABI): ... here.  Control it with newly added
            --disable-compat-libstdcxx-abi.
            * configure: Rebuilt.
            * doc/html/manual/configure.html: Document it.

Diff:
---
 libstdc++-v3/acinclude.m4                   | 26 ++++++++++++++-
 libstdc++-v3/configure                      | 49 +++++++++++++++++++++++------
 libstdc++-v3/doc/html/manual/configure.html |  4 ++-
 libstdc++-v3/doc/xml/manual/configure.xml   |  4 +++
 4 files changed, 72 insertions(+), 11 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 51a08bcc8b1..2dd5aa2af89 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -707,10 +707,34 @@ AC_DEFUN([GLIBCXX_EXPORT_FLAGS], [
   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
   AC_SUBST(OPTIMIZE_CXXFLAGS)
 
-  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2"
+  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual"
   AC_SUBST(WARN_FLAGS)
+
+  GLIBCXX_ENABLE_WABI
 ])
 
+dnl
+dnl Enable -Wabi=2 if not overridden by --disable-compat-libstdcxx-abi.
+dnl
+AC_DEFUN([GLIBCXX_ENABLE_WABI], [
+  # Default.
+  WARN_FLAGS_WABI=\ -Wabi=2
+  AC_MSG_CHECKING([for --disable-compat-libstdcxx-abi-mangling])
+  AC_ARG_ENABLE([compat-libstdcxx-abi-mangling],
+    AC_HELP_STRING([--disable-compat-libstdcxx-abi-mangling],
+		   [Disable backward-compatibility mangling ABI symbols]),
+    [case "$enableval" in
+      yes) AC_MSG_RESULT(enabled$WARN_FLAGS_WABI) ;;
+      no)  WARN_FLAGS_WABI=
+	   AC_MSG_RESULT(disabled) ;;
+      *)   AC_MSG_RESULT(unsupported)
+	   AC_MSG_ERROR([Unsupported argument to enable/disable compat libstdc++ abi mangling]);;
+     esac], [
+	   AC_MSG_RESULT(defaulting to enabled$WARN_FLAGS_WABI)
+     ])
+
+  WARN_FLAGS="$WARN_FLAGS$WARN_FLAGS_WABI"
+])
 
 dnl
 dnl All installation directory information is determined here.
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 21abaeb0778..af03d5f96f4 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -973,6 +973,7 @@ enable_cet
 with_gxx_include_dir
 enable_version_specific_runtime_libs
 with_toolexeclibdir
+enable_compat_libstdcxx_abi_mangling
 with_gcc_major_version_only
 '
       ac_precious_vars='build_alias
@@ -1689,6 +1690,8 @@ Optional Features:
   --enable-version-specific-runtime-libs
                           Specify that runtime libraries should be installed
                           in a compiler-specific directory
+  --disable-compat-libstdcxx-abi-mangling
+                          Disable backward-compatibility mangling ABI symbols
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -12280,7 +12283,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12283 "configure"
+#line 12286 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12386,7 +12389,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 12389 "configure"
+#line 12392 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16182,7 +16185,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
   # Fake what AC_TRY_COMPILE does.
 
     cat > conftest.$ac_ext << EOF
-#line 16185 "configure"
+#line 16188 "configure"
 int main()
 {
   typedef bool atomic_type;
@@ -16217,7 +16220,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16220 "configure"
+#line 16223 "configure"
 int main()
 {
   typedef short atomic_type;
@@ -16252,7 +16255,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16255 "configure"
+#line 16258 "configure"
 int main()
 {
   // NB: _Atomic_word not necessarily int.
@@ -16288,7 +16291,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
     rm -f conftest*
 
     cat > conftest.$ac_ext << EOF
-#line 16291 "configure"
+#line 16294 "configure"
 int main()
 {
   typedef long long atomic_type;
@@ -16444,7 +16447,7 @@ $as_echo "mutex" >&6; }
   # unnecessary for this test.
 
     cat > conftest.$ac_ext << EOF
-#line 16447 "configure"
+#line 16450 "configure"
 int main()
 {
   _Decimal32 d1;
@@ -16486,7 +16489,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
   # unnecessary for this test.
 
   cat > conftest.$ac_ext << EOF
-#line 16489 "configure"
+#line 16492 "configure"
 template<typename T1, typename T2>
   struct same
   { typedef T2 type; };
@@ -55671,7 +55674,35 @@ $as_echo "$gxx_include_dir" >&6; }
   # OPTIMIZE_CXXFLAGS = -O3 -fstrict-aliasing -fvtable-gc
 
 
-  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2"
+  WARN_FLAGS="-Wall -Wextra -Wwrite-strings -Wcast-qual"
+
+
+
+  # Default.
+  WARN_FLAGS_WABI=\ -Wabi=2
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --disable-compat-libstdcxx-abi-mangling" >&5
+$as_echo_n "checking for --disable-compat-libstdcxx-abi-mangling... " >&6; }
+  # Check whether --enable-compat-libstdcxx-abi-mangling was given.
+if test "${enable_compat_libstdcxx_abi_mangling+set}" = set; then :
+  enableval=$enable_compat_libstdcxx_abi_mangling; case "$enableval" in
+      yes) { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled$WARN_FLAGS_WABI" >&5
+$as_echo "enabled$WARN_FLAGS_WABI" >&6; } ;;
+      no)  WARN_FLAGS_WABI=
+	   { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; } ;;
+      *)   { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; }
+	   as_fn_error $? "Unsupported argument to enable/disable compat libstdc++ abi mangling" "$LINENO" 5;;
+     esac
+else
+
+	   { $as_echo "$as_me:${as_lineno-$LINENO}: result: defaulting to enabled$WARN_FLAGS_WABI" >&5
+$as_echo "defaulting to enabled$WARN_FLAGS_WABI" >&6; }
+
+fi
+
+
+  WARN_FLAGS="$WARN_FLAGS$WARN_FLAGS_WABI"
 
 
 
diff --git a/libstdc++-v3/doc/html/manual/configure.html b/libstdc++-v3/doc/html/manual/configure.html
index 346b5d345cd..cdbaaabcb2a 100644
--- a/libstdc++-v3/doc/html/manual/configure.html
+++ b/libstdc++-v3/doc/html/manual/configure.html
@@ -108,6 +108,8 @@
 	then the [time.clock] implementation will use a system call to access
 	the realtime and monotonic clocks, which is significantly slower than
 	the C library's <code class="function">clock_gettime</code> function.
+    </p></dd><dt><span class="term"><code class="code">--disable-compat-libstdcxx-abi-mangling</code></span></dt><dd><p>Disables
+    backward-compatibility mangling ABI symbols.
     </p></dd><dt><span class="term"><code class="code">--enable-libstdcxx-debug</code></span></dt><dd><p>Build separate debug libraries in addition to what is normally built.
 	By default, the debug libraries are compiled with
 	<code class="code"> CXXFLAGS='-g3 -O0 -fno-inline'</code>
@@ -308,4 +310,4 @@
       smaller library, so is suitable for systems that will never need to
       query the time zone database.
       This does not change the library ABI.
-    </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="setup.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="setup.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="make.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 2. Setup </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Make</td></tr></table></div></body></html>
\ No newline at end of file
+    </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="setup.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="setup.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="make.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 2. Setup </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Make</td></tr></table></div></body></html>
diff --git a/libstdc++-v3/doc/xml/manual/configure.xml b/libstdc++-v3/doc/xml/manual/configure.xml
index 0a477ab85e5..ab46db490dc 100644
--- a/libstdc++-v3/doc/xml/manual/configure.xml
+++ b/libstdc++-v3/doc/xml/manual/configure.xml
@@ -189,6 +189,10 @@
     </para>
  </listitem></varlistentry>
 
+ <varlistentry><term><code>--disable-compat-libstdcxx-abi-mangling</code></term>
+ <listitem><para>Disables backward-compatibility mangling ABI symbols.</para>
+ </listitem></varlistentry>
+
  <varlistentry><term><code>--enable-libstdcxx-debug</code></term>
  <listitem><para>Build separate debug libraries in addition to what is normally built.
 	By default, the debug libraries are compiled with

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-19 13:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-19 13:15 [gcc(refs/users/aoliva/heads/testme)] [libstdc++] introduce --disable-compat-libstdcxx-abi Alexandre Oliva

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).