build: CMake caching failing PIE check #32323

issue fanquake openend this issue on April 22, 2025
  1. fanquake commented at 10:43 am on April 22, 2025: member

    Similar to #31942 (comment), CMake caches the check failure, which leaves the user in a broken state (unless they nuke the build dir):

     0cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init"
     1-- The CXX compiler identification is GNU 14.2.0
     2-- Detecting CXX compiler ABI info
     3-- Detecting CXX compiler ABI info - done
     4-- Check for working CXX compiler: /usr/bin/c++ - skipped
     5-- Detecting CXX compile features
     6-- Detecting CXX compile features - done
     7-- Setting build type to "RelWithDebInfo" as none was specified
     8-- Performing Test CXX_SUPPORTS__WERROR
     9-- Performing Test CXX_SUPPORTS__WERROR - Success
    10-- Performing Test CXX_SUPPORTS__G3
    11-- Performing Test CXX_SUPPORTS__G3 - Success
    12-- Performing Test LINKER_SUPPORTS__G3
    13-- Performing Test LINKER_SUPPORTS__G3 - Success
    14-- Performing Test CXX_SUPPORTS__FTRAPV
    15-- Performing Test CXX_SUPPORTS__FTRAPV - Success
    16-- Performing Test LINKER_SUPPORTS__FTRAPV
    17-- Performing Test LINKER_SUPPORTS__FTRAPV - Success
    18-- Found SQLite3: /usr/include (found suitable version "3.45.1", minimum required is "3.7.17") 
    19CMake Warning at cmake/module/CheckLinkerSupportsPIE.cmake:24 (message):
    20  PIE is not supported at link time.  See the configure log for details.
    21Call Stack (most recent call first):
    22  CMakeLists.txt:203 (check_linker_supports_pie)
    23
    24
    25-- Performing Test LINKER_SUPPORTS__WL___FATAL_WARNINGS
    26-- Performing Test LINKER_SUPPORTS__WL___FATAL_WARNINGS - Failed
    27-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
    28-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
    29-- Check if compiler accepts -pthread
    30-- Check if compiler accepts -pthread - no
    31-- Looking for pthread_create in pthreads
    32-- Looking for pthread_create in pthreads - not found
    33-- Looking for pthread_create in pthread
    34-- Looking for pthread_create in pthread - not found
    35CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
    36  Could NOT find Threads (missing: Threads_FOUND)
    37Call Stack (most recent call first):
    38  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
    39  /usr/share/cmake-3.28/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    40  CMakeLists.txt:345 (find_package)
    41
    42
    43-- Configuring incomplete, errors occurred!
    

    Fix the compiler flag (forgot the =zero), and reconfigure:

     0 cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init=zero"
     1CMake Warning at cmake/module/CheckLinkerSupportsPIE.cmake:24 (message):
     2  PIE is not supported at link time.  See the configure log for details.
     3Call Stack (most recent call first):
     4  CMakeLists.txt:203 (check_linker_supports_pie)
     5
     6
     7CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
     8  Could NOT find Threads (missing: Threads_FOUND)
     9Call Stack (most recent call first):
    10  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
    11  /usr/share/cmake-3.28/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
    12  CMakeLists.txt:345 (find_package)
    13
    14
    15-- Configuring incomplete, errors occurred!
    
  2. hebasto added the label Build system on Apr 22, 2025
  3. hebasto commented at 8:18 pm on April 26, 2025: member

    Quoting from #31942 (comment):

    … a recommended debugging step is to discard any cached results from an existing build directory…

    And in this particular case, I don’t think that the CMake cache is worth reusing.

  4. fanquake commented at 9:07 am on April 28, 2025: member
    Not sure I understand your suggestion; are you saying we don’t fix this? Are you saying we should add a recommendation to the build docs to always delete the build dir before running CMake? Something else? Note that this is a generic issue, and the PIE check is just the first check that fails in this way, if you remove the PIE check the threads check will fail the same.
  5. hebasto commented at 9:38 am on April 28, 2025: member

    are you saying we don’t fix this?

    Correct. UPD.: #32323 (comment)

    Are you saying we should add a recommendation to the build docs to always delete the build dir before running CMake? Something else?

    Not “always” — only when configuration fails. Similar to #31942 (comment).

  6. hebasto commented at 4:37 pm on April 28, 2025: member
    After further consideration, I believe this issue exposes a bug that is fixed in #32367.

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-05-05 12:12 UTC

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