From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 577123858D32 for ; Thu, 13 Apr 2023 07:49:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 577123858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42b.google.com with SMTP id o29so2187409wro.0 for ; Thu, 13 Apr 2023 00:49:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1681372158; x=1683964158; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=piiT++XOilrxe39v0L3zoXK5DkHQWw7RxmuhOANPo7k=; b=R3yvPz4QchO3d8cio/QBOVdBXEC04f9D8bcL9XB20RCUE0VvQnGm7FczT8j+20AcNy Kl9TugZTULaATno/5NnsYti6ATW8Jx8dgib6i/8mni6bs7+Vq8ZJOugoBB9T69iudpm0 cMlQOqBshnOqiykNtmFqCLShaa6Ryq7urQ1ZRWyhjqGLG63MTcX+KMuVHf0juWRirre+ bX+oV9qg0TTYOvcTf4wMgagUpPgCrMJ6uWJetSZ2ZiCri3+EmCqcVCTHXuAbQUoDnUuV 8zvr5YpN1pBc4vc3Cd779p236aIK5P5lFEgRQ/WieZgnOk3yS2k0asoxxkEL3qQNDpKu hUnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681372158; x=1683964158; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=piiT++XOilrxe39v0L3zoXK5DkHQWw7RxmuhOANPo7k=; b=SxBIFmy0Z3F7Fp7zofcVWXMxrpdi1AdTdjXY4XdH5ibIrPW1SZyBGKA+hD9ACs6RX2 pGeBGdDhxDWn7bZq/FejtfRfSCrbtP55iFEqjKb25oN9QxdQ9hMMQ13WG4APgozatFvc Y3jsJXZ0lMDYDiCwEkUD/OrirNOHW66F1IFD+NUyotNcQhzCB718TQVEjqg5sK7j75J6 uTachi8Ed2NOxxU2blgG+2SHHgHvdNoh9BQyhIbKf3Gw0BrLaYVoKyJlE2KDmAFzIWv6 IyquX2zWC/iwKBWmclaAEX/x0iJWO7NHyhMItoDpCK6AKZm7sks4Oaga1Oevi/G/wGnA rRvQ== X-Gm-Message-State: AAQBX9cE6sKchVH3g1zx123kkcBEwevw4fU0GJdYTjRKVXTTP3967pz7 WHoJD1AVbkPVkf1UtX9z9pEaRu1bXKZME1oZpDg= X-Google-Smtp-Source: AKy350bSY0CfePZyFP620rhaakMI/GFAUZutP+936/TZPfvdUX5E/GltZYzA8c+yLX/pCw73cWVrdg== X-Received: by 2002:a5d:5290:0:b0:2cf:efc7:19ad with SMTP id c16-20020a5d5290000000b002cfefc719admr539877wrv.53.1681372157669; Thu, 13 Apr 2023 00:49:17 -0700 (PDT) Received: from chigot-Dell.home ([2a01:cb15:8123:8100:eb45:d879:c1f9:c8b]) by smtp.gmail.com with ESMTPSA id e32-20020a5d5960000000b002f02dbddc26sm662871wri.68.2023.04.13.00.49.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 00:49:17 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: binutils@sourceware.org Cc: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= Subject: [PATCH] ld: build libdep plugin only when shared library support is enabled Date: Thu, 13 Apr 2023 09:49:14 +0200 Message-Id: <20230413074914.354662-1-chigot@adacore.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Otherwise, libtool will create a static plugin which cannot be loaded. Even worse on Windows, it will create a .a file, resulting in a similar bug than PR 27113: some tools will try to open it and Windows will raise a popup error. --- ld/Makefile.am | 5 +++++ ld/Makefile.in | 19 +++++++++++-------- ld/configure | 19 +++++++++++++++++-- ld/configure.ac | 2 ++ 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/ld/Makefile.am b/ld/Makefile.am index 0e9bed88f65..cedacf01239 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -1029,6 +1029,7 @@ libldtestplug4_la_CFLAGS= -g -O2 libldtestplug4_la_LDFLAGS = -no-undefined -rpath /nowhere bfdplugindir = $(libdir)/bfd-plugins +if ENABLE_SHARED bfdplugin_LTLIBRARIES = libdep.la libdep_la_SOURCES = libdep_plugin.c libdep_la_LDFLAGS = -no-undefined -rpath /nowhere -module -avoid-version @@ -1036,6 +1037,9 @@ libdep_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ --tag=disable-static \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libdep_la_LDFLAGS) $(LDFLAGS) -o $@ +else +bfdplugin_LTLIBRARIES = +endif # DOCUMENTATION TARGETS # Manual configuration file; not usually attached to normal configuration, @@ -1111,6 +1115,7 @@ install-data-local: install-bfdpluginLTLIBRARIES for f in ldscripts/* ; do \ $(INSTALL_DATA) $$f $(DESTDIR)$(scriptdir)/$$f ; \ done + test -d $(DESTDIR)$(bfdplugindir) || $(MKDIR_P) $(DESTDIR)$(bfdplugindir) rm -f $(DESTDIR)$(bfdplugindir)/libdep.la rm -f $(DESTDIR)$(bfdplugindir)/libdep.dll.a diff --git a/ld/Makefile.in b/ld/Makefile.in index 15f88bf606d..855d6efc6f8 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -172,8 +172,9 @@ am__installdirs = "$(DESTDIR)$(bfdplugindir)" "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" LTLIBRARIES = $(bfdplugin_LTLIBRARIES) $(noinst_LTLIBRARIES) libdep_la_LIBADD = -am_libdep_la_OBJECTS = libdep_plugin.lo +@ENABLE_SHARED_TRUE@am_libdep_la_OBJECTS = libdep_plugin.lo libdep_la_OBJECTS = $(am_libdep_la_OBJECTS) +@ENABLE_SHARED_TRUE@am_libdep_la_rpath = -rpath $(bfdplugindir) libldtestplug_la_LIBADD = am_libldtestplug_la_OBJECTS = libldtestplug_la-testplug.lo libldtestplug_la_OBJECTS = $(am_libldtestplug_la_OBJECTS) @@ -1044,13 +1045,14 @@ libldtestplug4_la_SOURCES = testplug4.c libldtestplug4_la_CFLAGS = -g -O2 libldtestplug4_la_LDFLAGS = -no-undefined -rpath /nowhere bfdplugindir = $(libdir)/bfd-plugins -bfdplugin_LTLIBRARIES = libdep.la -libdep_la_SOURCES = libdep_plugin.c -libdep_la_LDFLAGS = -no-undefined -rpath /nowhere -module -avoid-version -libdep_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ - --tag=disable-static \ - $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(libdep_la_LDFLAGS) $(LDFLAGS) -o $@ +@ENABLE_SHARED_FALSE@bfdplugin_LTLIBRARIES = +@ENABLE_SHARED_TRUE@bfdplugin_LTLIBRARIES = libdep.la +@ENABLE_SHARED_TRUE@libdep_la_SOURCES = libdep_plugin.c +@ENABLE_SHARED_TRUE@libdep_la_LDFLAGS = -no-undefined -rpath /nowhere -module -avoid-version +@ENABLE_SHARED_TRUE@libdep_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ +@ENABLE_SHARED_TRUE@ --tag=disable-static \ +@ENABLE_SHARED_TRUE@ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ +@ENABLE_SHARED_TRUE@ $(libdep_la_LDFLAGS) $(LDFLAGS) -o $@ MAINTAINERCLEANFILES = configdoc.texi ld.1 ld.info @@ -2755,6 +2757,7 @@ install-data-local: install-bfdpluginLTLIBRARIES for f in ldscripts/* ; do \ $(INSTALL_DATA) $$f $(DESTDIR)$(scriptdir)/$$f ; \ done + test -d $(DESTDIR)$(bfdplugindir) || $(MKDIR_P) $(DESTDIR)$(bfdplugindir) rm -f $(DESTDIR)$(bfdplugindir)/libdep.la rm -f $(DESTDIR)$(bfdplugindir)/libdep.dll.a diststuff: info $(EXTRA_DIST) diff --git a/ld/configure b/ld/configure index 03b9e46f56d..607c7fce6b4 100755 --- a/ld/configure +++ b/ld/configure @@ -676,6 +676,8 @@ INCINTL LIBINTL_DEP LIBINTL USE_NLS +ENABLE_SHARED_FALSE +ENABLE_SHARED_TRUE WARN_WRITE_STRINGS NO_WERROR WARN_CFLAGS_FOR_BUILD @@ -11625,7 +11627,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11628 "configure" +#line 11630 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11731,7 +11733,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11734 "configure" +#line 11736 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16051,6 +16053,15 @@ if test -z "$host" ; then as_fn_error $? "Unrecognized host system type; please check config.sub." "$LINENO" 5 fi + if test "${enable_shared}" = yes; then + ENABLE_SHARED_TRUE= + ENABLE_SHARED_FALSE='#' +else + ENABLE_SHARED_TRUE='#' + ENABLE_SHARED_FALSE= +fi + + # host-specific stuff: ALL_LINGUAS="bg da de es fi fr ga id it ja pt_BR ru sr sv tr uk vi zh_CN zh_TW" @@ -17678,6 +17689,10 @@ if test -z "${ENABLE_LIBCTF_TRUE}" && test -z "${ENABLE_LIBCTF_FALSE}"; then as_fn_error $? "conditional \"ENABLE_LIBCTF\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_SHARED_TRUE}" && test -z "${ENABLE_SHARED_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_SHARED\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/ld/configure.ac b/ld/configure.ac index 77edac3258c..4c63fa56184 100644 --- a/ld/configure.ac +++ b/ld/configure.ac @@ -338,6 +338,8 @@ if test -z "$host" ; then AC_MSG_ERROR(Unrecognized host system type; please check config.sub.) fi +AM_CONDITIONAL(ENABLE_SHARED, test "${enable_shared}" = yes) + # host-specific stuff: ALL_LINGUAS="bg da de es fi fr ga id it ja pt_BR ru sr sv tr uk vi zh_CN zh_TW" -- 2.25.1