Mising Patch #2 from the RISC-V v3 Submission

Joseph Myers joseph@codesourcery.com
Mon Feb 12 21:53:00 GMT 2018


On Mon, 12 Feb 2018, Andreas Schwab wrote:

> On Feb 06 2017, Palmer Dabbelt <palmer@dabbelt.com> wrote:
> 
> > +/* Because RISC-V only has word-sized atomics, it requries libatomic where
> > +   others do not.  So link libatomic by default, as needed.  */
> > +#undef LIB_SPEC
> > +#ifdef LD_AS_NEEDED_OPTION
> > +#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC \
> > +  " %{pthread:" LD_AS_NEEDED_OPTION " -latomic " LD_NO_AS_NEEDED_OPTION "}"
> > +#else
> > +#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC " -latomic "
> > +#endif
> 
> Why is -latomic added only with -pthread if --as-needed is supported,
> but unconditionally if not?  Wouldn't it make sense to add it
> unconditionally in both cases?

Really -latomic should be used with --as-needed (provided -nostdlib isn't 
used, which gcc.c specs deal with) - generally, on all architectures (this 
is bug 81358).  Using it without --as-needed is riskier (introducing 
spurious dependencies in binaries that don't actually use it).  I don't 
think there should be any architecture dependency here.

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list