From patchwork Tue Mar 22 09:17:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1608061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=AGge9tS6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KN5WY6ZlRz9s0B for ; Tue, 22 Mar 2022 20:18:32 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7DF2C393BC39 for ; Tue, 22 Mar 2022 09:18:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DF2C393BC39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1647940707; bh=EZB1mZo0rMmmbvmiLXhlBRA39pApZzf8YEBep35p9JQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=AGge9tS6VRnpLjIQHW5Q1fpy5vzMY18UfCPxBrChRlEDiTW0oTSVXiWq0TwUum+VK unRBw/+vh2vAnyazUGITXZr8wf+fDm0UOIOY6yO2yuviA16yMymJ+q4l0HtStmRIDE 5m4BKTNgyxzREWWUFYcdyimVkbV/Yh6qitqZJiSg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E046B3857823 for ; Tue, 22 Mar 2022 09:17:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E046B3857823 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-CHlm7EIoM5eraxLImkpcHA-1; Tue, 22 Mar 2022 05:17:32 -0400 X-MC-Unique: CHlm7EIoM5eraxLImkpcHA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EDCB21C05EAF; Tue, 22 Mar 2022 09:17:31 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEB84401E3A; Tue, 22 Mar 2022 09:17:31 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 22M9HRLG3266863 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 22 Mar 2022 10:17:28 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 22M9HPkJ3266862; Tue, 22 Mar 2022 10:17:25 +0100 Date: Tue, 22 Mar 2022 10:17:25 +0100 To: Richard Biener , Jeff Law , Jan Hubicka , Rainer Orth Subject: [PATCH] lto-plugin: Use GNU ld or Solaris ld version script in preference to -export-symbols-regex [PR102426] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! As reported, libtool -export-symbols-regex doesn't work on Solaris when using GNU ld instead of Sun ld, libtool just always assumes Sun ld. As I'm unsure what is the maintainance status of libtool right now, this patch solves it on the lto-plugin side instead, tests at configure time similar way how libssp and other target libraries test for symbol versioning (except omitting the symbol version because we just want one GLOBAL symbol and rest of them LOCAL), and will use the current way of -export-symbols-regex onload as fallback when this doesn't work. Bootstrapped/regtested on x86_64-linux and i686-linux (where it now uses the GNU versioning instead of -export-symbols-regex onload). Ok for trunk if it works for Rainer too (both Sun and GNU ld)? 2022-03-22 Jakub Jelinek PR lto/102426 * configure.ac (LTO_PLUGIN_USE_SYMVER, LTO_PLUGIN_USE_SYMVER_GNU, LTO_PLUGIN_USE_SYMVER_SUN): New test for symbol versioning support. * Makefile.am (version_arg, version_dep): Set conditionally based on LTO_PLUGIN_USE_SYMVER*. (liblto_plugin_la_LDFLAGS): Use $(version_arg) instead of -export-symbols-regex onload. (liblto_plugin_la_DEPENDENCIES): Depend on $(version_dep). * lto-plugin.map: New file. * configure: Regenerated. * Makefile.in: Regenerated. Jakub --- lto-plugin/configure.ac.jj 2020-04-27 09:11:14.431603556 +0200 +++ lto-plugin/configure.ac 2022-03-21 14:42:05.913555824 +0100 @@ -50,6 +50,43 @@ AC_SUBST(real_target_noncanonical) # Determine what GCC version number to use in filesystem paths. GCC_BASE_VER +AC_MSG_CHECKING([whether symbol versioning is supported]) +lto_plugin_use_symver=no +if test x$gcc_no_link = xyes; then + # If we cannot link, we cannot build shared libraries, so do not use + # symbol versioning. + lto_plugin_use_symver=no +else + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map" + cat > conftest.map < conftest.map <&5 +$as_echo_n "checking whether symbol versioning is supported... " >&6; } +lto_plugin_use_symver=no +if test x$gcc_no_link = xyes; then + # If we cannot link, we cannot build shared libraries, so do not use + # symbol versioning. + lto_plugin_use_symver=no +else + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -fPIC -shared -Wl,--version-script,./conftest.map" + cat > conftest.map <conftest.$ac_ext +/* end confdefs.h. */ +int foo; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lto_plugin_use_symver=gnu +else + lto_plugin_use_symver=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test x$lto_plugin_use_symver = xno; then + case "$target_os" in + solaris2*) + LDFLAGS="$save_LDFLAGS" + LDFLAGS="$LDFLAGS -fPIC -shared -Wl,-M,./conftest.map" + # Sun ld cannot handle wildcards and treats all entries as undefined. + cat > conftest.map <conftest.$ac_ext +/* end confdefs.h. */ +int foo; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + lto_plugin_use_symver=sun +else + lto_plugin_use_symver=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + ;; + esac + fi + LDFLAGS="$save_LDFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lto_plugin_use_symver" >&5 +$as_echo "$lto_plugin_use_symver" >&6; } + if test "x$lto_plugin_use_symver" != xno; then + LTO_PLUGIN_USE_SYMVER_TRUE= + LTO_PLUGIN_USE_SYMVER_FALSE='#' +else + LTO_PLUGIN_USE_SYMVER_TRUE='#' + LTO_PLUGIN_USE_SYMVER_FALSE= +fi + + if test "x$lto_plugin_use_symver" = xgnu; then + LTO_PLUGIN_USE_SYMVER_GNU_TRUE= + LTO_PLUGIN_USE_SYMVER_GNU_FALSE='#' +else + LTO_PLUGIN_USE_SYMVER_GNU_TRUE='#' + LTO_PLUGIN_USE_SYMVER_GNU_FALSE= +fi + + if test "x$lto_plugin_use_symver" = xsun; then + LTO_PLUGIN_USE_SYMVER_SUN_TRUE= + LTO_PLUGIN_USE_SYMVER_SUN_FALSE='#' +else + LTO_PLUGIN_USE_SYMVER_SUN_TRUE='#' + LTO_PLUGIN_USE_SYMVER_SUN_FALSE= +fi + + case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 @@ -11981,7 +12081,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11984 "configure" +#line 12084 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12087,7 +12187,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12090 "configure" +#line 12190 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12558,6 +12658,18 @@ if test -z "${am__fastdepCC_TRUE}" && te as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${LTO_PLUGIN_USE_SYMVER_TRUE}" && test -z "${LTO_PLUGIN_USE_SYMVER_FALSE}"; then + as_fn_error $? "conditional \"LTO_PLUGIN_USE_SYMVER\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${LTO_PLUGIN_USE_SYMVER_GNU_TRUE}" && test -z "${LTO_PLUGIN_USE_SYMVER_GNU_FALSE}"; then + as_fn_error $? "conditional \"LTO_PLUGIN_USE_SYMVER_GNU\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${LTO_PLUGIN_USE_SYMVER_SUN_TRUE}" && test -z "${LTO_PLUGIN_USE_SYMVER_SUN_FALSE}"; then + as_fn_error $? "conditional \"LTO_PLUGIN_USE_SYMVER_SUN\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 --- lto-plugin/Makefile.in.jj 2022-01-11 23:20:34.347532985 +0100 +++ lto-plugin/Makefile.in 2022-03-21 14:53:49.644853595 +0100 @@ -323,7 +323,6 @@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ real_target_noncanonical = @real_target_noncanonical@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -349,11 +348,16 @@ AM_LDFLAGS = @ac_lto_plugin_ldflags@ AM_LIBTOOLFLAGS = --tag=disable-static libexecsub_LTLIBRARIES = liblto_plugin.la in_gcc_libs = $(foreach lib, $(libexecsub_LTLIBRARIES), $(gcc_build_dir)/$(lib)) +@LTO_PLUGIN_USE_SYMVER_FALSE@version_arg = -export-symbols-regex onload +@LTO_PLUGIN_USE_SYMVER_GNU_TRUE@@LTO_PLUGIN_USE_SYMVER_TRUE@version_arg = -Wl,--version-script=$(srcdir)/lto-plugin.map +@LTO_PLUGIN_USE_SYMVER_SUN_TRUE@@LTO_PLUGIN_USE_SYMVER_TRUE@version_arg = -Wl,-M,$(srcdir)/lto-plugin.map +@LTO_PLUGIN_USE_SYMVER_FALSE@version_dep = +@LTO_PLUGIN_USE_SYMVER_TRUE@version_dep = $(srcdir)/lto-plugin.map liblto_plugin_la_SOURCES = lto-plugin.c # Note that we intentionally override the bindir supplied by ACX_LT_HOST_FLAGS. liblto_plugin_la_LDFLAGS = $(AM_LDFLAGS) $(lt_host_flags) -module \ - -avoid-version -bindir $(libexecsubdir) -export-symbols-regex \ - onload $(if $(wildcard $(libiberty_noasan)),, $(if $(wildcard \ + -avoid-version -bindir $(libexecsubdir) $(version_arg) $(if \ + $(wildcard $(libiberty_noasan)),, $(if $(wildcard \ $(libiberty_pic)),,-Wc,$(libiberty))) # Can be simplified when libiberty becomes a normal convenience library. libiberty = $(with_libiberty)/libiberty.a @@ -366,7 +370,8 @@ liblto_plugin_la_LIBADD = \ liblto_plugin_la_DEPENDENCIES = \ $(if $(wildcard $(libiberty_noasan)),$(libiberty_noasan), \ - $(if $(wildcard $(libiberty_pic)),$(libiberty_pic),)) + $(if $(wildcard $(libiberty_pic)),$(libiberty_pic),)) \ + $(version_dep) LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) liblto_plugin_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \