public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ld: build libdep plugin only when shared library support is enabled
@ 2023-04-13  7:49 Clément Chigot
  2023-04-13  8:54 ` Howard Chu
  0 siblings, 1 reply; 3+ messages in thread
From: Clément Chigot @ 2023-04-13  7:49 UTC (permalink / raw)
  To: binutils; +Cc: Clément Chigot

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


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

* Re: [PATCH] ld: build libdep plugin only when shared library support is enabled
  2023-04-13  7:49 [PATCH] ld: build libdep plugin only when shared library support is enabled Clément Chigot
@ 2023-04-13  8:54 ` Howard Chu
  2023-04-13  8:59   ` Clément Chigot
  0 siblings, 1 reply; 3+ messages in thread
From: Howard Chu @ 2023-04-13  8:54 UTC (permalink / raw)
  To: Clément Chigot, binutils

Clément Chigot via Binutils wrote:
> 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.

At this point I think it'd be better to integrate the libdep functionality directly into ld, as suggested before:

https://sourceware.org/pipermail/binutils/2023-February/126155.html

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/

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

* Re: [PATCH] ld: build libdep plugin only when shared library support is enabled
  2023-04-13  8:54 ` Howard Chu
@ 2023-04-13  8:59   ` Clément Chigot
  0 siblings, 0 replies; 3+ messages in thread
From: Clément Chigot @ 2023-04-13  8:59 UTC (permalink / raw)
  To: Howard Chu; +Cc: binutils

On Thu, Apr 13, 2023 at 10:54 AM Howard Chu <hyc@symas.com> wrote:
>
> Clément Chigot via Binutils wrote:
> > 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.
>
> At this point I think it'd be better to integrate the libdep functionality directly into ld, as suggested before:
>
> https://sourceware.org/pipermail/binutils/2023-February/126155.html

Oh yeah clearly, I've missed this patch.
Thanks for pointing it out. I'll post an upvote on it.

Clément

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

end of thread, other threads:[~2023-04-13  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-13  7:49 [PATCH] ld: build libdep plugin only when shared library support is enabled Clément Chigot
2023-04-13  8:54 ` Howard Chu
2023-04-13  8:59   ` Clément Chigot

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