aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-02-03 11:56:25 +0000
committerRon Yorston <rmy@pobox.com>2024-02-03 11:56:25 +0000
commit49568fc1f16ff93848650e509855d7f55740f30d (patch)
treea1cdbbe7150469c3f41c8abb93d14661602d1b24
parent5a6d050af3aca3c8710e781e7082adec801201c8 (diff)
downloadbusybox-w32-49568fc1f16ff93848650e509855d7f55740f30d.tar.gz
busybox-w32-49568fc1f16ff93848650e509855d7f55740f30d.tar.bz2
busybox-w32-49568fc1f16ff93848650e509855d7f55740f30d.zip
win32: update sample script for release build
Update the mkrelease script to include cross-compilation of the Windows on ARM binary on Linux using llvm-mingw.
-rw-r--r--examples/mswin-build/README15
-rwxr-xr-xexamples/mswin-build/mkrelease88
2 files changed, 67 insertions, 36 deletions
diff --git a/examples/mswin-build/README b/examples/mswin-build/README
index 57a13d8d5..41cd6ebb2 100644
--- a/examples/mswin-build/README
+++ b/examples/mswin-build/README
@@ -1,6 +1,13 @@
1These are the scripts used to cross-compile busybox-w32. 1These scripts can be used to cross-compile busybox-w32 on a
2Fedora Linux system with mingw-w64 and llvm-mingw toolchains.
3The former are available from the Fedora repositories; the
4latter needs to be downloaded and installed from:
5
6 https://github.com/mstorsjo/llvm-mingw
2 7
3The release build performs some additional optimisation and is 8The release build performs some additional optimisation and is
4slightly slower as a result. It also includes information about 9slightly slower as a result.
5the build platform in the help message. This assumes the build is 10
6done on a Fedora Linux system. 11The busybox-w32 help message includes information about the build
12platform. Obtaining this information is very specific to the
13platform used.
diff --git a/examples/mswin-build/mkrelease b/examples/mswin-build/mkrelease
index 956cba0c1..51dd3346b 100755
--- a/examples/mswin-build/mkrelease
+++ b/examples/mswin-build/mkrelease
@@ -2,7 +2,7 @@
2# 2#
3# Build 32- and 64-bit busybox binaries for release 3# Build 32- and 64-bit busybox binaries for release
4# 4#
5TARGETS="build_32 build_64 build_64u" 5TARGETS="build_32 build_64 build_64a build_64u"
6 6
7if [ ! -d busybox-w32 ] 7if [ ! -d busybox-w32 ]
8then 8then
@@ -20,37 +20,46 @@ done
20# apply default configuration 20# apply default configuration
21for i in $TARGETS 21for i in $TARGETS
22do 22do
23 if [ $i = "build_64" ]
24 then
25 CONFIG=mingw64_defconfig
26 BITS=64
27 elif [ $i = "build_64u" ]
28 then
29 CONFIG=mingw64u_defconfig
30 BITS=64
31 elif [ $i = "build_32" ]
32 then
33 CONFIG=mingw32_defconfig
34 BITS=32
35 fi
36
37 ( 23 (
24 if [ $i = "build_64" ]
25 then
26 CONFIG=mingw64_defconfig
27 BITS=64
28 elif [ $i = "build_64a" ]
29 then
30 PATH="/data2/llvm/current/bin:$PATH"
31 CONFIG=mingw64a_defconfig
32 BITS=64
33 elif [ $i = "build_64u" ]
34 then
35 CONFIG=mingw64u_defconfig
36 BITS=64
37 elif [ $i = "build_32" ]
38 then
39 CONFIG=mingw32_defconfig
40 BITS=32
41 fi
42
38 cd $i 43 cd $i
39 make ${CONFIG} 44 make ${CONFIG}
40 # link time optimisation, fortify, stack protection 45 # TODO: add optimisations for clang/aarch64 build
41 sed -e 's/^CONFIG_EXTRA_CFLAGS="\(.*\)"$/CONFIG_EXTRA_CFLAGS="\1 -flto -fstack-protector --param=ssp-buffer-size=4"/' \ 46 if [ $i != "build_64a" ]
42 -e 's/^CONFIG_EXTRA_CFLAGS=" /CONFIG_EXTRA_CFLAGS="/' \ 47 then
43 -e 's/^CONFIG_EXTRA_LDLIBS="\(.*\)"$/CONFIG_EXTRA_LDLIBS="\1 -l:libssp.a"/' \ 48 # link time optimisation, fortify, stack protection
44 -e 's/^CONFIG_EXTRA_LDLIBS=" /CONFIG_EXTRA_LDLIBS="/' \ 49 sed -e 's/^CONFIG_EXTRA_CFLAGS="\(.*\)"$/CONFIG_EXTRA_CFLAGS="\1 -flto -fstack-protector --param=ssp-buffer-size=4"/' \
45 -i .config 50 -e 's/^CONFIG_EXTRA_CFLAGS=" /CONFIG_EXTRA_CFLAGS="/' \
46 # does ld support --disable-reloc-section? 51 -e 's/^CONFIG_EXTRA_LDLIBS="\(.*\)"$/CONFIG_EXTRA_LDLIBS="\1 -l:libssp.a"/' \
47 eval $(grep CONFIG_CROSS_COMPILER_PREFIX .config) 52 -e 's/^CONFIG_EXTRA_LDLIBS=" /CONFIG_EXTRA_LDLIBS="/' \
48 [ $BITS -eq 32 ] && [ -n "$CONFIG_CROSS_COMPILER_PREFIX" ] && \ 53 -i .config
49 ${CONFIG_CROSS_COMPILER_PREFIX}ld --help | \ 54 # does ld support --disable-reloc-section?
50 grep -q disable-reloc-section && 55 eval $(grep CONFIG_CROSS_COMPILER_PREFIX .config)
51 sed -e 's/^CONFIG_EXTRA_LDFLAGS="\(.*\)"$/CONFIG_EXTRA_LDFLAGS="\1 -Wl,--disable-reloc-section"/' \ 56 [ $BITS -eq 32 ] && [ -n "$CONFIG_CROSS_COMPILER_PREFIX" ] && \
52 -e 's/^CONFIG_EXTRA_LDFLAGS=" /CONFIG_EXTRA_LDFLAGS="/' \ 57 ${CONFIG_CROSS_COMPILER_PREFIX}ld --help | \
53 -i .config 58 grep -q disable-reloc-section &&
59 sed -e 's/^CONFIG_EXTRA_LDFLAGS="\(.*\)"$/CONFIG_EXTRA_LDFLAGS="\1 -Wl,--disable-reloc-section"/' \
60 -e 's/^CONFIG_EXTRA_LDFLAGS=" /CONFIG_EXTRA_LDFLAGS="/' \
61 -i .config
62 fi
54 ) 63 )
55done 64done
56 65
@@ -65,8 +74,23 @@ do
65 74
66 ( 75 (
67 cd $i 76 cd $i
68 GCCV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc) 77 if [ $i = "build_64a" ]
69 CRTV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt) 78 then
70 make -j $(nproc) EXTRAVERSION="-`git describe --match=FRP`" MINGW_VER="$GCCV; $CRTV" 79 # /data2/llvm/current should be a symlink
80 PATH="/data2/llvm/current/bin:$PATH"
81 VERSION=$(readlink /data2/llvm/current)
82 else
83 GCCV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc)
84 CRTV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt)
85 VERSION="$GCCV; $CRTV"
86 fi
87 make -j $(nproc) EXTRAVERSION="-`git describe --match=FRP`" MINGW_VER="$VERSION"
71 ) 88 )
72done 89done
90
91# Check the expected binaries exist
92echo
93for i in $TARGETS
94do
95 ls -l $i/busybox.exe
96done