Re: Mising Patch #2 from the RISC-V v3 Submission
On Feb 15 2018, Palmer Dabbeltwrote: > On Mon, 12 Feb 2018 15:18:39 PST (-0800), Jim Wilson wrote: >> On 02/12/2018 03:23 AM, Andreas Schwab wrote: >>> On Feb 06 2017, Palmer Dabbelt 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? >> >> I don't know the history here, but I do know that the most common atomic >> related bug report we get is for people using pthread, so we were >> probably thinking about that when this was written. > > IIRC that's why it's done this way. This is a problem for gcc itself, libstdc++-v3 is failing its atomic checks due to this (PR84568): checking for atomic builtins for bool... no checking for atomic builtins for short... no checking for atomic builtins for int... yes checking for atomic builtins for long long... yes configure: WARNING: No native atomic operations are provided for this platform. configure: WARNING: They will be faked using a mutex. configure: WARNING: Performance of certain classes will degrade as a result. But it wouldn't have found -latomic anyway. There needs to be a generic solution for that. Another affected package is mariadb. Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Re: Mising Patch #2 from the RISC-V v3 Submission
On Feb 15 2018, Palmer Dabbeltwrote: > On Mon, 12 Feb 2018 15:18:39 PST (-0800), Jim Wilson wrote: >> On 02/12/2018 03:23 AM, Andreas Schwab wrote: >>> On Feb 06 2017, Palmer Dabbelt 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? >> >> I don't know the history here, but I do know that the most common atomic >> related bug report we get is for people using pthread, so we were >> probably thinking about that when this was written. > > IIRC that's why it's done this way. There needs to be some standard way to find -latomic during build, a couple of libgo configure tests fail because they do not find it. Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Re: Mising Patch #2 from the RISC-V v3 Submission
On Mon, 12 Feb 2018 15:18:39 PST (-0800), Jim Wilson wrote: On 02/12/2018 03:23 AM, Andreas Schwab wrote: On Feb 06 2017, Palmer Dabbeltwrote: +/* 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? I don't know the history here, but I do know that the most common atomic related bug report we get is for people using pthread, so we were probably thinking about that when this was written. IIRC that's why it's done this way.
Re: Mising Patch #2 from the RISC-V v3 Submission
On Feb 12 2018, Jim Wilsonwrote: > I don't know the history here, but I do know that the most common atomic > related bug report we get is for people using pthread, so we were probably > thinking about that when this was written. But handling the two cases > differently does look like a bug. I'm OK with a patch that makes it > unconditional in the LD_AS_NEEDED_OPTION case also. Particularly if you > have a good case to justify it. This is needed by jemalloc, which needs -latomic because it uses byte atomics. It does not know about -pthread. https://build.opensuse.org/package/show/openSUSE:Factory:RISCV/jemalloc I haven't yet seen other packages that need this though. Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Re: Mising Patch #2 from the RISC-V v3 Submission
On 02/12/2018 03:23 AM, Andreas Schwab wrote: On Feb 06 2017, Palmer Dabbeltwrote: +/* 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? I don't know the history here, but I do know that the most common atomic related bug report we get is for people using pthread, so we were probably thinking about that when this was written. But handling the two cases differently does look like a bug. I'm OK with a patch that makes it unconditional in the LD_AS_NEEDED_OPTION case also. Particularly if you have a good case to justify it. Joseph's pointer to bug 81358 looks like a possible good justification for this. Do you want to write a patch, or do you want me to write it? I'm not worried about the case where --as-needed is missing. Linker --as-needed support was added to GNU ld in 2004, and RISC-V support was added to GCC in 2017, so there should be no riscv target that is missing the linker --as-needed support. Jim
Re: Mising Patch #2 from the RISC-V v3 Submission
On Mon, 12 Feb 2018, Andreas Schwab wrote: > On Feb 06 2017, Palmer Dabbeltwrote: > > > +/* 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 jos...@codesourcery.com
Re: Mising Patch #2 from the RISC-V v3 Submission
On Feb 06 2017, Palmer Dabbeltwrote: > +/* 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? Andreas. -- Andreas Schwab, SUSE Labs, sch...@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."
Re: Mising Patch #2 from the RISC-V v3 Submission
I think this got dropped because it was over the size limit for this mailing list. I've attached a gzip'd version of the patch instead. On Mon, Feb 6, 2017 at 10:53 AM, Palmer Dabbeltwrote: > Sorry, I'm not sure what happened to this patch. Here's patch #2 from of v3 > submission which I seem to have dropped. > 0001-RISC-V-Port-gcc.patch.gz Description: GNU Zip compressed data