https://sourceware.org/bugzilla/show_bug.cgi?id=31904
Bug ID: 31904 Summary: libdep.so plugin does not register search path in bfd linker Product: binutils Version: 2.42 Status: UNCONFIRMED Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: me at harmenstoppels dot nl Target Milestone: --- I've created two static libraries `f/libf.a` and `g/libg.a`. The first registers a dependency on the second: `-L/path/to/g -lg` using the following command: ar crl '-L/path/to/g -lg' f/libf.a f/f.o Then I link my main program again libf using `-Lf -lf` and expect that the linker locates and links libg.a too. This fails for the default linker ld.bfd from binutils 2.36 to latest. It succeeds with the gold linker. Here is a self-contained minimal example as Makefile: > LDFLAGS := -Wl,--plugin,/usr/lib/x86_64-linux-gnu/bfd-plugins/libdep.so > > .PHONY: all clean > > all: exe > > f/f.o: > mkdir -p f > printf 'extern int g(); int f(){ return g(); }' | $(CC) -c -xc - -o $@ > > f/libf.a: f/f.o g/libg.a > $(AR) crl '-L$(CURDIR)/g -lg' $@ $< > > g/g.o: > mkdir -p g > printf 'int g(){ return 4; }' | $(CC) -c -xc - -o $@ > > g/libg.a: g/g.o > $(AR) cr $@ $< > > exe: f/libf.a > printf 'extern int f(); int main() { return f(); }' | $(CC) $(LDFLAGS) > -xc - -o $@ -Lf -lf > > clean: > rm -f exe f/f.o f/libf.a g/g.o g/libg.a Run make and it outputs > mkdir -p f > printf 'extern int g(); int f(){ return g(); }' | cc -c -xc - -o f/f.o > mkdir -p g > printf 'int g(){ return 4; }' | cc -c -xc - -o g/g.o > ar cr g/libg.a g/g.o > ar crl '-L/tmp/tmp.iR9g9xEukO/g -lg' f/libf.a f/f.o > printf 'extern int f(); int main() { return f(); }' | cc > -Wl,--plugin,/usr/lib/x86_64-linux-gnu/bfd-plugins/libdep.so -xc - -o exe -Lf > -lf > got deps for library f/libf.a: -L/tmp/tmp.iR9g9xEukO/g -lg > /usr/bin/ld: f/libf.a(f.o): in function `f': > <stdin>:(.text+0xe): undefined reference to `g' > collect2: error: ld returned 1 exit status > make: *** [Makefile:22: exe] Error 1 So, it fails to register `-L/tmp/tmp.iR9g9xEukO/g` as a link dir. -- You are receiving this mail because: You are on the CC list for the bug.