Skip to content

Commit 75d807a

Browse files
committed
Merge bitcoin/bitcoin#27406: depends: add NO_HARDEN= option
436df1e depends: add NO_HARDEN option (fanquake) Pull request description: Add an option that when passed, will disable hardening options, and pass `--disable-hardening` through to configure. Due to the way we link `libssp` for Windows builds, they now fail (after #27118), if building with depends, and configuring with `--disable-hardening` (Windows is the odd build out here). See: bitcoin/bitcoin#27118 (comment). This change would add a depends option such that, if someone wants to build with depends, for Windows, without hardening, they can do so. This may also be useful when building for debugging. ACKs for top commit: hebasto: re-ACK 436df1e Tree-SHA512: 5a3ef5ec87b10a5ad0a284201988ce94789451735c7c7e20d337f7232955b0b9a0addab1c3b5725755f00d8ce6741aa9c8cb5e3d48d926515b7dde46acdbcaa0
2 parents 9ec30db + 436df1e commit 75d807a

File tree

5 files changed

+18
-4
lines changed

5 files changed

+18
-4
lines changed

depends/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ NO_USDT ?=
4545
NO_NATPMP ?=
4646
MULTIPROCESS ?=
4747
LTO ?=
48+
NO_HARDEN ?=
4849
FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources
4950

5051
C_STANDARD ?= c11
@@ -146,8 +147,8 @@ include packages/packages.mk
146147
# 2. Before including packages/*.mk (excluding packages/packages.mk), since
147148
# they rely on the build_id variables
148149
#
149-
build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(build_AR)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
150-
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(host_AR)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
150+
build_id:=$(shell env CC='$(build_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(build_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(build_AR)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
151+
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' C_STANDARD='$(C_STANDARD)' CXX='$(host_CXX)' CXX_STANDARD='$(CXX_STANDARD)' AR='$(host_AR)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' LTO='$(LTO)' NO_HARDEN='$(NO_HARDEN)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
151152

152153
boost_packages_$(NO_BOOST) = $(boost_packages)
153154

@@ -253,6 +254,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
253254
-e 's|@no_natpmp@|$(NO_NATPMP)|' \
254255
-e 's|@multiprocess@|$(MULTIPROCESS)|' \
255256
-e 's|@lto@|$(LTO)|' \
257+
-e 's|@no_harden@|$(NO_HARDEN)|' \
256258
-e 's|@debug@|$(DEBUG)|' \
257259
$< > $@
258260
touch $@

depends/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ The following can be set when running make: `make FOO=bar`
123123
resides in the `depends` directory, and the log file is printed out automatically in case
124124
of build error. After successful build log files are moved along with package archives
125125
- `LTO`: Use LTO when building packages.
126+
- `NO_HARDEN=1`: Don't use hardening options when building packages
126127

127128
If some packages are not built, for example `make NO_WALLET=1`, the appropriate
128129
options will be passed to bitcoin's configure. In this case, `--disable-wallet`.

depends/config.site.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ if test -z "$enable_lto" && test -n "@lto@"; then
8282
enable_lto=yes
8383
fi
8484

85+
if test -z "$enable_hardening" && test -n "@no_harden@"; then
86+
enable_hardening=no
87+
fi
88+
8589
PKG_CONFIG="$(which pkg-config) --static"
8690

8791
PKG_CONFIG_PATH="${depends_prefix}/share/pkgconfig:${depends_prefix}/lib/pkgconfig"

depends/gen_id

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Usage: env [ CC=... ] [ C_STANDARD=...] [ CXX=... ] [CXX_STANDARD=...] \
44
# [ AR=... ] [ RANLIB=... ] [ STRIP=... ] [ DEBUG=... ] \
5-
# [ LTO=... ] ./build-id [ID_SALT]...
5+
# [ LTO=... ] [ NO_HARDEN=... ] ./build-id [ID_SALT]...
66
#
77
# Prints to stdout a SHA256 hash representing the current toolset, used by
88
# depends/Makefile as a build id for caching purposes (detecting when the
@@ -70,6 +70,10 @@
7070
echo "LTO=${LTO}"
7171
echo "END LTO"
7272

73+
echo "BEGIN NO_HARDEN"
74+
echo "NO_HARDEN=${NO_HARDEN}"
75+
echo "END NO_HARDEN"
76+
7377
echo "END ALL"
7478
) | if [ -n "$DEBUG" ] && command -v tee > /dev/null 2>&1; then
7579
# When debugging and `tee` is available, output the preimage to stderr

depends/packages/libevent.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ define $(package)_set_vars
1616
$(package)_config_opts_netbsd=--with-pic
1717
$(package)_config_opts_openbsd=--with-pic
1818
$(package)_config_opts_android=--with-pic
19-
$(package)_cppflags+=-D_FORTIFY_SOURCE=3
2019
$(package)_cppflags_mingw32=-D_WIN32_WINNT=0x0601
20+
21+
ifeq ($(NO_HARDEN),)
22+
$(package)_cppflags+=-D_FORTIFY_SOURCE=3
23+
endif
2124
endef
2225

2326
define $(package)_preprocess_cmds

0 commit comments

Comments
 (0)