On Sat, Sep 19, 2015 at 10:48:01AM -0700, Philip Guenther wrote:
> On Sat, Sep 19, 2015 at 10:29 AM, Sebastien Marie <[email protected]> wrote:
> > On Sat, Sep 19, 2015 at 10:07:04AM -0700, Philip Guenther wrote:
> >> On Sat, Sep 19, 2015 at 9:50 AM, Sebastien Marie <[email protected]> 
> >> wrote:
> >> > While working on building llvm 3.7.0 on openbsd (-current amd64 and
> >> > i386), I encounter a problem when linking a shared library, while
> >> > -Wl,-z,defs was passed on command-line.
> >> >
> >> > I build a minimal reproductible testcase:
> >> >
> >> > $ touch test.c
> >> > $ c++ -Wl,-z,defs -shared -o libtest.so test.c
> >> > /usr/lib/crtbeginS.o: In function `atexit':
> >> > (.text+0x18f): undefined reference to `__cxa_atexit'
> >> > collect2: ld returned 1 exit status
> >>
> >> If you want to use -zdefs when building a shared library, you MUST
> >> include in the link the libraries that it depends on, including libc.
> >
> > First, I encountered this problem while building clang. The linking of
> > libclang.so.3.7 use -Wl,-z,defs.
> >
> > For building with it, it would require -lc for several symbols, and the
> > last symbols will be `environ'. If I add `crt0.o' for `environ', it will
> > require `__init' and `main'.
> 
> Congrats, you found a bug in how things are spread between crt0 and
> libc!  The result is that you can't use -zdefs when building a shared
> library.  The fix is to not have libc depend on crt0, not to disable
> that functionality in ld.

ok, it makes sens.
thanks !
-- 
Sebastien Marie

Reply via email to