build: CMake caching failing PIE check #32323

issue fanquake opened 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):

    cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init"
    -- The CXX compiler identification is GNU 14.2.0
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Setting build type to "RelWithDebInfo" as none was specified
    -- Performing Test CXX_SUPPORTS__WERROR
    -- Performing Test CXX_SUPPORTS__WERROR - Success
    -- Performing Test CXX_SUPPORTS__G3
    -- Performing Test CXX_SUPPORTS__G3 - Success
    -- Performing Test LINKER_SUPPORTS__G3
    -- Performing Test LINKER_SUPPORTS__G3 - Success
    -- Performing Test CXX_SUPPORTS__FTRAPV
    -- Performing Test CXX_SUPPORTS__FTRAPV - Success
    -- Performing Test LINKER_SUPPORTS__FTRAPV
    -- Performing Test LINKER_SUPPORTS__FTRAPV - Success
    -- Found SQLite3: /usr/include (found suitable version "3.45.1", minimum required is "3.7.17") 
    CMake Warning at cmake/module/CheckLinkerSupportsPIE.cmake:24 (message):
      PIE is not supported at link time.  See the configure log for details.
    Call Stack (most recent call first):
      CMakeLists.txt:203 (check_linker_supports_pie)
    
    
    -- Performing Test LINKER_SUPPORTS__WL___FATAL_WARNINGS
    -- Performing Test LINKER_SUPPORTS__WL___FATAL_WARNINGS - Failed
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
    -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
    -- Check if compiler accepts -pthread
    -- Check if compiler accepts -pthread - no
    -- Looking for pthread_create in pthreads
    -- Looking for pthread_create in pthreads - not found
    -- Looking for pthread_create in pthread
    -- Looking for pthread_create in pthread - not found
    CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find Threads (missing: Threads_FOUND)
    Call Stack (most recent call first):
      /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
      /usr/share/cmake-3.28/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
      CMakeLists.txt:345 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    

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

     cmake -B build -DAPPEND_CXXFLAGS="-ftrivial-auto-var-init=zero"
    CMake Warning at cmake/module/CheckLinkerSupportsPIE.cmake:24 (message):
      PIE is not supported at link time.  See the configure log for details.
    Call Stack (most recent call first):
      CMakeLists.txt:203 (check_linker_supports_pie)
    
    
    CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
      Could NOT find Threads (missing: Threads_FOUND)
    Call Stack (most recent call first):
      /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
      /usr/share/cmake-3.28/Modules/FindThreads.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
      CMakeLists.txt:345 (find_package)
    
    
    -- 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: 2026-05-01 15:12 UTC

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