Cmake build system breaks with symbolic links #31145

issue laanwj openend 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:

    0git clone --depth=1 https://github.com/bitcoin/bitcoin.git
    1mkdir build
    2cd bitcoin/
    3ln -s ../build .
    4cmake -Bbuild -DBUILD_GUI=ON
    5cd build
    6make
    
    0[ 37%] Building CXX object src/CMakeFiles/bitcoin_node.dir/validation.cpp.o
    1In file included from /data/src/tmp/bitcoin/build/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:2:
    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
    3   10 | #include "../../../../../src/qt/addressbookpage.h"
    4      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    5compilation terminated.
    6make[2]: *** [src/qt/CMakeFiles/bitcoinqt.dir/build.make:784: src/qt/CMakeFiles/bitcoinqt.dir/bitcoinqt_autogen/mocs_compilation.cpp.o] Error 1
    7make[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:

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

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

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

    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:

    0[ 91%] Built target test_bitcoin
    1make: *** [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


laanwj hebasto willcl-ark

Labels
Build system

Milestone
29.0


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

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