--as-needed and undefined non-weak symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm wondering if I've stumbled upon a bug in ld's --as-needed or
something I was not aware of, here's an example, foo.c:

extern void gtk_main();
int main() {
    gtk_main();
}

Now, libgtk (as of FC5) contains lots of undefined gdk_* symbols, so
trying "gcc -lgtk foo.c" on the above fails as expected, and "gcc -lgdk
-lgtk foo.c" succeeds, again as expected.  However, to my surprise, "gcc
-Wl,--as-needed -lgdk -lgtk foo.c" fails:

/tmp/ccImoouo.o: In function `main':
foo.c:(.text+0xa): undefined reference to `gtk_main'
collect2: ld returned 1 exit status

Is this how --as-needed should behave?  Ie. the linker does not appear
to notice that linking with libgdk is actually needed in this case and
drops it -> boom.

gtk+ is just an easy-to-find example in Fedora, and in its case,
eliminating the non-weak symbols in libgtk by linking it with libgdk
would most likely be the correct way around the problem, ditto with the
majority of other undefined-non-weak-symbols-in-shared-libs cases out
there.  But don't pay attention to those details, I'm curious whether
the above demonstrates a problem in --as-needed or not.

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux