Skip to content

Commit b2e4240

Browse files
committed
lto=thin is clang-only, even in Ubuntu 24.x, and we only really care about LTO for the binary bits that end up in the app package itself anyway. gradefully degrade to generic LTO when clang isn't detected on the system. when clang is detected, make sure we use it for generating the ICU host-run codegen
1 parent 055fcd8 commit b2e4240

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

scripts/start.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,30 @@ patchAndMakeICU() {
4848
mkdir -p $TARGETDIR/icu/host
4949
cd $TARGETDIR/icu/host
5050

51+
local HAS_CLANG=0
52+
if command -v clang >/dev/null 2>&1 && command -v clang++ >/dev/null 2>&1; then
53+
HAS_CLANG=1
54+
fi
55+
5156
if [[ "$BUILD_TYPE" = "Release" ]]
5257
then
53-
local OPT_FLAGS="-O2 -flto=thin -Wno-pass-failed=loop-vectorize"
58+
local LTO_FLAG
59+
local EXTRA_FLAGS=""
60+
if [[ $HAS_CLANG -eq 1 ]]; then
61+
LTO_FLAG="-flto=thin"
62+
EXTRA_FLAGS="-Wno-pass-failed=loop-vectorize"
63+
else
64+
LTO_FLAG="-flto"
65+
fi
66+
67+
local OPT_FLAGS="-O2 $LTO_FLAG"
68+
if [[ -n "$EXTRA_FLAGS" ]]; then
69+
OPT_FLAGS="$OPT_FLAGS $EXTRA_FLAGS"
70+
fi
71+
5472
CFLAGS="$OPT_FLAGS"
5573
CXXFLAGS="-std=c++20 $OPT_FLAGS"
56-
LDFLAGS="-flto=thin"
74+
LDFLAGS="$LTO_FLAG"
5775
else
5876
CFLAGS="-g2"
5977
CXXFLAGS="-std=c++20"
@@ -65,6 +83,9 @@ patchAndMakeICU() {
6583
if [[ -n "$LDFLAGS" ]]; then
6684
CONFIG_ENV+=("LDFLAGS=$LDFLAGS")
6785
fi
86+
if [[ $HAS_CLANG -eq 1 ]]; then
87+
CONFIG_ENV+=("CC=clang" "CXX=clang++")
88+
fi
6889

6990
if [[ -f "$ICU_FILTER_FILE" ]]; then
7091
printf "Using ICU data filter: %s\n" "$ICU_FILTER_FILE"

0 commit comments

Comments
 (0)