From patchwork Tue Apr 16 03:36:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1923961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=Ozg+EBd5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VJV8p4wyWz1yYB for ; Tue, 16 Apr 2024 13:37:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1840B3849AFA for ; Tue, 16 Apr 2024 03:37:11 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by sourceware.org (Postfix) with ESMTPS id 05DFE3858CDB for ; Tue, 16 Apr 2024 03:36:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 05DFE3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 05DFE3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::32 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713238612; cv=none; b=rD4ubMiH2dnR3cd3NCTG8dQDj1oAoL7jHi+GybGHyu8zicjzad8M0q7FyBHyhQ2zNmM/w+kguX0Bw1mAE3w/5OIj7jtq99IOHMp43Zm5YQ31pvymhGu8Uh9nA3uj84EX9WcgDeTjLfSF6GvK0hnA5XqjULfIJ5sAd4IA6OeJiYM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713238612; c=relaxed/simple; bh=rxyx/RgHcv43QPdpEiwok9WYMv3ymh97QGWH5ML06So=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UUmGfNyIFURH64Nl5TkyZz/o16LaQ7psKKLRgngssQ3qoLGhfgQIEAJ4eMYEXkdsTWDzfXeiwAd2oLnMP2W6xt2smiUh4n5BtwheY6XriQGnMHfyehUq2CCVWFgOLYltd+/nVW3AwroSlKNbPArEY13dfyCxdvgJoNjtRhr7pcY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-22fa7e4b0beso2557572fac.1 for ; Mon, 15 Apr 2024 20:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1713238607; x=1713843407; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=2wwzUyQfAh/nnA5WygziG/PiN55hDsxTq3Tbe1dHaQw=; b=Ozg+EBd5tQQV8vJkviIuYGQkCDXW6o5UqoBwELWWkMaeXqEDXf4cZl71AlHN6jVcbY Xrks5javFXRuPLi8ADjt06yV7YEf9rH+w6HcxIdXftJ6DpmiO1YxpkLq7Fn5koY01kYg tivyoU+1h0DSDo8pnaVnkBC06u6KkpJFFbOHCqOZgWvekqemMR3xfN7Ntr3vY2xmaj1i s//kmYIBxMCyaJPAI3OROzfgg6hJWsGUAzNONUYK091vLtecZHMCC2FefMmQ4sf4kF+u pxCbH/gfE2DBSL7iEpp5FPsVheqj+3npkGc0Om0NhPzLZwdmQhNosQfmxkB2dSJMb8ME 7tvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713238607; x=1713843407; h=mime-version:user-agent:message-id:date:organization:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2wwzUyQfAh/nnA5WygziG/PiN55hDsxTq3Tbe1dHaQw=; b=vrUTPwMr5b6X46r1gJ4qgubNTznTzP/XJuUNkhilQMEEl4Pmr0gXOReIEVSA4bUrfy KaFZYFwCgjoQkjOzgQ0qKSZBoED31NuzAPlHLv82FWVZSuv0ayVR/8gAoyqrnZ9Odrt5 UR12/2l4PocYJxa2+YfvrgkGH9omNrlCxZsgAb6ncpuYJODObFeF6qWaqyHmhRD+HGOk LXmjD4sYHZimL/pkyQWznPS8odKzJwUxM4xVvXNuPGQbA1S0Y/6S6cKFAJesq38O2DBC giTn3dJjnLFb6es8nCW8Es72GF+pSuHknuAk3wOb1/IoyNdTQKFakprTYFWGDIR0r5m5 igqQ== X-Gm-Message-State: AOJu0YymSGuC3gIkl+LvmTmF1+hE2W2xyx7STuD8PmIX9IA02Lm4fqbs ZRhc8YJkFZvIZsRy+ajB4okywQmo0CFuhVm5+6LkdAaaPw5snH/VNu/e/AYX43Wll9D9oa9F1A9 RIw== X-Google-Smtp-Source: AGHT+IFm++bxh7SJLhQa8G8zbh4vh/NDMs1Va/MtXuuk/oxBETJnp96dZ0T0A+d35cq8ciGtm0vYpA== X-Received: by 2002:a05:6870:23a3:b0:22e:d452:ea15 with SMTP id e35-20020a05687023a300b0022ed452ea15mr15003922oap.31.1713238607321; Mon, 15 Apr 2024 20:36:47 -0700 (PDT) Received: from free.home ([2804:7f1:218b:5e2:c43b:e0c4:71a:241b]) by smtp.gmail.com with ESMTPSA id bn10-20020a056a00324a00b006eade394613sm7996038pfb.198.2024.04.15.20.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 20:36:46 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 43G3aX4B2387806 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 16 Apr 2024 00:36:33 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] [libstdc++] introduce --disable-compat-libstdcxx-abi Organization: Free thinker, does not speak for AdaCore Date: Tue, 16 Apr 2024 00:36:33 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_QUOTING autolearn=unavailable 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org A number of libstdc++ tests that implicitly instantiate __to_chars_i 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. Regstrapped on x86_64-linux-gnu. Also tested with gcc-13 on arm-, aarch64-, x86- and x86_64-vxworks7r2. Ok to install? PS: for an alternate path to avoid this problem, see also https://sourceware.org/pipermail/binutils/2024-April/133602.html https://sourceware.org/pipermail/binutils/2024-April/133410.html 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. --- libstdc++-v3/acinclude.m4 | 26 ++++++++++++++ libstdc++-v3/configure | 49 ++++++++++++++++++++++----- libstdc++-v3/doc/html/manual/configure.html | 2 + 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 51a08bcc8b1d0..4ef5d5e98c2be 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]) + AC_ARG_ENABLE([compat-libstdcxx-abi], + AC_HELP_STRING([--disable-compat-libstdcxx-abi], + [Disable backward-compatibility 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]);; + 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 21abaeb077881..8066397b58c2e 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 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 + Disable backward-compatibility 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 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" >&5 +$as_echo_n "checking for --disable-compat-libstdcxx-abi... " >&6; } + # Check whether --enable-compat-libstdcxx-abi was given. +if test "${enable_compat_libstdcxx_abi+set}" = set; then : + enableval=$enable_compat_libstdcxx_abi; 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" "$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 346b5d345cd1b..8636b2360d9f0 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 clock_gettime function. +

--disable-compat-libstdcxx-abi

Disables + backward-compatibility ABI symbols.

--enable-libstdcxx-debug

Build separate debug libraries in addition to what is normally built. By default, the debug libraries are compiled with CXXFLAGS='-g3 -O0 -fno-inline'