https://sourceware.org/bugzilla/show_bug.cgi?id=32816
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> --- (In reply to Aliaksey Kandratsenka from comment #2) > As noted above, I have tried --no-as-needed. And yes it kinda "works", but > it is not great. > > There several imperfections with --no-as-needed: > > *) automake stuff insists on having only -lfoobar (and maybe -L) in > PROG_LIBADD variable. I.e. cannot wrap -Wl,--push-state,--as-needed > -Wl,--pop-state around my -lprofiler thing. I can and currently do this in > LDFLAGS but this mentions -lprofiler "too early" in libprofiler is static > library. I.e. LDFLAGS are passed early in linking command and LIBADD is > appended (which kinda makes sense in general). > > *) --as-needed is insufficient for the static library case > > *) I am not 100% sold on the wisdom of distros defaulting to --as-needed, > but they do. And me asking users of my library to disable it is not perfect. > > My current workaround is to do both > > AM_LDFLAGS = -Wl,--push-state,--no-as-needed \ > $(cpuprofiler_LIBS) \ > -Wl,--pop-state -Wl,-uProfilerStart > > > and > > trigram_index_LDADD = $(tcmalloc_LIBS) $(cpuprofiler_LIBS) > > So kinda mentioning -lprofiler twice, once for ".so" case via --no-as-needed > and once for the ".a" case via -Wl,-u and -lprofiler at the end of linking > command line. > > So ideally, we'd have --undefined flag equally working across shared and > static libraries and have everything nice and logical. Please provide a small testcase, including Makefile.am, to show the issue. -- You are receiving this mail because: You are on the CC list for the bug.