From d071e316e5bdcaf15ae8ec1a69ead26b21818a10 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 16 Jul 2020 18:20:20 +1200 Subject: [PATCH 01/21] depends: Add Clang 8.0.0 We vendor only the subset of the Clang tarball that we require. --- depends/packages/native_clang.mk | 32 ++++++++++++++++++++++++++++++++ depends/packages/packages.mk | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 depends/packages/native_clang.mk diff --git a/depends/packages/native_clang.mk b/depends/packages/native_clang.mk new file mode 100644 index 000000000..7df7f05d0 --- /dev/null +++ b/depends/packages/native_clang.mk @@ -0,0 +1,32 @@ +package=native_clang +$(package)_major_version=8 +$(package)_version=8.0.0 +$(package)_download_path=https://releases.llvm.org/$($(package)_version) +$(package)_download_file_linux=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_file_name_linux=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_sha256_hash_linux=9ef854b71949f825362a119bf2597f744836cb571131ae6b721cd102ffea8cd0 +$(package)_download_file_darwin=clang+llvm-$($(package)_version)-x86_64-apple-darwin.tar.xz +$(package)_file_name_darwin=clang-llvm-$($(package)_version)-x86_64-apple-darwin.tar.xz +$(package)_sha256_hash_darwin=94ebeb70f17b6384e052c47fef24a6d70d3d949ab27b6c83d4ab7b298278ad6f + +# Ensure we have clang native to the builder, not the target host +ifneq ($(canonical_host),$(build)) +$(package)_exact_download_file=$($(package)_download_file_$(build_os)) +$(package)_exact_file_name=$($(package)_file_name_$(build_os)) +$(package)_exact_sha256_hash=$($(package)_sha256_hash_$(build_os)) +endif + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/bin && \ + cp bin/clang-$($(package)_major_version) $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-ar $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-nm $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-objcopy $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/clang $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/llvm-ranlib $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/llvm-strip $($(package)_staging_prefix_dir)/bin && \ + mv include/ $($(package)_staging_prefix_dir) && \ + mv lib/ $($(package)_staging_prefix_dir) && \ + mv libexec/ $($(package)_staging_prefix_dir) +endef diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index ae88c1914..b176fdfe9 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,6 +1,6 @@ zcash_packages := libsodium utfcpp packages := boost libevent zeromq $(zcash_packages) googletest -native_packages := native_ccache native_rust +native_packages := native_clang native_ccache native_rust wallet_packages=bdb From d306b72be4bbb836377ae1831580d7c0e8d91b86 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 16 Jul 2020 18:20:51 +1200 Subject: [PATCH 02/21] depends: Use vendored Clang for native compilation Clang is used for compiling C/C++ dependencies, as well as the Zcash binaries themselves. GCC is still required for compiling native toolchain dependencies (such as ccache). --- depends/hosts/default.mk | 22 ++++++++++++++++------ depends/hosts/freebsd.mk | 16 ---------------- depends/hosts/linux.mk | 16 ---------------- depends/packages/boost.mk | 2 +- 4 files changed, 17 insertions(+), 39 deletions(-) diff --git a/depends/hosts/default.mk b/depends/hosts/default.mk index 6f60d6b3f..a6f0f3a56 100644 --- a/depends/hosts/default.mk +++ b/depends/hosts/default.mk @@ -1,12 +1,22 @@ -default_host_CC = $(host_toolchain)gcc -default_host_CXX = $(host_toolchain)g++ -default_host_AR = $(host_toolchain)ar -default_host_RANLIB = $(host_toolchain)ranlib -default_host_STRIP = $(host_toolchain)strip +# Flag explanations: +# +# -B$(build_prefix)/bin +# +# Explicitly point to our binaries (e.g. cctools) so that they are +# ensured to be found and preferred over other possibilities. +# +default_host_CC = clang -target $(host) -B$(build_prefix)/bin +default_host_CXX = clang++ -target $(host) -B$(build_prefix)/bin -stdlib=libc++ +default_host_AR = llvm-ar +default_host_RANLIB = llvm-ranlib +default_host_STRIP = llvm-strip default_host_LIBTOOL = $(host_toolchain)libtool default_host_INSTALL_NAME_TOOL = $(host_toolchain)install_name_tool default_host_OTOOL = $(host_toolchain)otool -default_host_NM = $(host_toolchain)nm +default_host_NM = llvm-nm + +$(host_os)_native_binutils?=native_clang +$(host_os)_native_toolchain?=native_clang define add_host_tool_func $(host_os)_$1?=$$(default_host_$1) diff --git a/depends/hosts/freebsd.mk b/depends/hosts/freebsd.mk index 07436aef8..56fe3da89 100644 --- a/depends/hosts/freebsd.mk +++ b/depends/hosts/freebsd.mk @@ -9,23 +9,7 @@ freebsd_debug_CXXFLAGS=$(freebsd_debug_CFLAGS) freebsd_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -ifeq (86,$(findstring 86,$(build_arch))) -i686_freebsd_CC=gcc -m32 -i686_freebsd_CXX=g++ -m32 -i686_freebsd_AR=ar -i686_freebsd_RANLIB=ranlib -i686_freebsd_NM=nm -i686_freebsd_STRIP=strip - -x86_64_freebsd_CC=gcc -m64 -x86_64_freebsd_CXX=g++ -m64 -x86_64_freebsd_AR=ar -x86_64_freebsd_RANLIB=ranlib -x86_64_freebsd_NM=nm -x86_64_freebsd_STRIP=strip -else i686_freebsd_CC=$(default_host_CC) -m32 i686_freebsd_CXX=$(default_host_CXX) -m32 x86_64_freebsd_CC=$(default_host_CC) -m64 x86_64_freebsd_CXX=$(default_host_CXX) -m64 -endif diff --git a/depends/hosts/linux.mk b/depends/hosts/linux.mk index 31748d662..72e45cd8a 100644 --- a/depends/hosts/linux.mk +++ b/depends/hosts/linux.mk @@ -9,23 +9,7 @@ linux_debug_CXXFLAGS=$(linux_debug_CFLAGS) linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -ifeq (86,$(findstring 86,$(build_arch))) -i686_linux_CC=gcc -m32 -i686_linux_CXX=g++ -m32 -i686_linux_AR=ar -i686_linux_RANLIB=ranlib -i686_linux_NM=nm -i686_linux_STRIP=strip - -x86_64_linux_CC=gcc -m64 -x86_64_linux_CXX=g++ -m64 -x86_64_linux_AR=ar -x86_64_linux_RANLIB=ranlib -x86_64_linux_NM=nm -x86_64_linux_STRIP=strip -else i686_linux_CC=$(default_host_CC) -m32 i686_linux_CXX=$(default_host_CXX) -m32 x86_64_linux_CC=$(default_host_CC) -m64 x86_64_linux_CXX=$(default_host_CXX) -m64 -endif diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 35b929613..2fe4232f7 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -16,7 +16,7 @@ $(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win3 $(package)_config_opts_x86_64_mingw32=address-model=64 $(package)_config_opts_i686_mingw32=address-model=32 $(package)_config_opts_i686_linux=address-model=32 architecture=x86 -$(package)_toolset_$(host_os)=gcc +$(package)_toolset_$(host_os)=clang $(package)_archiver_$(host_os)=$($(package)_ar) $(package)_toolset_darwin=darwin $(package)_archiver_darwin=$($(package)_libtool) From d3330ab797a481d7718b4635584feba308419f0f Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Fri, 17 Jul 2020 19:27:35 +0100 Subject: [PATCH 03/21] Fix warnings surfaced by compiling with clang++. Signed-off-by: Daira Hopwood --- src/wallet/gtest/test_wallet_zkeys.cpp | 1 - src/wallet/test/rpc_wallet_tests.cpp | 36 +++++++++++++------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/wallet/gtest/test_wallet_zkeys.cpp b/src/wallet/gtest/test_wallet_zkeys.cpp index fc205589a..619a61343 100644 --- a/src/wallet/gtest/test_wallet_zkeys.cpp +++ b/src/wallet/gtest/test_wallet_zkeys.cpp @@ -336,7 +336,6 @@ TEST(WalletZkeysTest, WriteViewingKeyDirectToDB) { /** * This test covers methods on CWalletDB to load/save crypted z keys. */ -/* TODO: Uncomment during PR for #3388 TEST(WalletZkeysTest, WriteCryptedzkeyDirectToDb) { SelectParams(CBaseChainParams::TESTNET); diff --git a/src/wallet/test/rpc_wallet_tests.cpp b/src/wallet/test/rpc_wallet_tests.cpp index 64f953412..5a3c86b66 100644 --- a/src/wallet/test/rpc_wallet_tests.cpp +++ b/src/wallet/test/rpc_wallet_tests.cpp @@ -1129,7 +1129,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters) } try { - std::vector recipients = { SendManyRecipient("dummy",1.0, "") }; + std::vector recipients = { SendManyRecipient("dummy", 1*COIN, "") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, "INVALID", recipients, {}, 1) ); } catch (const UniValue& objError) { BOOST_CHECK( find_error(objError, "Invalid from address")); @@ -1137,7 +1137,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters) // Testnet payment addresses begin with 'zt'. This test detects an incorrect prefix. try { - std::vector recipients = { SendManyRecipient("dummy",1.0, "") }; + std::vector recipients = { SendManyRecipient("dummy", 1*COIN, "") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, "zcMuhvq8sEkHALuSU2i4NbNQxshSAYrpCExec45ZjtivYPbuiFPwk6WHy4SvsbeZ4siy1WheuRGjtaJmoD1J8bFqNXhsG6U", recipients, {}, 1) ); } catch (const UniValue& objError) { BOOST_CHECK( find_error(objError, "Invalid from address")); @@ -1146,7 +1146,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_parameters) // Note: The following will crash as a google test because AsyncRPCOperation_sendmany // invokes a method on pwalletMain, which is undefined in the google test environment. try { - std::vector recipients = { SendManyRecipient("dummy",1.0, "") }; + std::vector recipients = { SendManyRecipient("dummy", 1*COIN, "") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, "ztjiDe569DPNbyTE6TSdJTaSDhoXEHLGvYoUnBU1wfVNU52TEyT6berYtySkd21njAeEoh8fFJUT42kua9r8EnhBaEKqCpP", recipients, {}, 1) ); } catch (const UniValue& objError) { BOOST_CHECK( find_error(objError, "no spending key found for zaddr")); @@ -1193,7 +1193,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // there are no utxos to spend { - std::vector recipients = { SendManyRecipient(zaddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, taddr1, {}, recipients, 1) ); operation->main(); BOOST_CHECK(operation->isFailed()); @@ -1204,7 +1204,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // minconf cannot be zero when sending from zaddr { try { - std::vector recipients = {SendManyRecipient(taddr1, 100.0, "DEADBEEF")}; + std::vector recipients = {SendManyRecipient(taddr1, 100*COIN, "DEADBEEF")}; std::shared_ptr operation(new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 0)); BOOST_CHECK(false); // Fail test if an exception is not thrown } catch (const UniValue& objError) { @@ -1215,7 +1215,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // there are no unspent notes to spend { - std::vector recipients = { SendManyRecipient(taddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(taddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) ); operation->main(); BOOST_CHECK(operation->isFailed()); @@ -1225,7 +1225,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // get_memo_from_hex_string()) { - std::vector recipients = { SendManyRecipient(zaddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr); @@ -1276,7 +1276,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // add_taddr_change_output_to_tx() will append a vout to a raw transaction { - std::vector recipients = { SendManyRecipient(zaddr1,100.0, "DEADBEEF") }; + std::vector recipients = { SendManyRecipient(zaddr1, 100*COIN, "DEADBEEF") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); TEST_FRIEND_AsyncRPCOperation_sendmany proxy(ptr); @@ -1285,14 +1285,14 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) BOOST_CHECK(tx.vout.size() == 0); CReserveKey keyChange(pwalletMain); - CAmount amount = AmountFromValue(ValueFromString("123.456")); + CAmount amount = 12345600000; proxy.add_taddr_change_output_to_tx(keyChange, amount); tx = proxy.getTx(); BOOST_CHECK(tx.vout.size() == 1); CTxOut out = tx.vout[0]; BOOST_CHECK_EQUAL(out.nValue, amount); - amount = AmountFromValue(ValueFromString("1.111")); + amount = 111100000; proxy.add_taddr_change_output_to_tx(keyChange, amount); tx = proxy.getTx(); BOOST_CHECK(tx.vout.size() == 2); @@ -1303,9 +1303,9 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) // add_taddr_outputs_to_tx() will append many vouts to a raw transaction { std::vector recipients = { - SendManyRecipient("tmTGScYwiLMzHe4uGZtBYmuqoW4iEoYNMXt",CAmount(1.23), ""), - SendManyRecipient("tmUSbHz3vxnwLvRyNDXbwkZxjVyDodMJEhh",CAmount(4.56), ""), - SendManyRecipient("tmYZAXYPCP56Xa5JQWWPZuK7o7bfUQW6kkd",CAmount(7.89), ""), + SendManyRecipient("tmTGScYwiLMzHe4uGZtBYmuqoW4iEoYNMXt", 123000000, ""), + SendManyRecipient("tmUSbHz3vxnwLvRyNDXbwkZxjVyDodMJEhh", 456000000, ""), + SendManyRecipient("tmYZAXYPCP56Xa5JQWWPZuK7o7bfUQW6kkd", 789000000, ""), }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, recipients, {}, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); @@ -1315,15 +1315,15 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_internals) CTransaction tx = proxy.getTx(); BOOST_CHECK(tx.vout.size() == 3); - BOOST_CHECK_EQUAL(tx.vout[0].nValue, CAmount(1.23)); - BOOST_CHECK_EQUAL(tx.vout[1].nValue, CAmount(4.56)); - BOOST_CHECK_EQUAL(tx.vout[2].nValue, CAmount(7.89)); + BOOST_CHECK_EQUAL(tx.vout[0].nValue, 123000000); + BOOST_CHECK_EQUAL(tx.vout[1].nValue, 456000000); + BOOST_CHECK_EQUAL(tx.vout[2].nValue, 789000000); } // Test the perform_joinsplit methods. { // Dummy input so the operation object can be instantiated. - std::vector recipients = { SendManyRecipient(zaddr1, 0.0005, "ABCD") }; + std::vector recipients = { SendManyRecipient(zaddr1, 50000, "ABCD") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(boost::none, mtx, zaddr1, {}, recipients, 1) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); @@ -1425,7 +1425,7 @@ BOOST_AUTO_TEST_CASE(rpc_z_sendmany_taddr_to_sapling) auto builder = TransactionBuilder(consensusParams, nextBlockHeight, pwalletMain); mtx = CreateNewContextualCMutableTransaction(consensusParams, nextBlockHeight); - std::vector recipients = { SendManyRecipient(zaddr1, 1 * COIN, "ABCD") }; + std::vector recipients = { SendManyRecipient(zaddr1, 1*COIN, "ABCD") }; std::shared_ptr operation( new AsyncRPCOperation_sendmany(builder, mtx, taddr1, {}, recipients, 0) ); std::shared_ptr ptr = std::dynamic_pointer_cast (operation); From 4abd76f70eb2455a3869e8be93fb20baf28ca5a0 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 30 Jul 2020 11:15:52 +0100 Subject: [PATCH 04/21] depends: Use vendored Clang for macOS cross-compilation --- depends/packages/native_cctools.mk | 39 ++++++------------- depends/packages/native_clang.mk | 1 + .../patches/native_cctools/ignore-otool.diff | 24 ++++++++++++ 3 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 depends/patches/native_cctools/ignore-otool.diff diff --git a/depends/packages/native_cctools.mk b/depends/packages/native_cctools.mk index e883cbd49..5febaa3b9 100644 --- a/depends/packages/native_cctools.mk +++ b/depends/packages/native_cctools.mk @@ -4,11 +4,8 @@ $(package)_download_path=https://github.com/tpoechtrager/cctools-port/archive $(package)_file_name=$($(package)_version).tar.gz $(package)_sha256_hash=e51995a843533a3dac155dd0c71362dd471597a2d23f13dff194c6285362f875 $(package)_build_subdir=cctools -$(package)_clang_version=8.0.0 -$(package)_clang_download_path=https://releases.llvm.org/$($(package)_clang_version) -$(package)_clang_download_file=clang+llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz -$(package)_clang_file_name=clang-llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz -$(package)_clang_sha256_hash=9ef854b71949f825362a119bf2597f744836cb571131ae6b721cd102ffea8cd0 +$(package)_dependencies=native_clang +$(package)_patches=ignore-otool.diff $(package)_libtapi_version=3efb201881e7a76a21e0554906cf306432539cef $(package)_libtapi_download_path=https://github.com/tpoechtrager/apple-libtapi/archive @@ -16,45 +13,41 @@ $(package)_libtapi_download_file=$($(package)_libtapi_version).tar.gz $(package)_libtapi_file_name=$($(package)_libtapi_version).tar.gz $(package)_libtapi_sha256_hash=380c1ca37cfa04a8699d0887a8d3ee1ad27f3d08baba78887c73b09485c0fbd3 -$(package)_extra_sources=$($(package)_clang_file_name) $(package)_extra_sources += $($(package)_libtapi_file_name) define $(package)_fetch_cmds $(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ -$(call fetch_file,$(package),$($(package)_clang_download_path),$($(package)_clang_download_file),$($(package)_clang_file_name),$($(package)_clang_sha256_hash)) && \ $(call fetch_file,$(package),$($(package)_libtapi_download_path),$($(package)_libtapi_download_file),$($(package)_libtapi_file_name),$($(package)_libtapi_sha256_hash)) endef define $(package)_extract_cmds mkdir -p $($(package)_extract_dir) && \ echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - echo "$($(package)_clang_sha256_hash) $($(package)_source_dir)/$($(package)_clang_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ echo "$($(package)_libtapi_sha256_hash) $($(package)_source_dir)/$($(package)_libtapi_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - mkdir -p toolchain/bin toolchain/lib/clang/$($(package)_clang_version)/include && \ mkdir -p libtapi && \ tar --no-same-owner --strip-components=1 -C libtapi -xf $($(package)_source_dir)/$($(package)_libtapi_file_name) && \ - tar --no-same-owner --strip-components=1 -C toolchain -xf $($(package)_source_dir)/$($(package)_clang_file_name) && \ - rm -f toolchain/lib/libc++abi.so* && \ tar --no-same-owner --strip-components=1 -xf $($(package)_source) endef define $(package)_set_vars $(package)_config_opts=--target=$(host) --with-libtapi=$($(package)_extract_dir) $(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib - $(package)_config_opts+=--enable-lto-support --with-llvm-config=$($(package)_extract_dir)/toolchain/bin/llvm-config - $(package)_cc=$($(package)_extract_dir)/toolchain/bin/clang - $(package)_cxx=$($(package)_extract_dir)/toolchain/bin/clang++ + $(package)_config_opts+=--enable-lto-support --with-llvm-config=$(build_prefix)/bin/llvm-config + $(package)_cc=$(build_prefix)/bin/clang + $(package)_cxx=$(build_prefix)/bin/clang++ endef define $(package)_preprocess_cmds - CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ./libtapi/build.sh && \ - CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ./libtapi/install.sh && \ - sed -i.old "/define HAVE_PTHREADS/d" $($(package)_build_subdir)/ld64/src/ld/InputFiles.h + patch -p1 < $($(package)_patch_dir)/ignore-otool.diff && \ + cd $($(package)_build_subdir); DO_NOT_UPDATE_CONFIG_SCRIPTS=1 ./autogen.sh endef define $(package)_config_cmds - $($(package)_autoconf) + rm -f $(build_prefix)/lib/libc++abi.so* && \ + CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ../libtapi/build.sh && \ + CC=$($(package)_cc) CXX=$($(package)_cxx) INSTALLPREFIX=$($(package)_extract_dir) ../libtapi/install.sh && \ + $($(package)_config_env) $($(package)_autoconf) endef define $(package)_build_cmds @@ -65,13 +58,5 @@ define $(package)_stage_cmds $(MAKE) DESTDIR=$($(package)_staging_dir) install && \ mkdir -p $($(package)_staging_prefix_dir)/lib/ && \ cd $($(package)_extract_dir) && \ - cp lib/libtapi.so.6 $($(package)_staging_prefix_dir)/lib/ && \ - cd $($(package)_extract_dir)/toolchain && \ - mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include && \ - mkdir -p $($(package)_staging_prefix_dir)/bin $($(package)_staging_prefix_dir)/include && \ - cp bin/clang $($(package)_staging_prefix_dir)/bin/ &&\ - cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ &&\ - cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \ - cp -rf lib/clang/$($(package)_clang_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include/ && \ - cp bin/dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil + cp lib/libtapi.so.6 $($(package)_staging_prefix_dir)/lib/ endef diff --git a/depends/packages/native_clang.mk b/depends/packages/native_clang.mk index 7df7f05d0..88c57d39c 100644 --- a/depends/packages/native_clang.mk +++ b/depends/packages/native_clang.mk @@ -20,6 +20,7 @@ define $(package)_stage_cmds mkdir -p $($(package)_staging_prefix_dir)/bin && \ cp bin/clang-$($(package)_major_version) $($(package)_staging_prefix_dir)/bin && \ cp bin/llvm-ar $($(package)_staging_prefix_dir)/bin && \ + cp bin/llvm-config $($(package)_staging_prefix_dir)/bin && \ cp bin/llvm-nm $($(package)_staging_prefix_dir)/bin && \ cp bin/llvm-objcopy $($(package)_staging_prefix_dir)/bin && \ cp -P bin/clang $($(package)_staging_prefix_dir)/bin && \ diff --git a/depends/patches/native_cctools/ignore-otool.diff b/depends/patches/native_cctools/ignore-otool.diff new file mode 100644 index 000000000..fdb348ede --- /dev/null +++ b/depends/patches/native_cctools/ignore-otool.diff @@ -0,0 +1,24 @@ +diff -ur cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/Makefile.am cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/Makefile.am +--- cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/Makefile.am 2020-07-30 15:01:05.680000000 +0100 ++++ cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/Makefile.am 2020-07-30 15:01:34.900000000 +0100 +@@ -1,7 +1,7 @@ + if ISDARWIN +-SUBDIRS=libstuff libmacho ar as misc otool efitools ld64 man ++SUBDIRS=libstuff libmacho ar as misc efitools ld64 man + else +-SUBDIRS=libobjc2 libstuff libmacho ar as misc otool efitools ld64 man ++SUBDIRS=libobjc2 libstuff libmacho ar as misc efitools ld64 man + endif + + ACLOCAL_AMFLAGS = -I m4 +diff -ur cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/configure.ac cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/configure.ac +--- cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97-orig/cctools/configure.ac 2020-07-30 15:01:05.680000000 +0100 ++++ cctools-port-55562e4073dea0fbfd0b20e0bf69ffe6390c7f97/cctools/configure.ac 2020-07-30 15:01:47.330000000 +0100 +@@ -466,7 +466,6 @@ + AC_CONFIG_FILES([as/ppc64/Makefile]) + AC_CONFIG_FILES([man/Makefile]) + AC_CONFIG_FILES([misc/Makefile]) +-AC_CONFIG_FILES([otool/Makefile]) + AC_CONFIG_FILES([efitools/Makefile]) + AC_CONFIG_FILES([libobjc2/Makefile]) + AC_CONFIG_FILES([ld64/Makefile]) From ff4cb00cb242f80b52415adfe2f9ceb9736f3931 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 10 Aug 2020 13:41:03 +0100 Subject: [PATCH 05/21] depends: Vendor LLD and use it for linking We don't specify it for macOS, as we already pin a specific SDK there. --- depends/hosts/freebsd.mk | 2 ++ depends/hosts/linux.mk | 2 ++ depends/hosts/mingw32.mk | 2 ++ depends/packages/native_clang.mk | 4 ++++ zcutil/build.sh | 1 - 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/depends/hosts/freebsd.mk b/depends/hosts/freebsd.mk index 56fe3da89..6ddb49918 100644 --- a/depends/hosts/freebsd.mk +++ b/depends/hosts/freebsd.mk @@ -9,6 +9,8 @@ freebsd_debug_CXXFLAGS=$(freebsd_debug_CFLAGS) freebsd_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC +freebsd_LDFLAGS?=-fuse-ld=lld + i686_freebsd_CC=$(default_host_CC) -m32 i686_freebsd_CXX=$(default_host_CXX) -m32 x86_64_freebsd_CC=$(default_host_CC) -m64 diff --git a/depends/hosts/linux.mk b/depends/hosts/linux.mk index 72e45cd8a..be6525e2c 100644 --- a/depends/hosts/linux.mk +++ b/depends/hosts/linux.mk @@ -9,6 +9,8 @@ linux_debug_CXXFLAGS=$(linux_debug_CFLAGS) linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC +linux_LDFLAGS?=-fuse-ld=lld + i686_linux_CC=$(default_host_CC) -m32 i686_linux_CXX=$(default_host_CXX) -m32 x86_64_linux_CC=$(default_host_CC) -m64 diff --git a/depends/hosts/mingw32.mk b/depends/hosts/mingw32.mk index 2248973a1..d84284480 100644 --- a/depends/hosts/mingw32.mk +++ b/depends/hosts/mingw32.mk @@ -1,6 +1,8 @@ mingw32_CFLAGS=-pipe mingw32_CXXFLAGS=$(mingw32_CFLAGS) +mingw32_LDFLAGS?=-fuse-ld=lld + mingw32_release_CFLAGS=-O1 mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS) diff --git a/depends/packages/native_clang.mk b/depends/packages/native_clang.mk index 88c57d39c..dfef49f66 100644 --- a/depends/packages/native_clang.mk +++ b/depends/packages/native_clang.mk @@ -19,12 +19,16 @@ endif define $(package)_stage_cmds mkdir -p $($(package)_staging_prefix_dir)/bin && \ cp bin/clang-$($(package)_major_version) $($(package)_staging_prefix_dir)/bin && \ + cp bin/lld $($(package)_staging_prefix_dir)/bin && \ cp bin/llvm-ar $($(package)_staging_prefix_dir)/bin && \ cp bin/llvm-config $($(package)_staging_prefix_dir)/bin && \ cp bin/llvm-nm $($(package)_staging_prefix_dir)/bin && \ cp bin/llvm-objcopy $($(package)_staging_prefix_dir)/bin && \ cp -P bin/clang $($(package)_staging_prefix_dir)/bin && \ cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/ld.lld $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/ld64.lld $($(package)_staging_prefix_dir)/bin && \ + cp -P bin/lld-link $($(package)_staging_prefix_dir)/bin && \ cp -P bin/llvm-ranlib $($(package)_staging_prefix_dir)/bin && \ cp -P bin/llvm-strip $($(package)_staging_prefix_dir)/bin && \ mv include/ $($(package)_staging_prefix_dir) && \ diff --git a/zcutil/build.sh b/zcutil/build.sh index 95ebd4e39..f49cfc596 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -67,7 +67,6 @@ set -x eval "$MAKE" --version as --version -ld -v HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ From 1b963478679d408df17f0847c2f00fbfac8bc8f3 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 12 Oct 2020 18:06:56 +0100 Subject: [PATCH 06/21] depends: Add libc++ as a dependency For mingw32: - We use the binaries provided by MSYS2, which do not go back as far as libc++ 8. We use libc++ 9 here, matching the LLVM version we will be switching to in a subsequent commit (to match the LLVM version used by Rust 1.44). We manually specify the path to the libc++ headers, because they don't match the headers used by Clang itself. - We now require at least mingw-w64 6.0.0, which fixes two Clang compilation bugs: - https://github.com/mirror/mingw-w64/commit/1bd66b53be1b4da7e6679d01d2626c1d9bdc989f - https://github.com/mirror/mingw-w64/commit/82b169c5734a6198d3b4c51a48f82e7b7104f143 Darwin is ignored, as the Xcode SDK includes libc++. For all other targets, we use the static libraries included in Clang releases. We reuse the files we downloaded in native_clang for native compilation, instead of fetching the archive twice. --- depends/funcs.mk | 6 +-- depends/hosts/mingw32.mk | 2 +- depends/packages/libcxx.mk | 73 ++++++++++++++++++++++++++++++++++++ depends/packages/packages.mk | 5 +++ 4 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 depends/packages/libcxx.mk diff --git a/depends/funcs.mk b/depends/funcs.mk index 37009e447..0649fae1c 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -46,9 +46,9 @@ $(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SU final_build_id_long+=$($(package)_build_id_long) #override platform specific files and hashes -$(eval $(1)_file_name=$(if $($(1)_exact_file_name),$($(1)_exact_file_name),$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name)))) -$(eval $(1)_sha256_hash=$(if $($(1)_exact_sha256_hash),$($(1)_exact_sha256_hash),$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash)))) -$(eval $(1)_download_file=$(if $($(1)_exact_download_file),$($(1)_exact_download_file),$(if $($(1)_download_file_$(host_os)),$($(1)_download_file_$(host_os)),$(if $($(1)_download_file),$($(1)_download_file),$($(1)_file_name))))) +$(eval $(1)_file_name=$(if $($(1)_exact_file_name),$($(1)_exact_file_name),$(if $($(1)_file_name_$(host_arch)_$(host_os)),$($(1)_file_name_$(host_arch)_$(host_os)),$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name))))) +$(eval $(1)_sha256_hash=$(if $($(1)_exact_sha256_hash),$($(1)_exact_sha256_hash),$(if $($(1)_sha256_hash_$(host_arch)_$(host_os)),$($(1)_sha256_hash_$(host_arch)_$(host_os)),$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash))))) +$(eval $(1)_download_file=$(if $($(1)_exact_download_file),$($(1)_exact_download_file),$(if $($(1)_download_file_$(host_arch)_$(host_os)),$($(1)_download_file_$(host_arch)_$(host_os)),$(if $($(1)_download_file_$(host_os)),$($(1)_download_file_$(host_os)),$(if $($(1)_download_file),$($(1)_download_file),$($(1)_file_name)))))) #compute package-specific paths $(1)_build_subdir?=. diff --git a/depends/hosts/mingw32.mk b/depends/hosts/mingw32.mk index d84284480..ed1910e66 100644 --- a/depends/hosts/mingw32.mk +++ b/depends/hosts/mingw32.mk @@ -1,5 +1,5 @@ mingw32_CFLAGS=-pipe -mingw32_CXXFLAGS=$(mingw32_CFLAGS) +mingw32_CXXFLAGS=$(mingw32_CFLAGS) -isystem $(host_prefix)/include/c++/v1 mingw32_LDFLAGS?=-fuse-ld=lld diff --git a/depends/packages/libcxx.mk b/depends/packages/libcxx.mk new file mode 100644 index 000000000..18df88905 --- /dev/null +++ b/depends/packages/libcxx.mk @@ -0,0 +1,73 @@ +package=libcxx +$(package)_version=$(native_clang_version) + +ifneq ($(canonical_host),$(build)) +ifneq ($(host_os),mingw32) +# Clang is provided pre-compiled for a bunch of targets; fetch the one we need +# and stage its copies of the static libraries. +$(package)_download_path=https://releases.llvm.org/$($(package)_version) +$(package)_download_file_aarch64_linux=clang+llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz +$(package)_file_name_aarch64_linux=clang-llvm-$($(package)_version)-aarch64-linux-gnu.tar.xz +$(package)_sha256_hash_aarch64_linux=998e9ae6e89bd3f029ed031ad9355c8b43441302c0e17603cf1de8ee9939e5c9 +$(package)_download_file_linux=clang+llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_file_name_linux=clang-llvm-$($(package)_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_sha256_hash_linux=9ef854b71949f825362a119bf2597f744836cb571131ae6b721cd102ffea8cd0 + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + cp lib/libc++.a $($(package)_staging_prefix_dir)/lib && \ + cp lib/libc++abi.a $($(package)_staging_prefix_dir)/lib +endef + +else +# For Windows cross-compilation, use the MSYS2 binaries. +$(package)_download_path=http://repo.msys2.org/mingw/x86_64 +$(package)_download_file=mingw-w64-x86_64-libc++-9.0.1-1-any.pkg.tar.xz +$(package)_file_name=mingw-w64-x86_64-libcxx-9.0.1-1-any.pkg.tar.xz +$(package)_sha256_hash=04e77c5d0e3a9efc9cc8ca3b6549af9a9eef6e20d53076295efbdfba76c5f5de + +$(package)_libcxxabi_download_file=mingw-w64-x86_64-libc++abi-9.0.1-1-any.pkg.tar.xz +$(package)_libcxxabi_file_name=mingw-w64-x86_64-libc++abi-9.0.1-1-any.pkg.tar.xz +$(package)_libcxxabi_sha256_hash=e8a38084dc05c9f6bd4ded4fe1cdbbe16f7280d66426a76b2c3c23d0575aad5c + +$(package)_extra_sources += $($(package)_libcxxabi_file_name) + +define $(package)_fetch_cmds +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_libcxxabi_download_file),$($(package)_libcxxabi_file_name),$($(package)_libcxxabi_sha256_hash)) +endef + +define $(package)_extract_cmds + mkdir -p $($(package)_extract_dir) && \ + echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_libcxxabi_sha256_hash) $($(package)_source_dir)/$($(package)_libcxxabi_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + mkdir -p libcxxabi && \ + tar --no-same-owner --strip-components=1 -C libcxxabi -xf $($(package)_source_dir)/$($(package)_libcxxabi_file_name) && \ + tar --no-same-owner --strip-components=1 -xf $($(package)_source) +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + mv include/ $($(package)_staging_prefix_dir) && \ + cp lib/libc++.a $($(package)_staging_prefix_dir)/lib && \ + cp libcxxabi/lib/libc++abi.a $($(package)_staging_prefix_dir)/lib +endef +endif + +else +# For native compilation, use the static libraries from native_clang. +# We explicitly stage them so that subsequent dependencies don't link to the +# shared libraries distributed with Clang. +define $(package)_fetch_cmds +endef + +define $(package)_extract_cmds +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/lib && \ + cp $(build_prefix)/lib/libc++.a $($(package)_staging_prefix_dir)/lib && \ + cp $(build_prefix)/lib/libc++abi.a $($(package)_staging_prefix_dir)/lib +endef +endif diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index b176fdfe9..3ab9925c7 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -7,3 +7,8 @@ wallet_packages=bdb ifneq ($(build_os),darwin) darwin_native_packages=native_cctools endif + +# We use a complete SDK for Darwin, which includes libc++. +ifneq ($(host_os),darwin) +packages += libcxx +endif From 0887f64c90885fac22c24548c82666c352292a46 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 12 Oct 2020 20:25:24 +0100 Subject: [PATCH 07/21] depends: Don't replace default CXXFLAGS in C++ dependencies --- depends/packages/bdb.mk | 2 +- depends/packages/boost.mk | 2 +- depends/packages/zeromq.mk | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index e507b90a9..50284954c 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -15,7 +15,7 @@ ifneq ($(build_os),darwin) $(package)_config_opts_darwin=--disable-atomicsupport endif $(package)_config_opts_aarch64=--disable-atomicsupport -$(package)_cxxflags=-std=c++11 +$(package)_cxxflags+=-std=c++11 endef define $(package)_preprocess_cmds diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 2fe4232f7..530da8447 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -21,7 +21,7 @@ $(package)_archiver_$(host_os)=$($(package)_ar) $(package)_toolset_darwin=darwin $(package)_archiver_darwin=$($(package)_libtool) $(package)_config_libraries=chrono,filesystem,program_options,system,thread,test -$(package)_cxxflags=-std=c++11 -fvisibility=hidden +$(package)_cxxflags+=-std=c++11 -fvisibility=hidden $(package)_cxxflags_linux=-fPIC $(package)_cxxflags_freebsd=-fPIC endef diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index e205e9243..546af6789 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -11,7 +11,7 @@ define $(package)_set_vars $(package)_config_opts += --disable-drafts --enable-option-checking $(package)_config_opts_linux=--with-pic $(package)_config_opts_freebsd=--with-pic - $(package)_cxxflags=-std=c++11 + $(package)_cxxflags+=-std=c++11 endef define $(package)_config_cmds From fa54a1661a70724772f47add88ece12432cafc39 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 12 Oct 2020 20:47:47 +0100 Subject: [PATCH 08/21] depends: Add multilib paths for Linux cross-compile --- depends/hosts/linux.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/depends/hosts/linux.mk b/depends/hosts/linux.mk index be6525e2c..fb2db9b76 100644 --- a/depends/hosts/linux.mk +++ b/depends/hosts/linux.mk @@ -15,3 +15,11 @@ i686_linux_CC=$(default_host_CC) -m32 i686_linux_CXX=$(default_host_CXX) -m32 x86_64_linux_CC=$(default_host_CC) -m64 x86_64_linux_CXX=$(default_host_CXX) -m64 + +# Clang doesn't appear to find these multilib paths by default, +# so help it out if we are cross-compiling. +ifneq ($(canonical_host),$(build)) + # CFLAGS is copied to CXXFLAGS after it is fully-evaluated. + linux_CFLAGS += -idirafter /usr/$(host)/include + linux_LDFLAGS += -L/usr/$(host)/lib +endif From 5ca4fbf8f6890c2702a499679625c231867019ff Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 12 Oct 2020 20:48:33 +0100 Subject: [PATCH 09/21] build: Statically link libc++ --- depends/config.site.in | 2 +- depends/packages/bdb.mk | 5 +++++ depends/packages/boost.mk | 5 +++++ depends/packages/googletest.mk | 5 +++++ depends/packages/zeromq.mk | 5 +++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/depends/config.site.in b/depends/config.site.in index dbcb7a6e4..2947db997 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -32,7 +32,7 @@ export PKG_CONFIG_LIBDIR=$depends_prefix/lib/pkgconfig export PKG_CONFIG_PATH=$depends_prefix/share/pkgconfig CPPFLAGS="-I$depends_prefix/include/ $CPPFLAGS" -LDFLAGS="-L$depends_prefix/lib $LDFLAGS" +LDFLAGS="-L$depends_prefix/lib $LDFLAGS -static-libstdc++ -lc++abi" CC="@CC@" CXX="@CXX@" diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 50284954c..c450707a0 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -6,6 +6,10 @@ $(package)_sha256_hash=47612c8991aa9ac2f6be721267c8d3cdccf5ac83105df8e50809daea2 $(package)_build_subdir=build_unix $(package)_patches=winioctl-and-atomic_init_db.patch +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif + define $(package)_set_vars $(package)_config_opts=--disable-shared --enable-cxx --disable-replication --enable-option-checking $(package)_config_opts_mingw32=--enable-mingw @@ -16,6 +20,7 @@ $(package)_config_opts_darwin=--disable-atomicsupport endif $(package)_config_opts_aarch64=--disable-atomicsupport $(package)_cxxflags+=-std=c++11 +$(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_preprocess_cmds diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 530da8447..b4377bd30 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -5,6 +5,10 @@ $(package)_file_name=$(package)_$($(package)_version).tar.bz2 $(package)_sha256_hash=83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1 $(package)_patches=signals2-noise.patch +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif + define $(package)_set_vars $(package)_config_opts_release=variant=release $(package)_config_opts_debug=variant=debug @@ -24,6 +28,7 @@ $(package)_config_libraries=chrono,filesystem,program_options,system,thread,test $(package)_cxxflags+=-std=c++11 -fvisibility=hidden $(package)_cxxflags_linux=-fPIC $(package)_cxxflags_freebsd=-fPIC +$(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_preprocess_cmds diff --git a/depends/packages/googletest.mk b/depends/packages/googletest.mk index c9cbe9961..32e1d286c 100644 --- a/depends/packages/googletest.mk +++ b/depends/packages/googletest.mk @@ -5,10 +5,15 @@ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_download_file=release-$($(package)_version).tar.gz $(package)_sha256_hash=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif + define $(package)_set_vars $(package)_cxxflags+=-std=c++11 $(package)_cxxflags_linux=-fPIC $(package)_cxxflags_freebsd=-fPIC +$(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_build_cmds diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 546af6789..0995f122f 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -4,6 +4,10 @@ $(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=9d9285db37ae942ed0780c016da87060497877af45094ff9e1a1ca736e3875a2 +ifneq ($(host_os),darwin) +$(package)_dependencies=libcxx +endif + define $(package)_set_vars $(package)_config_opts=--without-docs --disable-shared --disable-curve --disable-curve-keygen --disable-perf $(package)_config_opts += --without-libgssapi_krb5 --without-pgm --without-norm --without-vmci @@ -12,6 +16,7 @@ define $(package)_set_vars $(package)_config_opts_linux=--with-pic $(package)_config_opts_freebsd=--with-pic $(package)_cxxflags+=-std=c++11 + $(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_config_cmds From 2ca72adf8befc3af78ca71a608cc3e15694d32fb Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Mon, 12 Oct 2020 20:48:50 +0100 Subject: [PATCH 10/21] build: Add missing LIBUNIVALUE to Makefile.bench.include LDADD --- src/Makefile.bench.include | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index 13c3b3284..4a1dcab3e 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -35,6 +35,7 @@ bench_bench_bitcoin_LDADD = \ $(LIBLEVELDB_SSE42) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ + $(LIBUNIVALUE) \ $(LIBZCASH) \ $(LIBRUSTZCASH) From 3973a163588c6a432db3aaa0732f8e9bbce03ef5 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 13 Oct 2020 13:55:44 +0100 Subject: [PATCH 11/21] depends: Fix "unused variables" warning when compiling zeromq for Windows Clang triggers that warning, which becomes an error due to -Werror. --- depends/packages/zeromq.mk | 5 +++++ .../zeromq/windows-unused-variables.diff | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 depends/patches/zeromq/windows-unused-variables.diff diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk index 0995f122f..1124dd574 100644 --- a/depends/packages/zeromq.mk +++ b/depends/packages/zeromq.mk @@ -3,6 +3,7 @@ $(package)_version=4.3.3 $(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/ $(package)_file_name=$(package)-$($(package)_version).tar.gz $(package)_sha256_hash=9d9285db37ae942ed0780c016da87060497877af45094ff9e1a1ca736e3875a2 +$(package)_patches=windows-unused-variables.diff ifneq ($(host_os),darwin) $(package)_dependencies=libcxx @@ -19,6 +20,10 @@ define $(package)_set_vars $(package)_ldflags+=-static-libstdc++ -lc++abi endef +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/windows-unused-variables.diff +endef + define $(package)_config_cmds $($(package)_autoconf) endef diff --git a/depends/patches/zeromq/windows-unused-variables.diff b/depends/patches/zeromq/windows-unused-variables.diff new file mode 100644 index 000000000..f013bab60 --- /dev/null +++ b/depends/patches/zeromq/windows-unused-variables.diff @@ -0,0 +1,17 @@ +diff -ur zeromq-4.3.3-orig/src/clock.cpp zeromq-4.3.3/src/clock.cpp +--- zeromq-4.3.3-orig/src/clock.cpp 2020-10-13 13:44:04.190000000 +0100 ++++ zeromq-4.3.3/src/clock.cpp 2020-10-13 13:47:04.170000000 +0100 +@@ -126,9 +126,13 @@ + init_compatible_get_tick_count64 (); + #endif + ++#ifndef ZMQ_HAVE_WINDOWS + const uint64_t usecs_per_msec = 1000; ++#endif + const uint64_t usecs_per_sec = 1000000; ++#ifndef ZMQ_HAVE_WINDOWS + const uint64_t nsecs_per_usec = 1000; ++#endif + + zmq::clock_t::clock_t () : + _last_tsc (rdtsc ()), From c691a8413f650b162f968ab8dc5290e189a42c5e Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 13 Oct 2020 15:23:41 +0100 Subject: [PATCH 12/21] depends: Rename Boost libraries to follow MinGW/GCC convention Boost uses the MSVC naming convention when building Windows libraries, which causes issues with lld. --- depends/packages/boost.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index b4377bd30..4d2d6a93e 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -47,3 +47,12 @@ endef define $(package)_stage_cmds ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install endef + +# Boost uses the MSVC convention of libboost_foo.lib as the naming pattern when +# compiling for Windows, even though we use MinGW which follows the libfoo.a +# convention. This causes issues with lld, so we rename all .lib files to .a. +ifeq ($(host_os),mingw32) +define $(package)_postprocess_cmds + for f in lib/*.lib; do mv -- "$$$$f" "$$$${f%.lib}.a"; done +endef +endif From ab4033c49c2696e063eb9385c9b402a15696a5ec Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 13 Oct 2020 16:33:25 +0100 Subject: [PATCH 13/21] depends: Fix boost::iostreams usage on Windows with libc++ Fixed upstream (but not yet in a Boost release): https://github.com/boostorg/iostreams/pull/106 --- depends/packages/boost.mk | 3 ++- depends/patches/boost/iostreams-106.patch | 25 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 depends/patches/boost/iostreams-106.patch diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 4d2d6a93e..1b4ec97e8 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -3,7 +3,7 @@ $(package)_version=1_74_0 $(package)_download_path=https://dl.bintray.com/boostorg/release/1.74.0/source $(package)_file_name=$(package)_$($(package)_version).tar.bz2 $(package)_sha256_hash=83bfc1507731a0906e387fc28b7ef5417d591429e51e788417fe9ff025e116b1 -$(package)_patches=signals2-noise.patch +$(package)_patches=iostreams-106.patch signals2-noise.patch ifneq ($(host_os),darwin) $(package)_dependencies=libcxx @@ -32,6 +32,7 @@ $(package)_ldflags+=-static-libstdc++ -lc++abi endef define $(package)_preprocess_cmds + patch -p2 < $($(package)_patch_dir)/iostreams-106.patch && \ patch -p2 < $($(package)_patch_dir)/signals2-noise.patch endef diff --git a/depends/patches/boost/iostreams-106.patch b/depends/patches/boost/iostreams-106.patch new file mode 100644 index 000000000..dcecd5d0d --- /dev/null +++ b/depends/patches/boost/iostreams-106.patch @@ -0,0 +1,25 @@ +From 4e76f73826fd0a7067b837e4850a9051436f5ec5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= + +Date: Sun, 22 Dec 2019 10:26:38 +0100 +Subject: [PATCH] Fix build on windows with libc++ + +Proposed by @SquallATF in #67 +--- + include/boost/iostreams/detail/config/fpos.hpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/include/boost/iostreams/detail/config/fpos.hpp b/include/boost/iostreams/detail/config/fpos.hpp +index c5dc6cf59..a5835421f 100644 +--- a/include/boost/iostreams/detail/config/fpos.hpp ++++ b/include/boost/iostreams/detail/config/fpos.hpp +@@ -26,7 +26,8 @@ + + # if (defined(_YVALS) || defined(_CPPLIB_VER)) && !defined(__SGI_STL_PORT) && \ + !defined(_STLPORT_VERSION) && !defined(__QNX__) && !defined(_VX_CPU) && !defined(__VXWORKS__) \ +- && !((defined(BOOST_MSVC) || defined(BOOST_CLANG)) && _MSVC_STL_VERSION >= 141) ++ && !((defined(BOOST_MSVC) || defined(BOOST_CLANG)) && _MSVC_STL_VERSION >= 141) \ ++ && !defined(_LIBCPP_VERSION) + /**/ + + #include From e917cb614f24330d8e6ef45d3d30e522ce5cc3ba Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 13 Oct 2020 17:17:26 +0100 Subject: [PATCH 14/21] build: Compile secp256k1 with C99 The secp256k1 library is intended to be C89-compatible. Targeting both C89 and MinGW with Clang triggers this bug that is fixed in MinGW 8.0.0: https://github.com/mirror/mingw-w64/commit/bedff472afbf8b75331d06b6d3b5f41f2a7b02c7 Rather than requiring MinGW 8, we compile secp256k1 targeting C99. --- src/secp256k1/configure.ac | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/secp256k1/configure.ac b/src/secp256k1/configure.ac index e5fcbcb4e..9eeab51f0 100644 --- a/src/secp256k1/configure.ac +++ b/src/secp256k1/configure.ac @@ -25,9 +25,9 @@ fi AM_PROG_CC_C_O -AC_PROG_CC_C89 -if test x"$ac_cv_prog_cc_c89" = x"no"; then - AC_MSG_ERROR([c89 compiler support required]) +AC_PROG_CC_C99 +if test x"$ac_cv_prog_cc_c99" = x"no"; then + AC_MSG_ERROR([c99 compiler support required]) fi AM_PROG_AS @@ -65,7 +65,7 @@ esac CFLAGS="$CFLAGS -W" -warn_CFLAGS="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" +warn_CFLAGS="-std=c99 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings" saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $warn_CFLAGS" AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}]) From 5a1e6853c18bc4741c35918f1fb0c96854122be7 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 13 Oct 2020 19:38:40 +0100 Subject: [PATCH 15/21] build: Add -lpthread to univalue test LDFLAGS Fixes missing symbols when running the univalue test suite. --- src/univalue/Makefile.am | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/univalue/Makefile.am b/src/univalue/Makefile.am index 0f5ba5995..49c4e7c6f 100644 --- a/src/univalue/Makefile.am +++ b/src/univalue/Makefile.am @@ -41,22 +41,22 @@ TEST_DATA_DIR=test test_unitester_SOURCES = test/unitester.cpp test_unitester_LDADD = libunivalue.la test_unitester_CXXFLAGS = -I$(top_srcdir)/include -DJSON_TEST_SRC=\"$(srcdir)/$(TEST_DATA_DIR)\" -test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_unitester_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread test_test_json_SOURCES = test/test_json.cpp test_test_json_LDADD = libunivalue.la test_test_json_CXXFLAGS = -I$(top_srcdir)/include -test_test_json_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_test_json_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread test_no_nul_SOURCES = test/no_nul.cpp test_no_nul_LDADD = libunivalue.la test_no_nul_CXXFLAGS = -I$(top_srcdir)/include -test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_no_nul_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread test_object_SOURCES = test/object.cpp test_object_LDADD = libunivalue.la test_object_CXXFLAGS = -I$(top_srcdir)/include -test_object_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) +test_object_LDFLAGS = -static $(LIBTOOL_APP_LDFLAGS) -lpthread TEST_FILES = \ $(TEST_DATA_DIR)/fail10.json \ From bf450b26072568fa4387225edd98b8a2f44b2ccd Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 14 Oct 2020 21:52:32 +0100 Subject: [PATCH 16/21] qa: Disable FORTIFY_SOURCE checks FORTIFY_SOURCE does mostly nothing for Clang before 10, which we don't pin yet (and won't before we next upgrade Rust). --- qa/zcash/full_test_suite.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qa/zcash/full_test_suite.py b/qa/zcash/full_test_suite.py index 621197654..3fe2df08a 100755 --- a/qa/zcash/full_test_suite.py +++ b/qa/zcash/full_test_suite.py @@ -78,11 +78,13 @@ def check_security_hardening(): # NOTE: checksec.sh does not reliably determine whether FORTIFY_SOURCE # is enabled for the entire binary. See issue #915. - ret &= test_fortify_source('src/zcashd') - ret &= test_fortify_source('src/zcash-cli') - ret &= test_fortify_source('src/zcash-gtest') - ret &= test_fortify_source('src/zcash-tx') - ret &= test_fortify_source('src/test/test_bitcoin') + # FORTIFY_SOURCE does mostly nothing for Clang before 10, which we don't + # pin yet, so we disable these tests. + # ret &= test_fortify_source('src/zcashd') + # ret &= test_fortify_source('src/zcash-cli') + # ret &= test_fortify_source('src/zcash-gtest') + # ret &= test_fortify_source('src/zcash-tx') + # ret &= test_fortify_source('src/test/test_bitcoin') return ret From ea7d57aa4718a512f6e40a3dea0265d77c4aff5d Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 16 Oct 2020 15:10:20 +0100 Subject: [PATCH 17/21] QA: Add native_clang and libcxx to updatecheck.py --- qa/zcash/postponed-updates.txt | 17 +++++++++++++++++ qa/zcash/updatecheck.py | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/qa/zcash/postponed-updates.txt b/qa/zcash/postponed-updates.txt index 6cd530758..fa4a0a43d 100644 --- a/qa/zcash/postponed-updates.txt +++ b/qa/zcash/postponed-updates.txt @@ -4,6 +4,23 @@ # bdb 18.1.40 2020-09-01 # +# Clang is pinned to a version that matches the Rust version. +# This will be Clang 9 intially, which we are postponing until after the +# initial Clang PR is merged. +# libc++ is pinned to the same version as Clang. +native_clang 8.0.1 2020-11-01 +native_clang 9.0.0 2020-11-01 +native_clang 9.0.1 2020-11-01 +native_clang 10.0.0 2021-01-20 +native_clang 10.0.1 2021-01-20 +native_clang 11.0.0 2021-01-20 +libcxx 8.0.1 2020-11-01 +libcxx 9.0.0 2020-11-01 +libcxx 9.0.1 2020-11-01 +libcxx 10.0.0 2021-01-20 +libcxx 10.0.1 2021-01-20 +libcxx 11.0.0 2021-01-20 + bdb 18.1.40 2021-01-20 native_rust 1.45.0 2021-01-20 native_rust 1.45.1 2021-01-20 diff --git a/qa/zcash/updatecheck.py b/qa/zcash/updatecheck.py index 30edf9883..38ae8761f 100755 --- a/qa/zcash/updatecheck.py +++ b/qa/zcash/updatecheck.py @@ -57,6 +57,11 @@ def get_dependency_list(): GithubTagReleaseLister("google", "googletest", "^release-(\d+)\.(\d+)\.(\d+)$", { "release-1.8.1": (1, 8, 1) }), DependsVersionGetter("googletest")), + # libc++ matches the Clang version + Dependency("libcxx", + GithubTagReleaseLister("llvm", "llvm-project", "^llvmorg-(\d+)\.(\d+).(\d+)$", + { "llvmorg-11.0.0": (11, 0, 0), "llvmorg-9.0.1-rc3": None}), + DependsVersionGetter("native_clang")), Dependency("libevent", GithubTagReleaseLister("libevent", "libevent", "^release-(\d+)\.(\d+)\.(\d+)-stable$", { "release-2.0.22-stable": (2, 0, 22), "release-2.1.9-beta": None }), @@ -69,6 +74,10 @@ def get_dependency_list(): GithubTagReleaseLister("ccache", "ccache", "^v?(\d+)\.(\d+)(?:\.(\d+))?$", { "v3.5.1": (3, 5, 1), "v3.6": (3, 6)}), DependsVersionGetter("native_ccache")), + Dependency("native_clang", + GithubTagReleaseLister("llvm", "llvm-project", "^llvmorg-(\d+)\.(\d+).(\d+)$", + { "llvmorg-11.0.0": (11, 0, 0), "llvmorg-9.0.1-rc3": None}), + DependsVersionGetter("native_clang")), Dependency("native_rust", GithubTagReleaseLister("rust-lang", "rust", "^(\d+)\.(\d+)(?:\.(\d+))?$", { "1.33.0": (1, 33, 0), "0.9": (0, 9) }), From 11baa4d49da47e22c60a5b07382fa9f6bad582be Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 16 Oct 2020 16:48:56 +0100 Subject: [PATCH 18/21] doc: Add Clang and libc++ migration to release notes --- doc/release-notes.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/release-notes.md b/doc/release-notes.md index a29094b51..dbbc76796 100644 --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -4,3 +4,21 @@ release-notes at release time) Notable changes =============== +Migration to Clang and static libc++ +------------------------------------ + +`zcashd` now builds its C++ (and C) dependencies entirely with a pinned version +of Clang, and statically links libc++ instead of dynamically linking libstdc++. +This migration enables us to reliably use newer C++ features while supporting +older LTS platforms, be more confident in the compiler's optimisations, and +leverage security features such as sanitisers and efficient fuzzing. + +Additionally, because both Clang and rustc use LLVM as their backend, we can +optimise across the FFI boundary between them. This reduces the cost of moving +between C++ and Rust, making it easier to build more functionality in Rust +(though not making it costless, as we still need to work within the constraints +of the C ABI). + +The system compiler is still used to compile a few native dependencies (used by +the build machine to then compile `zcashd` for the target machine). These will +likely also be migrated to use the pinned Clang in a future release. From d54d4d083e592d17427b161e8adc0599c8dc8eff Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Sat, 17 Oct 2020 16:03:32 +0100 Subject: [PATCH 19/21] Update contrib/devtools/symbol-check.py Signed-off-by: Daira Hopwood --- contrib/devtools/symbol-check.py | 94 ++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 35 deletions(-) diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py index 5b83ba97b..99e545f52 100755 --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -1,12 +1,12 @@ #!/usr/bin/env python # Copyright (c) 2014 Wladimir J. van der Laan -# Copyright (c) 2016-2019 The Zcash developers +# Copyright (c) 2016-2020 The Zcash developers # Distributed under the MIT software license, see the accompanying # file COPYING or https://www.opensource.org/licenses/mit-license.php . ''' A script to check that the (Linux) executables produced by gitian only contain -allowed gcc, glibc and libstdc++ version symbols. This makes sure they are -still compatible with the minimum supported Linux distribution versions. +allowed gcc and glibc version symbols. This makes sure they are still compatible +with the minimum supported Linux distribution versions. Example usage: @@ -18,55 +18,73 @@ import re import sys import os -# Debian 6.0.9 (Squeeze) has: +# Ubuntu 16.04 LTS (Xenial Xerus; End of Standard Support April 2021, EOL April 2022) has: # -# - g++ version 4.4.5 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=g%2B%2B) -# - libc version 2.11.3 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=libc6) -# - libstdc++ version 4.4.5 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=libstdc%2B%2B6) +# - g++ version 4.5.3 (https://packages.ubuntu.com/search?suite=all&searchon=names&keywords=g%2B%2B) +# - libc6 version 2.23 (https://packages.ubuntu.com/search?suite=all&searchon=names&keywords=libc6) # -# Ubuntu 10.04.4 (Lucid Lynx) has: +# Debian 9 (Stretch; EOL 2020-07-06, LTS EOL in 2022) has: # -# - g++ version 4.4.3 (http://packages.ubuntu.com/search?keywords=g%2B%2B&searchon=names&suite=lucid§ion=all) -# - libc version 2.11.1 (http://packages.ubuntu.com/search?keywords=libc6&searchon=names&suite=lucid§ion=all) -# - libstdc++ version 4.4.3 (http://packages.ubuntu.com/search?suite=lucid§ion=all&arch=any&keywords=libstdc%2B%2B&searchon=names) +# - g++ version 6.3.0 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=g%2B%2B) +# - libc6 version 2.24 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=libc6) # -# Taking the minimum of these as our target. +# CentOS 8 (Full update EOL May 2024, Maintenance EOL 2029-05-31) has: # -# According to GNU ABI document (http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html) this corresponds to: -# GCC 4.4.0: GCC_4.4.0 -# GCC 4.4.2: GLIBCXX_3.4.13, CXXABI_1.3.3 -# (glibc) GLIBC_2_11 +# - g++ version 8.3.1 (http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ search for libgcc) +# - libc6 version 2.28 (http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ search for glibc) # +# Arch is a rolling release, and as of October 2020 has packages for: +# +# - g++ version 8.4.0 / 9.3.0 / 10.2.0 (https://www.archlinux.org/packages/?q=gcc) +# - libc6 version 2.32 (https://www.archlinux.org/packages/?q=glibc) +# +# We take the minimum of these as our target. In practice, if we build on Xenial without +# upgrading GCC or libc, then we should get a binary that works for all these systems, and +# later ones. +# +# According to the GNU ABI document (http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html) this corresponds to: +# GCC 4.5.3: GCC_4.5.0, GLIBCXX_3.4.14, CXXABI_1.3.4 +# libc6: GLIBC_2_23 + +# We statically link libc++ and libc++abi in our builds. Set this to allow dynamic linking to libstdc++. +ALLOW_DYNAMIC_LIBSTDCXX = False + MAX_VERSIONS = { -'GCC': (4,4,0), -'CXXABI': (1,3,3), -'GLIBCXX': (3,4,13), -'GLIBC': (2,11) + 'GCC': (4,5,0), + 'GLIBC': (2,23), } +if ALLOW_DYNAMIC_LIBSTDCXX: + MAX_VERSIONS.update({ + 'GLIBCXX': (3,4,14), + 'CXXABI': (1,3,4), + }) + # See here for a description of _IO_stdin_used: # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=634261#109 # Ignore symbols that are exported as part of every executable IGNORE_EXPORTS = { -'_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used' + '_edata', '_end', '_init', '__bss_start', '_fini', '_IO_stdin_used' } READELF_CMD = os.getenv('READELF', '/usr/bin/readelf') CPPFILT_CMD = os.getenv('CPPFILT', '/usr/bin/c++filt') + # Allowed NEEDED libraries ALLOWED_LIBRARIES = { -# zcashd -'libgcc_s.so.1', # GCC base support -'libc.so.6', # C library -'libstdc++.so.6', # C++ standard library -'libpthread.so.0', # threading -'libanl.so.1', # DNS resolve -'libm.so.6', # math library -'librt.so.1', # real-time (clock) -'libgomp.so.1', # OpenMP support library -'ld-linux-x86-64.so.2', # 64-bit dynamic linker -'ld-linux.so.2', # 32-bit dynamic linker -'libdl.so.2' # programming interface to dynamic linker + # zcashd + 'libgcc_s.so.1', # GCC support library (also used by clang) + 'libc.so.6', # C library + 'libpthread.so.0', # threading + 'libanl.so.1', # DNS resolver + 'libm.so.6', # math library + 'librt.so.1', # real-time (POSIX compatibility) + 'ld-linux-x86-64.so.2', # 64-bit dynamic linker + 'ld-linux.so.2', # 32-bit dynamic linker + 'libdl.so.2' # programming interface to dynamic linker } +if ALLOW_DYNAMIC_LIBSTDCXX: + ALLOWED_LIBRARIES.add('libstdc++.so.6') # C++ standard library + class CPPFilt(object): ''' @@ -138,6 +156,7 @@ if __name__ == '__main__': cppfilt = CPPFilt() retval = 0 for filename in sys.argv[1:]: + print("Checking %s..." % (filename,)) # Check imported symbols for sym,version in read_symbols(filename, True): if version and not check_version(MAX_VERSIONS, version): @@ -154,7 +173,12 @@ if __name__ == '__main__': if library_name not in ALLOWED_LIBRARIES: print('%s: NEEDED library %s is not allowed' % (filename, library_name)) retval = 1 + print() + + if retval == 0: + print("Everything OK") + else: + print("Note: this script is intended to ensure that Gitian builds meet our compatibility policy.") + print("The above warnings do not necessarily mean the program(s) will not work on your system.") exit(retval) - - From f2d7fd6323a493322f8bd1ca9d0bf1db5ab9a4d9 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Sun, 18 Oct 2020 18:45:36 +0100 Subject: [PATCH 20/21] contrib/devtools/symbol-check.py: add info about Fedora-based distributions. Signed-off-by: Daira Hopwood --- contrib/devtools/symbol-check.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py index 99e545f52..6bedea5ac 100755 --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -28,11 +28,21 @@ import os # - g++ version 6.3.0 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=g%2B%2B) # - libc6 version 2.24 (https://packages.debian.org/search?suite=default§ion=all&arch=any&searchon=names&keywords=libc6) # +# RedHat Enterprise Linux 8 (EOL: long and complicated) is based on Fedora 28 (EOL 2019-05-28) and uses the same base packages: +# +# - g++ version 8.0.1 (https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Everything/x86_64/os/Packages/g/ search for gcc-) +# - libc6 version 2.27 (https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Everything/x86_64/os/Packages/g/ search for glibc) +# # CentOS 8 (Full update EOL May 2024, Maintenance EOL 2029-05-31) has: # # - g++ version 8.3.1 (http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ search for libgcc) # - libc6 version 2.28 (http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ search for glibc) # +# Fedora 31 (EOL ~November 2020) has: +# +# - g++ version 9.2.1 (https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/g/ search for gcc-) +# - libc6 version 2.30 (https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Everything/x86_64/os/Packages/g/ search for glibc) +# # Arch is a rolling release, and as of October 2020 has packages for: # # - g++ version 8.4.0 / 9.3.0 / 10.2.0 (https://www.archlinux.org/packages/?q=gcc) From eaed8d57974afcf51136fc1a99789e4768779e06 Mon Sep 17 00:00:00 2001 From: str4d Date: Mon, 19 Oct 2020 20:19:00 +0100 Subject: [PATCH 21/21] depends: Add untested note to FreeBSD host Co-authored-by: Daira Hopwood --- depends/hosts/freebsd.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/depends/hosts/freebsd.mk b/depends/hosts/freebsd.mk index 6ddb49918..9eddcc6e1 100644 --- a/depends/hosts/freebsd.mk +++ b/depends/hosts/freebsd.mk @@ -9,6 +9,9 @@ freebsd_debug_CXXFLAGS=$(freebsd_debug_CFLAGS) freebsd_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC +# Changes below have not been tested. If you try to build on FreeBSD, +# please let us know how it goes. + freebsd_LDFLAGS?=-fuse-ld=lld i686_freebsd_CC=$(default_host_CC) -m32