cmake: Add --no-undefined linker option #1559

pull hebasto wants to merge 2 commits into bitcoin-core:master from hebasto:240628-undef changing 5 files +57 −1
  1. hebasto commented at 12:30 pm on June 28, 2024: member

    This PR adds the --no-undefined option to a linker, which supports it.

    From the GNU ld docs:

    --no-undefined

    Report unresolved symbol references from regular object files. This is done even if the linker is creating a non-symbolic shared library.

    Closes #1556.

    Looking for Concept (N)ACKs. Once ACKed, I’ll add the same functionality to the Autotools-based build system.

  2. theuni commented at 3:15 pm on June 28, 2024: contributor

    Concept ACK.

    I think we might be after -Wl,--no-allow-shlib-undefined, though, and only for the shared lib as that’s what we care about. --no-undefined is strictly stronger, I guess, and should also be satisfied for the binaries. So I suppose the sledgehammer approach here should be fine.

  3. hebasto commented at 3:20 pm on June 28, 2024: member

    I think we might be after -Wl,--no-allow-shlib-undefined

    From my experience, it fails to catch an issue like one I demoed in #1556.

  4. real-or-random commented at 3:33 pm on June 28, 2024: contributor

    I think we might be after -Wl,--no-allow-shlib-undefined, though, and only for the shared lib as that’s what we care about. --no-undefined is strictly stronger, I guess, and should also be satisfied for the binaries. So I suppose the sledgehammer approach here should be fine.

    If https://stackoverflow.com/a/2356407 is right, then --no-undefined covers objects created by the linker and --no-allow-shlib-undefined covers shared libraries consumed by the linker.

  5. real-or-random added the label build on Jun 28, 2024
  6. real-or-random commented at 3:34 pm on June 28, 2024: contributor
    Concept ACK
  7. hebasto commented at 5:07 pm on June 28, 2024: member

    Looking for Concept (N)ACKs. Once ACKed, I’ll add the same functionality to the Autotools-based build system.

    Added a commit for the Autotools-based build system.

  8. in CMakeLists.txt:273 in 6a19dc02ec outdated
    268@@ -269,6 +269,11 @@ if(SECP256K1_BUILD_CTIME_TESTS)
    269   unset(msan_enabled)
    270 endif()
    271 
    272+if(NOT SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS)
    273+  include(TryAppendLnkerFlags)
    


    real-or-random commented at 5:07 pm on June 28, 2024:
    0  include(TryAppendLinkerFlags)
    

    and rename the file?


    hebasto commented at 5:16 pm on June 28, 2024:
    Sure! Sorry for a typo :)

    hebasto commented at 5:18 pm on June 28, 2024:
    Thanks! Done.
  9. cmake: Add `--no-undefined` linker option 1abae91b77
  10. hebasto force-pushed on Jun 28, 2024
  11. hebasto marked this as a draft on Jun 28, 2024
  12. real-or-random commented at 10:14 am on June 29, 2024: contributor
    I think we need to make add an exception to this if external default callbacks are enabled because the entire point of this option is that the user provides the callbacks at link time.
  13. autotools: Add `--no-undefined` linker option bc995fd001
  14. hebasto force-pushed on Jun 29, 2024
  15. hebasto commented at 10:27 am on June 29, 2024: member

    I think we need to make add an exception to this if external default callbacks are enabled because the entire point of this option is that the user provides the callbacks at link time.

    Right. I did it in CMake, but forgot about it in Autotools. Fixed.

  16. hebasto marked this as ready for review on Jun 29, 2024
  17. hebasto marked this as a draft on Jun 29, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 18:15 UTC

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