diff options
author | Ron Yorston <rmy@pobox.com> | 2024-02-03 11:56:25 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-02-03 11:56:25 +0000 |
commit | 49568fc1f16ff93848650e509855d7f55740f30d (patch) | |
tree | a1cdbbe7150469c3f41c8abb93d14661602d1b24 | |
parent | 5a6d050af3aca3c8710e781e7082adec801201c8 (diff) | |
download | busybox-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/README | 15 | ||||
-rwxr-xr-x | examples/mswin-build/mkrelease | 88 |
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 @@ | |||
1 | These are the scripts used to cross-compile busybox-w32. | 1 | These scripts can be used to cross-compile busybox-w32 on a |
2 | Fedora Linux system with mingw-w64 and llvm-mingw toolchains. | ||
3 | The former are available from the Fedora repositories; the | ||
4 | latter needs to be downloaded and installed from: | ||
5 | |||
6 | https://github.com/mstorsjo/llvm-mingw | ||
2 | 7 | ||
3 | The release build performs some additional optimisation and is | 8 | The release build performs some additional optimisation and is |
4 | slightly slower as a result. It also includes information about | 9 | slightly slower as a result. |
5 | the build platform in the help message. This assumes the build is | 10 | |
6 | done on a Fedora Linux system. | 11 | The busybox-w32 help message includes information about the build |
12 | platform. Obtaining this information is very specific to the | ||
13 | platform 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 | # |
5 | TARGETS="build_32 build_64 build_64u" | 5 | TARGETS="build_32 build_64 build_64a build_64u" |
6 | 6 | ||
7 | if [ ! -d busybox-w32 ] | 7 | if [ ! -d busybox-w32 ] |
8 | then | 8 | then |
@@ -20,37 +20,46 @@ done | |||
20 | # apply default configuration | 20 | # apply default configuration |
21 | for i in $TARGETS | 21 | for i in $TARGETS |
22 | do | 22 | do |
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 | ) |
55 | done | 64 | done |
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 | ) |
72 | done | 89 | done |
90 | |||
91 | # Check the expected binaries exist | ||
92 | echo | ||
93 | for i in $TARGETS | ||
94 | do | ||
95 | ls -l $i/busybox.exe | ||
96 | done | ||