Skip to content

Commit 98ebe78

Browse files
committed
Merge #18820: build: Propagate well-known vars into depends
f0d7ed1 depends: Propagate only specific CLI variables to sub-makes (Carl Dong) 0a33803 depends: boost: Use clang toolset if clang in CXX (Carl Dong) 1ce74bc depends: boost: Split target-os from toolset (Carl Dong) 2d4e480 depends: boost: Specify toolset to bootstrap.sh (Carl Dong) 3d6603e depends: Propagate well-known vars into depends (Carl Dong) Pull request description: From: bitcoin/bitcoin#18308 (comment) The following monstrosity is quite useful when invoked inside `depends`, and reviewers can use it to compare the behaviour of this change against master. ```bash make print-{{,{host,{,{i686,x86_64,riscv64}_}linux}_}{CC,CXX},boost_{cc,cxx}} ``` It would also be helpful to make sure that setting `HOST`, `CC`, and `CXX` does the right thing. The 3 hosts I found offered good coverage were: `{x86_64,i686,riscv64}-linux-gnu`. As we special-case the `x86_64` and `i686` hosts in `depends/hosts/linux.mk`, and `riscv64` is a sanity check for a non-special-cased host. ACKs for top commit: hebasto: ACK f0d7ed1, tested on Linux Mint 19.3 (x86_64): practicalswift: ACK f0d7ed1 -- patch looks correct laanwj: Code review and concept ACK f0d7ed1 ryanofsky: Code review ACK f0d7ed1. Changes since last review: adding comment explaining check for predefined make variables, dropping freetype commit, adding commit whitelisting overrides for recursive makes Tree-SHA512: b6b8e76f713c26a0add6cd685824e2f5639109236ee9f89338f7c79cb1b1f2c3897bfb62b80b023d6d1943b5a6eb282a2f827f1f499c5e556eca015d6635fa65
2 parents cb88de3 + f0d7ed1 commit 98ebe78

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

depends/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@
44
print-%:
55
@echo $* = $($*)
66

7+
# When invoking a sub-make, keep only the command line variable definitions
8+
# matching the pattern in the filter function.
9+
#
10+
# e.g. invoking:
11+
# $ make A=1 C=1 print-MAKEOVERRIDES print-MAKEFLAGS
12+
#
13+
# with the following in the Makefile:
14+
# MAKEOVERRIDES := $(filter A=% B=%,$(MAKEOVERRIDES))
15+
#
16+
# will print:
17+
# MAKEOVERRIDES = A=1
18+
# MAKEFLAGS = -- A=1
19+
#
20+
# this is because as the GNU make manual says:
21+
# The command line variable definitions really appear in the variable
22+
# MAKEOVERRIDES, and MAKEFLAGS contains a reference to this variable.
23+
#
24+
# and since the GNU make manual also says:
25+
# variables defined on the command line are passed to the sub-make through
26+
# MAKEFLAGS
27+
#
28+
# this means that sub-makes will be invoked as if:
29+
# $(MAKE) A=1 blah blah
30+
MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES))
731
SOURCES_PATH ?= $(BASEDIR)/sources
832
WORK_PATH = $(BASEDIR)/work
933
BASE_CACHE ?= $(BASEDIR)/built

depends/hosts/default.mk

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,18 @@ default_host_OTOOL = $(host_toolchain)otool
1313
default_host_NM = $(host_toolchain)nm
1414

1515
define add_host_tool_func
16+
ifneq ($(filter $(origin $1),undefined default),)
17+
# Do not consider the well-known var $1 if it is undefined or is taking a value
18+
# that is predefined by "make" (e.g. the make variable "CC" has a predefined
19+
# value of "cc")
1620
$(host_os)_$1?=$$(default_host_$1)
1721
$(host_arch)_$(host_os)_$1?=$$($(host_os)_$1)
1822
$(host_arch)_$(host_os)_$(release_type)_$1?=$$($(host_os)_$1)
23+
else
24+
$(host_os)_$1=$(or $($1),$($(host_os)_$1),$(default_host_$1))
25+
$(host_arch)_$(host_os)_$1=$(or $($1),$($(host_arch)_$(host_os)_$1),$$($(host_os)_$1))
26+
$(host_arch)_$(host_os)_$(release_type)_$1=$(or $($1),$($(host_arch)_$(host_os)_$(release_type)_$1),$$($(host_os)_$1))
27+
endif
1928
host_$1=$$($(host_arch)_$(host_os)_$1)
2029
endef
2130

depends/packages/boost.mk

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ $(package)_config_opts_release=variant=release
99
$(package)_config_opts_debug=variant=debug
1010
$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam
1111
$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1
12-
$(package)_config_opts_linux=threadapi=pthread runtime-link=shared
13-
$(package)_config_opts_darwin=--toolset=clang-darwin runtime-link=shared
14-
$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static
12+
$(package)_config_opts_linux=target-os=linux threadapi=pthread runtime-link=shared
13+
$(package)_config_opts_darwin=target-os=darwin runtime-link=shared
14+
$(package)_config_opts_mingw32=target-os=windows binary-format=pe threadapi=win32 runtime-link=static
1515
$(package)_config_opts_x86_64_mingw32=address-model=64
1616
$(package)_config_opts_i686_mingw32=address-model=32
1717
$(package)_config_opts_i686_linux=address-model=32 architecture=x86
@@ -20,8 +20,11 @@ $(package)_config_opts_aarch64_android=address-model=64
2020
$(package)_config_opts_x86_64_android=address-model=64
2121
$(package)_config_opts_armv7a_android=address-model=32
2222
$(package)_toolset_$(host_os)=gcc
23+
$(package)_toolset_darwin=clang
24+
ifneq (,$(findstring clang,$($(package)_cxx)))
25+
$(package)_toolset_$(host_os)=clang
26+
endif
2327
$(package)_archiver_$(host_os)=$($(package)_ar)
24-
$(package)_toolset_darwin=clang-darwin
2528
$(package)_config_libraries=filesystem,system,thread,test
2629
$(package)_cxxflags=-std=c++11 -fvisibility=hidden
2730
$(package)_cxxflags_linux=-fPIC
@@ -33,13 +36,13 @@ define $(package)_preprocess_cmds
3336
endef
3437

3538
define $(package)_config_cmds
36-
./bootstrap.sh --without-icu --with-libraries=$($(package)_config_libraries)
39+
./bootstrap.sh --without-icu --with-libraries=$($(package)_config_libraries) --with-toolset=$($(package)_toolset_$(host_os))
3740
endef
3841

3942
define $(package)_build_cmds
40-
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage
43+
./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) toolset=$($(package)_toolset_$(host_os)) stage
4144
endef
4245

4346
define $(package)_stage_cmds
44-
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install
47+
./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) toolset=$($(package)_toolset_$(host_os)) install
4548
endef

0 commit comments

Comments
 (0)