Add configure check for -latomic #8563

pull ajtowns wants to merge 1 commits into bitcoin:master from ajtowns:autoconf-latomic changing 2 files +43 −0
  1. ajtowns commented at 11:22 AM on August 23, 2016: member

    Add a configure check to use libatomic for std::atomic operations if needed.

    Per https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_concurrency.html "Some uses of std::atomic also require linking to libatomic." This has been observed to be necessary when building with gcc on Debian's mips and mipsel architectures.

  2. Add configure check for -latomic 878faacd7b
  3. MarcoFalke added the label Build system on Aug 23, 2016
  4. MarcoFalke added the label Needs backport on Aug 23, 2016
  5. MarcoFalke added this to the milestone 0.13.1 on Aug 23, 2016
  6. laanwj assigned theuni on Aug 24, 2016
  7. sipa commented at 5:18 PM on August 26, 2016: member

    Concept ACK

  8. luke-jr commented at 3:58 AM on August 27, 2016: member

    Concept ACK, but I wonder if we should try to link with -latomic first, in case linking without it merely fails at runtime (or worse, works without providing the atomic guarantees).

  9. laanwj commented at 11:45 AM on August 30, 2016: member

    Hm, you have a point @luke-jr but I also like the approach of trying -latomic only when necessary. This will make sure that no spurious library is linked that happens to be called 'atomic' on completely unrelated platforms/compilers, and that the configure log clearly states why a certain library is linked.

    without it merely fails at runtime (or worse, works without providing the atomic guarantees).

    That would be really messed-up. Linking a library or not should not affect program behavior in itself (that's determined during compile time), and missing symbols give an error at link time. (Maybe something could be concocted with ELF weak symbols that gives this kind of behavior, even making it dependent on the link order, but bleh)

  10. luke-jr commented at 1:46 AM on August 31, 2016: member

    I agree, it would indeed be messed-up, but wasn't that almost exactly what happened in CVE-2012-1910?

  11. theuni commented at 3:24 AM on August 31, 2016: member

    Assuming we're only doing link tests, is an AC_SEARCH_LIBS not enough here?

  12. laanwj commented at 2:02 PM on August 31, 2016: member

    I agree, it would indeed be messed-up, but wasn't that almost exactly what happened in CVE-2012-1910?

    IIRC there the problem was linking the wrong library, not forgetting to link a library.

  13. laanwj commented at 5:52 AM on September 9, 2016: member

    Assuming we're only doing link tests, is an AC_SEARCH_LIBS not enough here?

    I think the problem is that it is unspecified which symbols are exported. The requirement is that the atomic library is linked when c++11 atomics are used. How these relate to ELF-level symbols is probably an implementation detail that may change over time.

  14. luke-jr commented at 6:16 AM on September 9, 2016: member

    main is always exported ;)

  15. laanwj commented at 6:20 AM on September 9, 2016: member

    I mean these symbols exported by atomic library:

    libbitcoin_server.a(libbitcoin_server_a-main.o): In function `std::__atomic_base<long long>::store(long long, std::memory_order)':
    /usr/include/c++/6/bits/atomic_base.h:374: undefined reference to `__atomic_store_8'
    libbitcoin_server.a(libbitcoin_server_a-main.o): In function `std::__atomic_base<long long>::load(std::memory_order) const':
    /usr/include/c++/6/bits/atomic_base.h:396: undefined reference to `__atomic_load_8'
    /usr/include/c++/6/bits/atomic_base.h:396: undefined reference to `__atomic_load_8'
    libbitcoin_server.a(libbitcoin_server_a-main.o): In function `std::__atomic_base<long long>::store(long
    ...
    

    Would be easy enough to check for one of them using AC_SEARCH_LIBS, but I think the test in this pull is fine and less dependent on implementation details.

  16. laanwj commented at 6:58 AM on September 9, 2016: member

    ACK 878faac, reproduced with a mipsel-unknown-linux-gnu toolchain (gcc 5.3.0) built with crosstool-ng. Without this patch it fails, with this patch it proceeds. Haven't tested the executable, but it's a clear step forward at least.

  17. laanwj merged this on Sep 9, 2016
  18. laanwj closed this on Sep 9, 2016

  19. laanwj referenced this in commit 7f8b677aeb on Sep 9, 2016
  20. luke-jr referenced this in commit 147003c73e on Sep 21, 2016
  21. luke-jr commented at 10:40 PM on September 21, 2016: member

    Ugh, this m4 code is GPL licensed at best... checking with upstream if we can get MIT license on it.

  22. ajtowns commented at 5:16 AM on September 22, 2016: member
  23. laanwj removed the label Needs backport on Sep 26, 2016
  24. laanwj commented at 2:09 PM on September 26, 2016: member

    This was backported in #8772, removing tag

  25. codablock referenced this in commit e2f2c7a4fa on Sep 19, 2017
  26. sickpig referenced this in commit d4b37e77e8 on Oct 18, 2017
  27. sickpig referenced this in commit 671dc97bc5 on Oct 19, 2017
  28. schinzelh referenced this in commit 0db98537be on Oct 23, 2017
  29. zkbot referenced this in commit 75604363cc on Dec 1, 2017
  30. zkbot referenced this in commit 6aef4033a7 on Dec 1, 2017
  31. zkbot referenced this in commit 83af270002 on Dec 15, 2017
  32. codablock referenced this in commit a5020b6a4b on Jan 9, 2018
  33. codablock referenced this in commit b90d7611ab on Jan 9, 2018
  34. kotodev referenced this in commit c8a979fc92 on Jan 25, 2018
  35. renium9 referenced this in commit 23640da445 on Feb 6, 2018
  36. MarcoFalke locked this on Sep 8, 2021

Milestone
0.13.1


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-26 09:16 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me