mirror of
https://github.com/status-im/status-app.git
synced 2026-08-27 15:11:20 +00:00
On iOS, Nim builds --app:staticlib, so the .a ships bitcode, and the actual LTO + codegen happens at Xcode's final link.
ThinLTO is aggressive about cross-module optimization, and it occasionally miscompiles code with subtle semantics.
The exact pattern that's failing — Nim's ORC move/destructor handling around std/json's ref-based JsonNode built
via %* (a newJObject() followed by a run of OrderedTable inserts) — is a classic place for an over-eager optimizer to
wrongly drop the populated temporary or elide the inserts, yielding an empty {}.
105 lines
3.5 KiB
Bash
Executable File
105 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -ef pipefail
|
|
set -o xtrace
|
|
|
|
STATUS_DESKTOP=${STATUS_DESKTOP:-"../vendors/status-desktop"}
|
|
ARCH=${ARCH:-"amd64"}
|
|
ANDROID_ABI=${ANDROID_ABI:-"arm64-v8a"}
|
|
LIB_DIR=${LIB_DIR}
|
|
LIB_SUFFIX=${LIB_SUFFIX:-""}
|
|
OS=${OS:-"android"}
|
|
DEBUG=${DEBUG:-0}
|
|
PROFILE=${PROFILE:-0}
|
|
FLAG_DAPPS_ENABLED=${FLAG_DAPPS_ENABLED:-0}
|
|
FLAG_CONNECTOR_ENABLED=${FLAG_CONNECTOR_ENABLED:-0}
|
|
FLAG_KEYCARD_ENABLED=${FLAG_KEYCARD_ENABLED:-0}
|
|
FLAG_SINGLE_STATUS_INSTANCE_ENABLED=${FLAG_SINGLE_STATUS_INSTANCE_ENABLED:-0}
|
|
FLAG_BROWSER_ENABLED=${FLAG_BROWSER_ENABLED:-0}
|
|
FLAG_BUY_ENABLED=${FLAG_BUY_ENABLED:-1}
|
|
FLAG_SWAP_ENABLED=${FLAG_SWAP_ENABLED:-1}
|
|
FLAG_BRIDGE_ENABLED=${FLAG_BRIDGE_ENABLED:-1}
|
|
|
|
BUNDLE_IDENTIFIER=${BUNDLE_IDENTIFIER:-"app.status.mobile"}
|
|
DESKTOP_VERSION=$(cd "$STATUS_DESKTOP" && ./scripts/version.sh)
|
|
STATUSGO_VERSION=$(cd "$STATUS_DESKTOP/vendor/status-go" && ./scripts/version.sh)
|
|
|
|
if [[ "$ARCH" == "x86_64" ]]; then
|
|
CARCH="amd64"
|
|
else
|
|
CARCH="$ARCH"
|
|
fi
|
|
|
|
if [[ "$OS" == "ios" ]]; then
|
|
PLATFORM_SPECIFIC=(--app:staticlib -d:ios --os:ios)
|
|
else
|
|
PLATFORM_SPECIFIC=(--app:lib --os:android -d:android -d:androidNDK -d:lto -d:chronicles_sinks=textlines[logcat],textlines[file,nocolors] \
|
|
--passL="-L$LIB_DIR" --passL="-lstatus_stub" --passL="-lStatusQ$LIB_SUFFIX" --passL="-lqrcodegen" --passL="-lssl_3" --passL="-lcrypto_3" --passL="-lstatus-keycard-qt" -d:taskpool)
|
|
fi
|
|
|
|
if [ -n "$USE_QML_SERVER" ]; then
|
|
QML_SERVER_DEFINES="-d:USE_QML_SERVER=$USE_QML_SERVER"
|
|
else
|
|
QML_SERVER_DEFINES=""
|
|
fi
|
|
|
|
echo "Building status-client for $ARCH using compiler: $CC"
|
|
|
|
cd "$STATUS_DESKTOP"
|
|
|
|
# setting compile time feature flags
|
|
FEATURE_FLAGS=(
|
|
FLAG_DAPPS_ENABLED=$FLAG_DAPPS_ENABLED
|
|
FLAG_CONNECTOR_ENABLED=$FLAG_CONNECTOR_ENABLED
|
|
FLAG_KEYCARD_ENABLED=$FLAG_KEYCARD_ENABLED
|
|
FLAG_SINGLE_STATUS_INSTANCE_ENABLED=$FLAG_SINGLE_STATUS_INSTANCE_ENABLED
|
|
FLAG_BROWSER_ENABLED=$FLAG_BROWSER_ENABLED
|
|
FLAG_BUY_ENABLED=$FLAG_BUY_ENABLED
|
|
FLAG_SWAP_ENABLED=$FLAG_SWAP_ENABLED
|
|
FLAG_BRIDGE_ENABLED=$FLAG_BRIDGE_ENABLED
|
|
)
|
|
|
|
# app configuration defines
|
|
APP_CONFIG_DEFINES=(
|
|
--outdir:./bin
|
|
-d:KDF_ITERATIONS=3200
|
|
-d:DESKTOP_VERSION="$DESKTOP_VERSION"
|
|
-d:STATUSGO_VERSION="$STATUSGO_VERSION"
|
|
-d:GIT_COMMIT="$(git log --pretty=format:'%h' -n 1)"
|
|
-d:PUSH_TOPIC="$BUNDLE_IDENTIFIER"
|
|
)
|
|
|
|
NIM_FLAGS=(
|
|
--mm:orc
|
|
-d:useMalloc
|
|
# NOTE: -d:lto is intentionally NOT here. On the iOS --app:staticlib target,
|
|
# LTO bitcode in the .a is mis-optimized at Xcode's final link, miscompiling
|
|
# std/json %* JObject construction (CreateAccountRequest.toJson() -> empty {},
|
|
# breaking account creation). LTO is re-added for Android below, where it works.
|
|
--opt:size
|
|
--cc:clang
|
|
--cpu:"$CARCH"
|
|
--noMain:on
|
|
--clang.exe="$CC"
|
|
--clang.linkerexe="$CC"
|
|
--dynlibOverrideAll
|
|
--nimcache:"$STATUS_DESKTOP"/nimcache
|
|
)
|
|
|
|
if [ "$DEBUG" -eq 1 ]; then
|
|
#TODO: filter nimqml logs and then set -d:debug instead of -d:release
|
|
NIM_FLAGS+=(-d:release -d:nimTypeNames)
|
|
elif [ "$PROFILE" -eq 1 ]; then
|
|
NIM_FLAGS+=(-d:release -d:nimTypeNames -d:qmldebug -d:qmlDebugPort:${QML_DEBUG_PORT:-49152} --passC:-DQT_QML_DEBUG)
|
|
else
|
|
NIM_FLAGS+=(-d:release -d:production)
|
|
fi
|
|
|
|
# build status-client with feature flags
|
|
env "${FEATURE_FLAGS[@]}" ./vendor/nimbus-build-system/scripts/env.sh nim c "${PLATFORM_SPECIFIC[@]}" "${APP_CONFIG_DEFINES[@]}" ${QML_SERVER_DEFINES} \
|
|
"${NIM_FLAGS[@]}" \
|
|
"$STATUS_DESKTOP"/src/nim_status_client.nim
|
|
|
|
mkdir -p "$LIB_DIR"
|
|
|
|
cp "$STATUS_DESKTOP/bin/libnim_status_client$LIB_EXT" "$LIB_DIR/libnim_status_client$LIB_EXT"
|