[build2] Fix build on older x86 and arm CPUs

Boris Kolpackov boris at codesynthesis.com
Fri Dec 22 13:45:10 UTC 2017


Norbert Lange <nolange79 at gmail.com> writes:

> I tried crosscompiling the debian package, it will error out because
> the (lowest denominator) CPU does not have built-in instructions for
> atomics.
>
> You can solve this generally by linking with '-latomic
> -Wl,--as-needed'. libatomic has fallback implemenations, and
> --as-needed will remove the dependency to the library if its unused.

I did a bit of reading on this and it appears that libatomic provides
locked implementations of the atomic operations. build2 uses atomics
pretty heavily which makes me wonder if such a build will be even
usable on these older CPUs?

I think if we really need to support these legacy CPUs (which I am
not sure about; cross-compiling seems like a much better option),
then perhaps the right way to do this would be to disable parallelism
and get rid of atomics. One way to do it without uglyfying the code
too much would be to provide no-op/serial implementation of the
interface provided by libatomic. Apparently someone has already
thought along these lines[1].

What do you think?

[1] http://www.openwall.com/lists/musl/2015/07/23/5

Boris



More information about the users mailing list