This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: notes on current atomics config and usage
> I see this point in a slightly different way. It all depends on whether
> the atomics (implemented in terms of underlying builtins) are part of
> the library, i.e., exported, or not.
>If they are part of the library,
> then the user code, irrespective of the -march, will call into the
> library and all will be fine.
>If, on the other hand, the atomics are
> inlined, then the issue is for our *headers* to recognize the actual
> -march (via __GCC_ATOMIC_BUILTINS, I can't see any other way...) and do
> the right thing.
Options are:
1) inline atomics only, no exports
2) don't inline any atomics, force link to exported
3) inline atomics only and have compatibility exports
The way I see it, every which way we get get into dicy situations.
Option 1:
a) configured for i686, user tries to use with -march="-i386". This
will blow up, regardless of __GCC_ATOMIC_BUILTINS, because of the
inlined builtins in the *.cc files compiled into libstdc++.a or libstdc+
+.so have instructions not on this arch. Thus, any linkage will fail.
b) configured for i386, user tries to use with -march="i686". This
will not blow up, but won't be optimal because all the library bits are
compiled without the advanced atomics. The user will only get the
builtins on header files.
Option 2:
a) configured for i686, user tries to use with -march="-i386". Blow up.
Possible work around would be to put just the atomics in a separate
library, which is dynamically selected based on the -march value in
use. This won't work for anything except for toy projects.
b) configured for i386, user tries to use with -march="i686". Won't get
benefit of atomics, -march is a no-op.
Option 3:
all the issues with Option 1.
Let's face it: i486+ and i386 are related, but separate arches. Same
for sparc families.
> Of course, I'm not considering *static* linking, which would give us
> troubles anyway, I think it *already* does if one builds a program on a
> machine using the atomics in config/cpu/i486 and then tries to use it on
> an i386...
Yep.
-benjamin