Can’t compile bitcoin for SmartOS - recipe for target ‘compat/libbitcoin_util_a-glibc_sanity.o’ failed #13581

issue stacepellegrino openend this issue on July 1, 2018
  1. stacepellegrino commented at 4:37 pm on July 1, 2018: none

    After fixing #13580 my build still fails with…

     0CXX compat/libbitcoin_util_a-glibc_sanity.o
     1In file included from compat/glibc_sanity.cpp:12:0:
     2compat/glibc_sanity.cpp: In function 'bool {anonymous}::sanity_test_fdelt()':
     3compat/glibc_sanity.cpp:53:5: error: 'memset' was not declared in this scope
     4FD_ZERO(&fds);
     5^
     6Makefile:6248: recipe for target 'compat/libbitcoin_util_a-glibc_sanity.o' failed
     7make[2]: *** [compat/libbitcoin_util_a-glibc_sanity.o] Error 1
     8make[2]: Leaving directory '/opt/local/src/bitcoin/src'
     9Makefile:9824: recipe for target 'all-recursive' failed
    10make[1]: *** [all-recursive] Error 1
    11make[1]: Leaving directory '/opt/local/src/bitcoin/src'
    12Makefile:757: recipe for target 'all-recursive' failed
    13make: *** [all-recursive] Error 1
    

    I have attached config.log for your review.

  2. stacepellegrino commented at 4:59 pm on July 1, 2018: none
     0# make V=1
     1Making all in src
     2make[1]: Entering directory '/opt/local/src/bitcoin/src'
     3make[2]: Entering directory '/opt/local/src/bitcoin/src'
     4make[3]: Entering directory '/opt/local/src/bitcoin'
     5make[3]: Leaving directory '/opt/local/src/bitcoin'
     6g++ -std=c++11 -DHAVE_CONFIG_H -I. -I../src/config   -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -I. -I/opt/local/include/db4/ -DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC -pthread -I/opt/local/include -I./leveldb/include -I./leveldb/helpers/memenv -I/opt/local/include -I/opt/local/include -I./secp256k1/include -I./univalue/include -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS  -Wstack-protector -fstack-protector-all -Wall -Wextra -Wformat -Wvla -Wno-unused-parameter    -fPIE -g -O2 -MT compat/libbitcoin_util_a-glibc_sanity.o -MD -MP -MF compat/.deps/libbitcoin_util_a-glibc_sanity.Tpo -c -o compat/libbitcoin_util_a-glibc_sanity.o `test -f 'compat/glibc_sanity.cpp' || echo './'`compat/glibc_sanity.cpp
     7In file included from compat/glibc_sanity.cpp:12:0:
     8compat/glibc_sanity.cpp: In function 'bool {anonymous}::sanity_test_fdelt()':
     9compat/glibc_sanity.cpp:53:5: error: 'memset' was not declared in this scope
    10     FD_ZERO(&fds);
    11     ^
    12Makefile:6248: recipe for target 'compat/libbitcoin_util_a-glibc_sanity.o' failed
    13make[2]: *** [compat/libbitcoin_util_a-glibc_sanity.o] Error 1
    14make[2]: Leaving directory '/opt/local/src/bitcoin/src'
    15Makefile:9824: recipe for target 'all-recursive' failed
    16make[1]: *** [all-recursive] Error 1
    17make[1]: Leaving directory '/opt/local/src/bitcoin/src'
    18Makefile:757: recipe for target 'all-recursive' failed
    19make: *** [all-recursive] Error 1
    
  3. Empact commented at 9:39 pm on July 1, 2018: member
    I’ll take this.
  4. Empact commented at 10:56 pm on July 1, 2018: member
    Could you try building my branch at #13584?
  5. stacepellegrino commented at 11:40 pm on July 1, 2018: none
    Just doing a cloning your branch to build now.
  6. stacepellegrino commented at 11:56 pm on July 1, 2018: none
    What commands do I use to fetch, merge and build your branch?
  7. stacepellegrino commented at 0:03 am on July 2, 2018: none

    Just figured it out…

    0# git remote show origin
    1# git merge master
    2# git config --global user.email stacey.pellegrino@gmail.com
    3# git config --global user.name "Stacey Pellegrino"
    4# git commit
    
  8. stacepellegrino commented at 0:24 am on July 2, 2018: none
    I don’t think the branch pulled as I am still getting the same build error. What are the commands needed to pull your branch?
  9. Empact commented at 0:24 am on July 2, 2018: member
    Not at a computer to confirm, but I think this should work: git remote add Empact https://github.com/Empact/bitcoin git fetch Empact git checkout -b cstring Empact/cstring make
  10. stacepellegrino commented at 0:53 am on July 2, 2018: none

    Build now does not fail when compiling compat/libbitcoin_util_a-glibc_sanity.o now. @Empact ’s fix solved the issue.

    However, build now fails with the following:

     0leveldb/util/env_posix.cc: In member function 'virtual leveldb::Status leveldb::{anonymous}::PosixSequentialFile::Read(std::size_t, leveldb::Slice*, char*)':
     1leveldb/util/env_posix.cc:105:51: error: 'fread_unlocked' was not declared in this scope
     2     size_t r = fread_unlocked(scratch, 1, n, file_);
     3                                                   ^
     4leveldb/util/env_posix.cc: In member function 'virtual leveldb::Status leveldb::{anonymous}::PosixWritableFile::Append(const leveldb::Slice&)':
     5leveldb/util/env_posix.cc:234:66: error: 'fwrite_unlocked' was not declared in this scope
     6     size_t r = fwrite_unlocked(data.data(), 1, data.size(), file_);
     7                                                                  ^
     8leveldb/util/env_posix.cc: In member function 'virtual leveldb::Status leveldb::{anonymous}::PosixWritableFile::Flush()':
     9leveldb/util/env_posix.cc:251:30: error: 'fflush_unlocked' was not declared in this scope
    10     if (fflush_unlocked(file_) != 0) {
    11                              ^
    12leveldb/util/env_posix.cc: In member function 'virtual leveldb::Status leveldb::{anonymous}::PosixWritableFile::Sync()':
    13leveldb/util/env_posix.cc:290:30: error: 'fflush_unlocked' was not declared in this scope
    14     if (fflush_unlocked(file_) != 0 ||
    15                              ^
    16Makefile:5044: recipe for target 'leveldb/util/leveldb_libleveldb_a-env_posix.o' failed
    17make[2]: *** [leveldb/util/leveldb_libleveldb_a-env_posix.o] Error 1
    18make[2]: Leaving directory '/opt/local/src/bitcoin/src'
    19Makefile:9824: recipe for target 'all-recursive' failed
    20make[1]: *** [all-recursive] Error 1
    21make[1]: Leaving directory '/opt/local/src/bitcoin/src'
    22Makefile:757: recipe for target 'all-recursive' failed
    23make: *** [all-recursive] Error 1
    

    Creating a new issue regarding this build failure.

  11. stacepellegrino closed this on Jul 2, 2018

  12. Empact commented at 2:35 am on July 2, 2018: member
    @stacepellegrino could you re-open this? We can close it when a fix is merged.
  13. stacepellegrino reopened this on Jul 2, 2018

  14. MarcoFalke commented at 7:00 pm on July 9, 2018: member
    @Empact Are you still working on a “more targeted fix”
  15. Empact commented at 8:00 pm on July 9, 2018: member

    Sorry I forgot that PR fixed this issue. I can go with either restoring the specific include or merging the existing work, which I just reopened.

    The “more target fix” I’ve been working on relates to applying iwyu to bitcoin, which I intend to use as a external / automated check on the include work, e.g. #13584. I’ll post the related iwyu output today.

  16. Empact commented at 10:07 pm on July 9, 2018: member
    Here’s a PR to fix just this instance: #13619. It may or may not be enough to get past this and onto #13585, but @stacepellegrino will have to confirm.
  17. Empact commented at 6:38 am on July 10, 2018: member

    @stacepellegrino I don’t think you have your system properly setup, e.g. see this output from configure:

     0configure:28711: g++ -std=c++11 -o conftest -g -O2  -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -DBOOST_SP_USE_STD_ATOMIC -DBOOST_AC_USE_STD_ATOMIC -pthread -I/opt/local/include  conftest.cpp -L/opt/local/lib -lboost_system -lboost_filesystem -lboost_program_options -lboost_thread -lboost_chrono  >&5
     1conftest.cpp: In function 'int main()':
     2conftest.cpp:85:5: error: 'choke' was not declared in this scope
     3     choke;
     4     ^
     5configure:28711: $? = 1
     6configure: failed program was:
     7| /* confdefs.h */
     8| #define PACKAGE_NAME "Bitcoin Core"
     9| #define PACKAGE_TARNAME "bitcoin"
    10| #define PACKAGE_VERSION "0.16.99"
    11| #define PACKAGE_STRING "Bitcoin Core 0.16.99"
    12| #define PACKAGE_BUGREPORT "https://github.com/bitcoin/bitcoin/issues"
    13| #define PACKAGE_URL "https://bitcoincore.org/"
    14| #define HAVE_CXX11 1
    15| #define STDC_HEADERS 1
    16| #define HAVE_SYS_TYPES_H 1
    17| #define HAVE_SYS_STAT_H 1
    18| #define HAVE_STDLIB_H 1
    
  18. MarcoFalke commented at 7:02 pm on July 11, 2018: member

    I believe this can be fixed by adding the missing include:

     0diff --git a/src/compat/glibc_sanity.cpp b/src/compat/glibc_sanity.cpp
     1index 20d2ad3cb6..a99f260871 100644
     2--- a/src/compat/glibc_sanity.cpp
     3+++ b/src/compat/glibc_sanity.cpp
     4@@ -7,6 +7,7 @@
     5 #endif
     6 
     7 #include <cstddef>
     8+#include <cstring>
     9 
    10 #if defined(HAVE_SYS_SELECT_H)
    11 #include <sys/select.h>
    
  19. Empact commented at 7:21 pm on July 11, 2018: member

    @MarcoFalke agreed, similarly: #13619

    But I’m doubting this SmartOS thread - if configure can not run successfully, then are there not some basic platform issues to address first? Seems configure should run cleanly before we tackle build errors.

  20. theuni commented at 8:41 pm on July 11, 2018: member

    @Empact sadly this is just a bug in SmartOS’s libc. glibc even makes a note about not using memset for this reason.

    We can work around it by splitting glibc_sanity.cpp into two pieces: One for sanity_test_memcpy and one for sanity_test_fdelt. Once split, the file with sanity_test_fdelt can safely include string.h.

  21. fanquake added the label Build system on Sep 6, 2018
  22. bahamas10 commented at 9:14 pm on January 10, 2019: none

    I ran into this issue as well and was able to fix it using the diff provided by @MarcoFalke

    I provisioned a fresh SmartOS 16Q4 LTS instance to do this:

    0$ uname -v
    1joyent_20180927T004151Z
    2$ cat /etc/product
    3Name: Joyent Instance
    4Image: base-64-lts 16.4.1
    5Documentation: https://docs.joyent.com/images/smartos/base
    

    Installed deps:

    0sudo pkgin in build-essential autoconf pkg-config boost
    

    Pulled the source and checked out the latest version (at the time of this writing):

    0cd ~
    1git clone https://github.com/bitcoin/bitcoin.git
    2cd bitcoin/
    3git checkout v0.17.1
    

    Autogen + configure:

    0./autogen.sh
    1./configure --disable-wallet --without-gui --without-miniupnpc --disable-tests
    

    Patch the source:

    0vim ./src/compat/glibc_sanity.cpp
    
     0$ git diff
     1diff --git a/src/compat/glibc_sanity.cpp b/src/compat/glibc_sanity.cpp
     2index 1ef66e27b..0166fea90 100644
     3--- a/src/compat/glibc_sanity.cpp
     4+++ b/src/compat/glibc_sanity.cpp
     5@@ -7,6 +7,7 @@
     6 #endif
     7
     8 #include <cstddef>
     9+#include <cstring>
    10
    11 #if defined(HAVE_SYS_SELECT_H)
    12 #include <sys/select.h>
    

    Compiled:

    0make 
    

    Ensured it worked:

    0$ ./src/bitcoin-cli -version
    1Bitcoin Core RPC client version v0.17.1.0-ef70f9b52-dirty
    
  23. Empact commented at 2:25 am on January 11, 2019: member
    @bahamas10 would you try building the code on this branch?: https://github.com/Empact/bitcoin/tree/glibc-sanity-string
  24. bahamas10 commented at 4:12 am on January 11, 2019: none

    @Empact Tested. I used the same instance I used in my previous comment with the same dependencies already installed:

    0git clone https://github.com/Empact/bitcoin.git bitcoin-smartos-fix
    1cd bitcoin-smartos-fix/
    2git checkout glibc-sanity-string
    3./autogen.sh 
    4./configure --disable-wallet --without-gui --without-miniupnpc --disable-tests
    5make
    
     0$ make
     1...
     2  CXXLD    bench/bench_bitcoin
     3Undefined                       first referenced
     4 symbol                             in file
     5getnameinfo                         libbitcoin_common.a(libbitcoin_common_a-netaddress.o)  (symbol belongs to implicit dependency /lib/amd64/libsocket.so.1)
     6ld: fatal: symbol referencing errors. No output written to bench/bench_bitcoin
     7collect2: error: ld returned 1 exit status
     8Makefile:3991: recipe for target 'bench/bench_bitcoin' failed
     9make[2]: *** [bench/bench_bitcoin] Error 1
    10make[2]: Leaving directory '/home/dave/dev/bitcoin-smartos-fix/src'
    11Makefile:10520: recipe for target 'all-recursive' failed
    12make[1]: *** [all-recursive] Error 1
    13make[1]: Leaving directory '/home/dave/dev/bitcoin-smartos-fix/src'
    14Makefile:773: recipe for target 'all-recursive' failed
    15make: *** [all-recursive] Error 1
    

    I haven’t looked into this tonight (I can look more tomorrow), but i’m willing to bet there probably needs to be a -lsocket somewhere.

  25. bahamas10 commented at 5:46 pm on January 11, 2019: none

    @Empact I was able to get this all to compile by adding -lsocket to the ./configure step

    0$ LIBS='-lsocket' ./configure --disable-wallet --without-gui --without-miniupnpc --disable-tests
    1$ make
    2...
    3$ ./src/bitcoind -version
    4Bitcoin Core Daemon version v0.17.99.0-effb4fdae
    5Copyright (C) 2009-2019 The Bitcoin Core developers
    6...
    
  26. laanwj closed this on Sep 18, 2019

  27. Empact commented at 7:49 pm on September 18, 2019: member
    #15146 has been merged, could you try again with current master? We may need to re-open for the -lsocket issue, etc.
  28. sidhujag referenced this in commit f5f7b1e08e on Sep 23, 2019
  29. MarcoFalke locked this on Dec 16, 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: 2024-10-04 19:12 UTC

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