Closed ibara closed 2 years ago
I don't think -Bdynamic is the way to create shared libraries. My /usr/bin/ld resolves to LLD 7.7.1, and supports -shared, like GNU linker. Are you sure it doesn't work; which linker is installed on your system?
I tried to clean up this somewhat, and ended up with only a change for static. Having logic around valid uses of -pie/-nopie etc is not necessary IMO. With this, 'make test-linker' works on both my Linux and OpenBSD install. It has a test for -shared, but not -static (yet).
Let me know if there is some scenario that still does not work for you.
This PR organizes linker flags correctly for all permutations of -static/-shared, -pie/-nopie on OpenBSD. I didn't touch the Linux side of things because I don't know what should be correct there, but Linux will need some changes to cope.
At least on OpenBSD, you can't send -static and -shared directly to the linker; it expects -Bdynamic and -Bstatic (at least, I followed what clang does in this regard). I avoided sending -pie and -nopie directly as well in the (admittedly strange) edge case where someone tries to use -pie and -nopie in the same invocation.