build: Set shared linker flags in toolchain file #31395

pull TheCharlatan wants to merge 1 commits into bitcoin:master from TheCharlatan:toolchain_set_shared_linker_flags changing 1 files +9 −0
  1. TheCharlatan commented at 10:34 am on November 30, 2024: contributor

    These are required when cross-compiling shared libraries such as the kernel library.

    This was discovered after attempting to cross-compile the kernel library and running into the following error:

    0[100%] Linking CXX shared library libbitcoinkernel.dylib
    1/usr/bin/ld: unrecognised emulation mode: llvm
    2Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386pep i386pe
    3clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    4gmake[3]: *** [src/kernel/CMakeFiles/bitcoinkernel.dir/build.make:1209: src/kernel/libbitcoinkernel.dylib] Error 1
    5gmake[2]: *** [CMakeFiles/Makefile2:1175: src/kernel/CMakeFiles/bitcoinkernel.dir/all] Error 2
    6gmake[1]: *** [CMakeFiles/Makefile2:1182: src/kernel/CMakeFiles/bitcoinkernel.dir/rule] Error 2
    7gmake: *** [Makefile:569: bitcoinkernel] Error 2
    
  2. build: Set shared linker flags in toolchain file
    These are required when cross-compiling shared libraries such as the
    kernel library.
    a8e04704f9
  3. DrahtBot commented at 10:34 am on November 30, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31395.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK hebasto, tdb3

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. DrahtBot added the label Build system on Nov 30, 2024
  5. hebasto approved
  6. hebasto commented at 9:25 am on December 1, 2024: member

    ACK a8e04704f930de168fdddbb1c040dd70fbbe8ff7, tested on Ubuntu 24.04:

    0$ make -C depends -j 16 HOST=arm64-apple-darwin NO_QT=1
    1$ cmake -B build --toolchain depends/arm64-apple-darwin/toolchain.cmake -DBUILD_SHARED_LIBS=ON -DBUILD_KERNEL_LIB=ON
    2$ cmake --build build -j 16 -t bitcoinkernel
    

    UPD. It seems to make sense to configure all CI jobs with -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_LIB=ON -DBUILD_SHARED_LIBS=ON.

  7. tdb3 approved
  8. tdb3 commented at 10:33 pm on December 1, 2024: contributor

    ACK a8e04704f930de168fdddbb1c040dd70fbbe8ff7

    On master, was able to reproduce a build error cross compiling for arm64-apple-darwin and x86_64-apple-darwin:

     0$ make -C depends HOST=arm64-apple-darwin -j11
     1$ cmake -B build -DBUILD_KERNEL_LIB=ON --toolchain depends/arm64-apple-darwin/toolchain.cmake
     2$ cmake --build build -j11
     3...
     4[ 38%] Linking CXX shared library libbitcoinkernel.dylib
     5/usr/bin/ld: unrecognised emulation mode: llvm
     6Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386pep i386pe
     7clang++: error: linker command failed with exit code 1 (use -v to see invocation)
     8gmake[2]: *** [src/kernel/CMakeFiles/bitcoinkernel.dir/build.make:1209: src/kernel/libbitcoinkernel.dylib] Error 1
     9gmake[1]: *** [CMakeFiles/Makefile2:1723: src/kernel/CMakeFiles/bitcoinkernel.dir/all] Error 2
    10gmake[1]: *** Waiting for unfinished jobs....
    11[ 38%] Linking CXX static library libbitcoin_common.a
    12[ 38%] Built target bitcoin_common
    13gmake: *** [Makefile:146: all] Error 2
    
     0$ make -C depends HOST=x86_64-apple-darwin -j11
     1$ cmake -B build -DBUILD_KERNEL_LIB=ON --toolchain depends/x86_64-apple-darwin/toolchain.cmake
     2$ cmake --build build -j11
     3...
     4[ 72%] Linking CXX shared library libbitcoinkernel.dylib
     5/usr/bin/ld: unrecognised emulation mode: llvm
     6Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386pep i386pe
     7clang++: error: linker command failed with exit code 1 (use -v to see invocation)
     8gmake[2]: *** [src/kernel/CMakeFiles/bitcoinkernel.dir/build.make:1211: src/kernel/libbitcoinkernel.dylib] Error 1
     9gmake[1]: *** [CMakeFiles/Makefile2:1838: src/kernel/CMakeFiles/bitcoinkernel.dir/all] Error 2
    10gmake: *** [Makefile:146: all] Error 2
    

    Was not able to reproduce the error building (on master) for riscv64-linux-gnu, arm-linux-gnueabihf, aarch64-linux-gnu, or x86_64-w64-mingw32.

    On the PR branch, was able to successfully cross compile for arm64-apple-darwin, x86_64-apple-darwin, riscv64-linux-gnu, arm-linux-gnueabihf, and aarch64-linux-gnu. (sanity checked with file build/src/kernel/libbitcoinkernel.{so/dylib} to see correct binary info).

    Ubuntu 24.04 with gcc 13.2.0 and clang 18.1.3.

  9. fanquake merged this on Dec 2, 2024
  10. fanquake closed this on Dec 2, 2024

  11. theuni commented at 6:14 pm on December 2, 2024: member
    Post-merge utACK a8e04704f930de168fdddbb1c040dd70fbbe8ff7

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: 2024-12-30 15:12 UTC

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