Out-of-tree builds don't currently work #7466

issue laanwj opened this issue on February 4, 2016
  1. laanwj commented at 1:33 PM on February 4, 2016: member

    Unlike most projects using autotools, Bitcoin Core does not suppport out-of-tree builds. Trying to do this results in an error during build:

    $ cd build
    $ ../bitcoin/autogen.sh
    ...
    $ ../bitcoin/configure
    ...
    $ make -j10
    Building LevelDB ...
    make[3]: Entering directory '/data/src/x/build/src'
    make[3]: *** leveldb: No such file or directory.  Stop.
    make[3]: Leaving directory '/data/src/x/build/src'
    Makefile:7553: recipe for target 'leveldb/libmemenv.a' failed
    make[2]: *** [leveldb/libmemenv.a] Error 2
    make[2]: *** Waiting for unfinished jobs....
    make[2]: Leaving directory '/data/src/x/build/src'
    Makefile:7060: recipe for target 'all-recursive' failed
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory '/data/src/x/build/src'
    Makefile:654: recipe for target 'all
    

    There are various reasons why out-of-tree builds are preferred, so it would be nice if this worked.

  2. laanwj added the label Build system on Feb 4, 2016
  3. kleetus commented at 2:52 PM on February 4, 2016: none

    I think what you are referring to are VPATH builds. I put a merge request in ages ago for this very issue.

    #6336

    What needs to get adjusted is LevelDB's custom makefile (it should have a configure.ac at the very least). Since LevelDB is a Google project, it should be fixed there, but Google isn't really maintaining this project anymore, IIRC. And, since LevelDB was not submoduled into Bitcoin, but copied in and maintained by hand, this is difficult. My merge request addressed the issue of using LevelDB within the context of well-behaved autotools projects like Bitcoin. I would be happy to update the merge request and resubmit.

  4. sipa commented at 3:04 PM on February 4, 2016: member

    I think you misread my comment there.

    We have our own slightly modified branch of LevelDB, in https://github.com/bitcoin/leveldb. If we want to change LevelDB's build system, we can do it there, and update the subtree in Bitcoin.

    The question is just whether we want to maintain our own modified build system for LevelDB. I think doing so deserves being discussed at least, as LevelDB is hardly making any changes anymore, and it is an often seen problem.

    It would be better to get google/leveldb to use a more modern build system, but it sounds unlikely to be accepted.

  5. laanwj commented at 3:04 PM on February 4, 2016: member

    Thanks! I did a search of prior issues but somehow missed that one.

    I'd prefer an upstream solution too, but that doesn't seem to be coming. As you say LevelDB upstream is only intermittently maintained - though it seems there is a flurry of activity now.

    We already have some custom changes in https://github.com/bitcoin/leveldb/, maybe it could be added there for now.

  6. kleetus commented at 3:35 PM on February 4, 2016: none

    @sipa I did misread your comment, thanks for pointing that out. I wasn't sure of the mechanism that bitcoin/leveldb gets pulled into Bitcoin. The hand-rolled makefile in both google/leveldb and bitcoin/leveldb work pretty well in their own context. It seems to me that someone is tasked with cherry-picking in files from github's bitcoin/leveldb to the bitcoin/src/leveldb directory. This might be similar to the way libsecp256k1works as well, but this is a little off-topic. My suggestion would be to convert bitcoin/leveldb into a "well-behaved" autotools project (like libsecp256k1 is now). I would be happy to do this if someone has not committed to this work already.

    At the same time, I would like to suggest that libsecp256k1 and leveldb become git submodules instead of code that needs to be copied into the project by hand (if this in fact what happens). My apologies for the slight derailment.

  7. sipa commented at 3:38 PM on February 4, 2016: member

    They are not just copied into the tree. They are git subtrees, and have several advantages over submodules.

    If updates are made to the bitcoin/leveldb repository, we can easily pull them into Bitcoin Core, in a verifiable manner.

  8. laanwj commented at 3:44 PM on February 4, 2016: member

    My suggestion would be to convert bitcoin/leveldb into a "well-behaved" autotools project (like libsecp256k1 is now). I would be happy to do this if someone has not committed to this work already.

    Sounds good to me. Seems like the cleanest solution.

  9. kleetus commented at 7:56 PM on February 5, 2016: none

    I've added this merge request to bitcoin/leveldb:

    https://github.com/bitcoin/leveldb/pull/11

    if/when this is merged and pulled into Bitcoin's src/leveldb, then I can and will put in a merge request for Bitcoin's configure.ac for a one line change:

    AC_CONFIG_SUBDIRS([src/leveldb])

  10. laanwj commented at 7:54 AM on February 8, 2016: member

    Thanks, looks good to me, I'll test later @theuni can you take a look?

  11. laanwj commented at 2:58 PM on February 10, 2016: member

    AC_CONFIG_SUBDIRS([src/leveldb])

    Tested ACK. Both in-tree and out-of-tree builds work after importing https://github.com/bitcoin/leveldb/pull/11 and adding this to configure.ac.

  12. laanwj commented at 8:00 AM on March 30, 2016: member

    I'd really like to move this forward, we should pick one of the alternatives and merge it:

  13. laanwj commented at 11:57 AM on April 15, 2016: member

    Another thing that would speak for just integrating leveldb into our build system. I needed the following change to be able to use llvm-ar (to use link-time optimization):

    diff --git a/src/leveldb/Makefile b/src/leveldb/Makefile
    index 2bd2cad..e87ae01 100644
    --- a/src/leveldb/Makefile
    +++ b/src/leveldb/Makefile
    @@ -108,7 +108,7 @@ clean:
    
     $(LIBRARY): $(LIBOBJECTS)
            rm -f $@
    -       $(AR) -rs $@ $(LIBOBJECTS)
    +       $(AR) rs $@ $(LIBOBJECTS)
    
     db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
            $(CXX) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LIBS)
    @@ -190,7 +190,7 @@ write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
    
     $(MEMENVLIBRARY) : $(MEMENVOBJECTS)
            rm -f $@
    -       $(AR) -rs $@ $(MEMENVOBJECTS)
    +       $(AR) rs $@ $(MEMENVOBJECTS)
    
     memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
            $(CXX) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LIBS)
    

    This works fine for all the archives that are part of Bitcoin Core's own build system. Having a separate "cranky" build system to maintain here just gives more work.

  14. theuni commented at 6:36 PM on April 15, 2016: member

    Sorry for letting this slip. Agreed.

    Given the lack of activity upstream, I don't think it's worthwhile trying to integrate with their buildsystem. I'll update my PR in the other repo.

  15. laanwj commented at 11:02 AM on April 28, 2016: member

    Closing as #7911 was merged.

  16. laanwj closed this on Apr 28, 2016

  17. MarcoFalke locked this on Sep 8, 2021

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

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