Cmake build system breaks with symbolic links #31145

issue laanwj opened this issue on October 24, 2024
  1. laanwj commented at 8:04 AM on October 24, 2024: member

    If the build directory is a symbolic link, or when the entire source directory is symlinked (and we build from there), the current cmake build runs into trouble finding its own generated files.

    To reproduce:

    git clone --depth=1 https://github.com/bitcoin/bitcoin.git
    mkdir build
    cd bitcoin/
    ln -s ../build .
    cmake -Bbuild -DBUILD_GUI=ON
    cd build
    make
    
    [ 37%] Building CXX object src/CMakeFiles/bitcoin_node.dir/validation.cpp.o
    In file included from /data/src/tmp/bitcoin/build/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:2:
    /data/src/tmp/bitcoin/build/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_addressbookpage.cpp:10:10: fatal error: ../../../../../src/qt/addressbookpage.h: No such file or directory
       10 | #include "../../../../../src/qt/addressbookpage.h"
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    make[2]: *** [src/qt/CMakeFiles/bitcoinqt.dir/build.make:784: src/qt/CMakeFiles/bitcoinqt.dir/bitcoinqt_autogen/mocs_compilation.cpp.o] Error 1
    make[2]: *** Waiting for unfinished jobs...
    

    This affects the build with Qt as well as the build with multiprocess, both which have generated files.

    With autotools this wasn't an issue, so i think it can be considered a regression. But not a high-priority one as it can be worked around by specifying the full paths instead.

  2. laanwj added the label Build system on Oct 24, 2024
  3. fanquake added this to the milestone 29.0 on Nov 13, 2024
  4. hebasto commented at 2:27 PM on November 24, 2024: member

    This affects ... the build with multiprocess...

    Unable to reproduce this part on Ubuntu 24.04.

  5. laanwj commented at 3:36 PM on November 25, 2024: member

    Unable to reproduce this part on Ubuntu 24.04.

    Okay... i'll retest the multiprocess case. If it's still an issue, it's seperate from the Qt case anyway and would need to be fixed seperately.

  6. willcl-ark commented at 1:53 PM on November 28, 2024: member

    I was able to reproduce this on Ubuntu 23.10 on master @ 7590e93 with the repro steps in OP:

    <details> <summary>Details</summary>

    [ 66%] Automatic RCC for bitcoin_locale.qrc
    [ 67%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bitcoinaddressvalidator.cpp.o
    [ 67%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bantablemodel.cpp.o
    [ 67%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bitcoinqt_autogen/mocs_compilation.cpp.o
    [ 67%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bitcoingui.cpp.o
    [ 67%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bitcoinamountfield.cpp.o
    [ 67%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bitcoin.cpp.o
    [ 67%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bitcoinunits.cpp.o
    [ 68%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/clientmodel.cpp.o
    [ 68%] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/csvmodelwriter.cpp.o
    In file included from /tmp/31145/bitcoin/build/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:2:
    /tmp/31145/bitcoin/build/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_addressbookpage.cpp:10:10: fatal error: '../../../../../src/qt/addressbookpage.h' file not found
       10 | #include "../../../../../src/qt/addressbookpage.h"
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    make[2]: *** [src/qt/CMakeFiles/bitcoinqt.dir/build.make:786: src/qt/CMakeFiles/bitcoinqt.dir/bitcoinqt_autogen/mocs_compilation.cpp.o] Error 1
    make[2]: *** Waiting for unfinished jobs....
    [ 69%] Linking CXX executable bitcoin-wallet
    [ 69%] Built target bitcoin-wallet
    make[1]: *** [CMakeFiles/Makefile2:1432: src/qt/CMakeFiles/bitcoinqt.dir/all] Error 2
    make[1]: *** Waiting for unfinished jobs....
    [ 70%] Linking CXX static library libbitcoin_node.a
    [ 70%] Built target bitcoin_node
    make: *** [Makefile:146: all] Error 2
    

    </details>

    However, if the symlink is constructed using an asbolute path then it works correctly. E.g. for me:

    mkdir -p /tmp/31145/build && cd /tmp/31145
    git clone --depth=1 https://github.com/bitcoin/bitcoin.git
    cd bitcoin
    ln -s /tmp/31145/build .
    cmake -Bbuild -DBUILD_GUI=ON
    cd build
    make
    

    So the build system seems to be getting tripped up on the relativity of the symlink.

    Actually I spoke too soon here, sorry. It just failed much later on that before:

    [ 91%] Built target test_bitcoin
    make: *** [Makefile:146: all] Error 2
    

    So I agree, symlinked build dirs seem generally broken currently with cmake.

  7. hebasto commented at 1:59 PM on November 28, 2024: member

    @willcl-ark

    So I agree, symlinked build dirs seem generally broken currently with cmake.

    Does #31361 fix it?

  8. willcl-ark commented at 2:09 PM on November 28, 2024: member

    It does indeed.

  9. fanquake closed this on Dec 2, 2024

  10. fanquake referenced this in commit da4f4fac8d on Dec 2, 2024
  11. bitcoin locked this on Dec 2, 2025

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-04-13 15:13 UTC

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