cmake: Errors not actually errors? #33153

issue fanquake openend this issue on August 7, 2025
  1. fanquake commented at 12:29 pm on August 7, 2025: member

    Using current master (6a2bb0fd835977637e0f43db76121bbfd21565f6), if you configure with the following, CMake will “Error”:

     0# gcc --version
     1# gcc (Ubuntu 14.2.0-4ubuntu2~24.04) 14.2.0
     2
     3cmake -B build -DBUILD_KERNEL_LIB=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
     4<snip>
     5Cross compiling ....................... FALSE
     6C++ compiler .......................... GNU 14.2.0, /usr/bin/c++
     7CMAKE_BUILD_TYPE ...................... RelWithDebInfo
     8Preprocessor defined macros ........... 
     9C++ compiler flags .................... -O2 -g -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/root/ci_scratch/src=. -fmacro-prefix-map=/root/ci_scratch/src=. -fstack-reuse=none -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter
    10Linker flags .......................... -O2 -g -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
    11
    12NOTE: The summary above may not exactly match the final applied build flags
    13      if any additional CMAKE_* or environment variables have been modified.
    14      To see the exact flags applied, build with the --verbose option.
    15
    16Treat compiler warnings as errors ..... OFF
    17Use ccache for compiling .............. ON
    18
    19
    20-- Configuring done (23.3s)
    21CMake Error at src/kernel/CMakeLists.txt:11 (add_library):
    22  CMake doesn't support IPO for current compiler
    23
    24
    25-- Generating done (0.1s)
    26CMake Generate step failed.  Build files cannot be regenerated correctly.
    

    However you can just call cmake --build build, and compilation “works”:

     0cmake --build build -j14 --target bitcoinkernel
     1[  0%] Generating bitcoin-build-info.h
     2[  0%] Built target secp256k1_precomputed
     3[  0%] Built target crc32c
     4[ 14%] Built target bitcoin_crypto
     5[ 14%] Built target secp256k1
     6[ 42%] Built target leveldb
     7[ 42%] Built target generate_build_info
     8[ 42%] Built target bitcoin_clientversion
     9[100%] Built target bitcoinkernel
    10
    11# file build/lib/libbitcoinkernel.a 
    12build/lib/libbitcoinkernel.a: current ar archive
    

    It would be good if when CMake errors during configuration, it’s not actually possible to continue building, rather than silently ignoring errors.

    Note that the presence of -Werror=dev when configuring, makes no difference here.

    Also, the error string CMake is throwing, is also incorrect, as the compiler does support LTO.

  2. fanquake added the label Build system on Aug 7, 2025
  3. maflcko commented at 12:39 pm on August 7, 2025: member

    in the Guix build, errors will just be silently ignored.

    I think the guix build has set -e, so it should be fine and not proceed here.

  4. hebasto commented at 12:44 pm on August 7, 2025: member

    Using current master (6a2bb0f), if you configure with the following, CMake will “Error”

    What version of CMake are you using?

  5. fanquake commented at 1:08 pm on August 7, 2025: member

    What version of CMake are you using?

    Happens with 3.28.3 & 4.0.3.

  6. fanquake commented at 1:12 pm on August 7, 2025: member

    I think the guix build has set -e, so it should be fine and not proceed here.

    Looks like this is the case, and tested the build does fail. So I guess it will just (potentially) silently ignore errors everywhere else.

  7. hebasto commented at 3:22 pm on August 7, 2025: member

    Also, the error string CMake is throwing, is also incorrect, as the compiler does support LTO.

    CMake doesn’t blame the compiler, rather itself: “CMake doesn’t support IPO for current compiler”.

    For some reason, this occurs with the “Unix Makefiles” generator but not with the “Ninja” generator.

  8. hebasto commented at 3:22 pm on August 7, 2025: member
  9. hebasto commented at 3:34 pm on August 7, 2025: member

    It seems that the $<TARGET_OBJECTS:..> added to bitcoinkernel sources in #33077 are causing the issue.

    cc @theuni


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: 2025-08-13 06:13 UTC

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