Skip to content

Commit 0947726

Browse files
committed
build: support LTO in depends
No Qt for now.
1 parent 9e4fbeb commit 0947726

File tree

11 files changed

+55
-3
lines changed

11 files changed

+55
-3
lines changed

depends/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ NO_UPNP ?=
4242
NO_USDT ?=
4343
NO_NATPMP ?=
4444
MULTIPROCESS ?=
45+
LTO ?=
4546
FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources
4647

4748
BUILD = $(shell ./config.guess)
@@ -140,8 +141,8 @@ include packages/packages.mk
140141
# 2. Before including packages/*.mk (excluding packages/packages.mk), since
141142
# they rely on the build_id variables
142143
#
143-
build_id:=$(shell env CC='$(build_CC)' CXX='$(build_CXX)' AR='$(build_AR)' RANLIB='$(build_RANLIB)' STRIP='$(build_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' ./gen_id '$(BUILD_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
144-
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' CXX='$(host_CXX)' AR='$(host_AR)' RANLIB='$(host_RANLIB)' STRIP='$(host_STRIP)' SHA256SUM='$(build_SHA256SUM)' DEBUG='$(DEBUG)' ./gen_id '$(HOST_ID_SALT)' 'GUIX_ENVIRONMENT=$(realpath $(GUIX_ENVIRONMENT))')
144+
build_id:=$(shell env CC='$(build_CC)' CXX='$(build_CXX)' 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))')
145+
$(host_arch)_$(host_os)_id:=$(shell env CC='$(host_CC)' CXX='$(host_CXX)' 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))')
145146

146147
qrencode_packages_$(NO_QR) = $(qrencode_$(host_os)_packages)
147148

@@ -242,6 +243,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_
242243
-e 's|@no_usdt@|$(NO_USDT)|' \
243244
-e 's|@no_natpmp@|$(NO_NATPMP)|' \
244245
-e 's|@multiprocess@|$(MULTIPROCESS)|' \
246+
-e 's|@lto@|$(LTO)|' \
245247
-e 's|@debug@|$(DEBUG)|' \
246248
$< > $@
247249
touch $@

depends/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ The following can be set when running make: `make FOO=bar`
117117
- `LOG`: Use file-based logging for individual packages. During a package build its log file
118118
resides in the `depends` directory, and the log file is printed out automatically in case
119119
of build error. After successful build log files are moved along with package archives
120+
- `LTO`: Use LTO when building packages.
120121

121122
If some packages are not built, for example `make NO_WALLET=1`, the appropriate
122123
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
@@ -78,6 +78,10 @@ if test "@host_os@" = darwin; then
7878
BREW=no
7979
fi
8080

81+
if test -z "$enable_lto" && test -n "@lto@"; then
82+
enable_lto=yes
83+
fi
84+
8185
PKG_CONFIG="$(which pkg-config) --static"
8286

8387
# These two need to remain exported because pkg-config does not see them

depends/gen_id

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# Usage: env [ CC=... ] [ CXX=... ] [ AR=... ] [ RANLIB=... ] [ STRIP=... ] \
4-
# [ DEBUG=... ] ./build-id [ID_SALT]...
4+
# [ DEBUG=... ] [ LTO=... ] ./build-id [ID_SALT]...
55
#
66
# Prints to stdout a SHA256 hash representing the current toolset, used by
77
# depends/Makefile as a build id for caching purposes (detecting when the
@@ -63,6 +63,10 @@
6363
env | grep '^STRIP_'
6464
echo "END STRIP"
6565

66+
echo "BEGIN LTO"
67+
echo "LTO=${LTO}"
68+
echo "END LTO"
69+
6670
echo "END ALL"
6771
) | if [ -n "$DEBUG" ] && command -v tee > /dev/null 2>&1; then
6872
# When debugging and `tee` is available, output the preimage to stderr

depends/hosts/android.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ else
55
android_CXX=$(ANDROID_TOOLCHAIN_BIN)/$(HOST)$(ANDROID_API_LEVEL)-clang++
66
android_CC=$(ANDROID_TOOLCHAIN_BIN)/$(HOST)$(ANDROID_API_LEVEL)-clang
77
endif
8+
9+
ifneq ($(LTO),)
10+
android_CFLAGS += -flto
11+
android_LDFLAGS += -flto
12+
endif
13+
814
android_AR=$(ANDROID_TOOLCHAIN_BIN)/llvm-ar
915
android_RANLIB=$(ANDROID_TOOLCHAIN_BIN)/llvm-ranlib
1016

depends/hosts/darwin.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ darwin_CXX=env -u C_INCLUDE_PATH -u CPLUS_INCLUDE_PATH \
110110
-Xclang -internal-externc-isystem$(OSX_SDK)/usr/include
111111

112112
darwin_CFLAGS=-pipe
113+
114+
ifneq ($(LTO),)
115+
darwin_CFLAGS += -flto
116+
darwin_LDFLAGS += -flto
117+
endif
118+
113119
darwin_CXXFLAGS=$(darwin_CFLAGS)
114120

115121
darwin_release_CFLAGS=-O2

depends/hosts/freebsd.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
freebsd_CFLAGS=-pipe
2+
3+
ifneq ($(LTO),)
4+
freebsd_CFLAGS += -flto
5+
freebsd_LDFLAGS += -flto
6+
endif
7+
28
freebsd_CXXFLAGS=$(freebsd_CFLAGS)
39

410
freebsd_release_CFLAGS=-O2

depends/hosts/linux.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
linux_CFLAGS=-pipe
2+
3+
ifneq ($(LTO),)
4+
linux_CFLAGS += -flto
5+
linux_LDFLAGS += -flto
6+
endif
7+
28
linux_CXXFLAGS=$(linux_CFLAGS)
39

410
linux_release_CFLAGS=-O2

depends/hosts/mingw32.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ mingw32_CXX := $(host)-g++-posix
33
endif
44

55
mingw32_CFLAGS=-pipe
6+
7+
ifneq ($(LTO),)
8+
mingw32_CFLAGS += -flto
9+
mingw32_LDFLAGS += -flto
10+
endif
11+
612
mingw32_CXXFLAGS=$(mingw32_CFLAGS)
713

814
mingw32_release_CFLAGS=-O2

depends/hosts/netbsd.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
netbsd_CFLAGS=-pipe
2+
3+
ifneq ($(LTO),)
4+
netbsd_CFLAGS += -flto
5+
netbsd_LDFLAGS += -flto
6+
endif
7+
28
netbsd_CXXFLAGS=$(netbsd_CFLAGS)
39

410
netbsd_release_CFLAGS=-O2

0 commit comments

Comments
 (0)