Skip to content

Commit 27f7af0

Browse files
committed
Enforce static build
Signed-off-by: Andrea Barberio <[email protected]>
1 parent da6a271 commit 27f7af0

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
build/
2+
.*.swp

build.sh

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ VPD_VERSION="release-R74-11895.B"
1111
rm -rf "${OUTDIR}"
1212
mkdir -p "${OUTDIR}"
1313

14+
check_if_statically_linked() {
15+
f=$1
16+
# ldd exits with an error if it's not a dynamic executable, so exit 0 here
17+
# means error,
18+
ldd "${f}" && \
19+
(
20+
echo "ERROR: $f is not statically linked"
21+
exit 1
22+
) || \
23+
true # all good
24+
}
25+
1426
# build kexec-tools
1527
cd "${OUTDIR}"
1628
git clone git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
@@ -19,11 +31,11 @@ git checkout -b "${KEXEC_TOOLS_VERSION}"
1931
./bootstrap
2032
# just optimize for space. Kexec uses kernel headers so we cannot use musl-gcc
2133
# here. See https://wiki.musl-libc.org/faq.html#Q:-Why-am-I-getting-
22-
CFLAGS=-Os ./configure
34+
CFLAGS=-Os LDFLAGS=-static ./configure
2335
make
2436
strip build/sbin/kexec
2537
du -hs build/sbin/kexec
26-
ldd build/sbin/kexec
38+
check_if_statically_linked build/sbin/kexec
2739

2840
# build flashrom
2941
cd "${OUTDIR}"
@@ -32,10 +44,13 @@ cd flashrom
3244
git checkout -b "${FLASHROM_VERSION}"
3345
# no musl-gcc here either, as flashrom needs libpci-dev (we may remove PCI
3446
# programmers from the build at a later stage though)
35-
CFLAGS=-Os make
47+
CONFIG_STATIC=yes \
48+
CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no \
49+
CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no \
50+
make
3651
strip flashrom
3752
du -hs flashrom
38-
ldd flashrom
53+
check_if_statically_linked flashrom
3954

4055
# build memtester
4156
cd "${OUTDIR}"
@@ -45,14 +60,17 @@ ln -s "memtester-${MEMTESTER_VERSION}" memtester
4560
cd "memtester-${MEMTESTER_VERSION}"
4661
CFLAGS=-Os CC=musl-gcc make # build statically
4762
du -hs memtester
48-
ldd memtester
63+
check_if_statically_linked memtester
4964

5065
# build vpd
5166
cd "${OUTDIR}"
5267
git clone https://chromium.googlesource.com/chromiumos/platform/vpd
5368
cd vpd
5469
git checkout "${VPD_VERSION}"
5570
make
71+
# rename vpd_s to vpd for our purposes. This overwrites the original,
72+
# dynamically linked, vpd binary, but we don't need it.
73+
mv vpd_s vpd
5674
strip vpd
5775
du -hs vpd
58-
ldd vpd
76+
check_if_statically_linked vpd

0 commit comments

Comments
 (0)