Skip to content

Commit ebb37da

Browse files
committed
Use -flto-partition=balanced when cross-compiling to ARM
Using -flto-partition=none causes the linker to produce very large code sections, which exceed the maximum branch size allowed in Thumb-2 mode. This results in errors like the following during the assembly stage: /tmp/cc4XktsH.s: Assembler messages: /tmp/cc4XktsH.s:7861200: Error: Thumb-2 branch out of range
1 parent d5506d0 commit ebb37da

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

build.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ declare -r pieflags='-fPIE'
4949
declare -r ccflags='-w -O2'
5050
declare -r linkflags='-Xlinker -s'
5151

52-
declare -r ltoflags='-flto -fno-fat-lto-objects -flto-partition=one -flto-compression-level=0 -fdevirtualize-at-ltrans'
53-
declare -r ltolinkflags='-flto'
52+
declare lto_partition='one'
5453

5554
declare -r max_jobs='40'
5655

@@ -187,6 +186,13 @@ declare -r \
187186
build_type \
188187
is_native
189188

189+
if [[ "${build_type}" = 'arm'* ]]; then
190+
lto_partition='balanced'
191+
fi
192+
193+
declare -r ltoflags="-flto -fno-fat-lto-objects -flto-partition=${lto_partition} -flto-compression-level=0 -fdevirtualize-at-ltrans"
194+
declare -r ltolinkflags='-flto'
195+
190196
if ! [ -f "${gmp_tarball}" ]; then
191197
curl \
192198
--url 'https://mirrors.kernel.org/gnu/gmp/gmp-6.3.0.tar.xz' \

0 commit comments

Comments
 (0)