Skip to content

Commit 77989a2

Browse files
Move submodule init before aarch64 workaround, deduplicate UNAME_S
Move submodule initialization above the aarch64 sed workaround so the file it edits is guaranteed to exist even if the caller disables submodule checkout. Also remove the redundant UNAME_S assignment later in the script.
1 parent 42b6952 commit 77989a2

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

.ci/scripts/wheel/pre_build_script.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ set -euxo pipefail
99

1010
# This script is run before building ExecuTorch binaries
1111

12-
if [[ "$(uname -m)" == "aarch64" ]]; then
13-
# On some Linux aarch64 systems, the "atomic" library is not found during linking.
14-
# To work around this, replace "atomic" with the literal ${ATOMIC_LIB} so the
15-
# build system uses the full path to the atomic library.
16-
file="extension/llm/tokenizers/third-party/sentencepiece/src/CMakeLists.txt"
17-
sed 's/list(APPEND SPM_LIBS "atomic")/list(APPEND SPM_LIBS ${ATOMIC_LIB})/' \
18-
"$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
19-
20-
grep -n 'list(APPEND SPM_LIBS ${ATOMIC_LIB})' "$file" && \
21-
echo "the file $file has been modified for atomic to use full path"
22-
fi
23-
2412
# Initialize submodules here instead of during checkout so we can use OpenSSL
2513
# on Windows (schannel fails with SEC_E_ILLEGAL_MESSAGE on some gitlab hosts).
2614
UNAME_S=$(uname -s)
@@ -42,9 +30,20 @@ else
4230
fi
4331
popd
4432

33+
if [[ "$(uname -m)" == "aarch64" ]]; then
34+
# On some Linux aarch64 systems, the "atomic" library is not found during linking.
35+
# To work around this, replace "atomic" with the literal ${ATOMIC_LIB} so the
36+
# build system uses the full path to the atomic library.
37+
file="extension/llm/tokenizers/third-party/sentencepiece/src/CMakeLists.txt"
38+
sed 's/list(APPEND SPM_LIBS "atomic")/list(APPEND SPM_LIBS ${ATOMIC_LIB})/' \
39+
"$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
40+
41+
grep -n 'list(APPEND SPM_LIBS ${ATOMIC_LIB})' "$file" && \
42+
echo "the file $file has been modified for atomic to use full path"
43+
fi
44+
4545
# On Windows, enable symlinks and re-checkout the current revision to create
4646
# the symlinked src/ directory. This is needed to build the wheel.
47-
UNAME_S=$(uname -s)
4847
if [[ $UNAME_S == *"MINGW"* || $UNAME_S == *"MSYS"* ]]; then
4948
echo "Enabling symlinks on Windows"
5049
git config core.symlinks true

0 commit comments

Comments
 (0)