Skip to content

Commit 35f9c4c

Browse files
authored
Sync with upstream script to properly handle symlinks (#27)
I ran a comparison of the chromium's sysroots with ours and found out, that symlinks look differently, e.g. - chromium: `libutil.so -> ../../..//lib/x86_64-linux-gnu/libutil.so.1` - ours (before this change): `libutil.so -> /lib/x86_64-linux-gnu/libutil.so.1` This might have worked in the past with Bazel 7, but with Bazel 8 in some situations (maybe due to Bazel 8's stricter sandboxing) it just fails. I was not able to reproduce it locally, it only happens in CI with enabled Bazel Cache. This change enables the relative symlink handling instead of using absolute paths and syncs with the upstream script of the chromium project. (`lapack` and `blas` seem to be in the correct shape: `liblapack.a -> ./lapack/liblapack.a`) Tested in swift-nav/rules_swiftnav#200 (see testplan in PR description)
1 parent 9576a06 commit 35f9c4c

File tree

5 files changed

+42
-30
lines changed

5 files changed

+42
-30
lines changed

.github/workflows/bullseye-aarch64-sysroot.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ jobs:
1515
name: bullseye-aarch64 sysroot
1616
steps:
1717
- name: Checkout source
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1919

2020
- name: Create sysroot
2121
run: ./sysroot/sysroot-creator.sh build arm64
2222

2323
- name: Upload sysroot
24-
uses: actions/upload-artifact@v3
24+
uses: actions/upload-artifact@v4
2525
with:
2626
name: debian_bullseye_aarch64_sysroot.tar.xz
2727
path: sysroot/out/sysroot-build/bullseye/debian_bullseye_arm64_sysroot.tar.xz
2828

29-
- uses: bazelbuild/setup-bazelisk@v2
29+
- uses: bazel-contrib/setup-bazel@0.15.0
3030

3131
- name: Mount bazel cache
32-
uses: actions/cache@v1
32+
uses: actions/cache@v4
3333
with:
3434
path: "~/.cache/bazel"
3535
key: bazel
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Release sysroot
4444
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
45-
uses: svenstaro/upload-release-action@v1-release
45+
uses: svenstaro/upload-release-action@v2
4646
with:
4747
repo_token: ${{ secrets.GITHUB_TOKEN }}
4848
file: "sysroot/out/sysroot-build/bullseye/debian_bullseye_arm64_sysroot.tar.xz"

.github/workflows/bullseye-x86_64-sysroot.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@ jobs:
1515
name: bullseye-x86_64 sysroot
1616
steps:
1717
- name: Checkout source
18-
uses: actions/checkout@v2
18+
uses: actions/checkout@v4
1919

2020
- name: Create sysroot
2121
run: ./sysroot/sysroot-creator.sh build amd64
2222

2323
- name: Upload sysroot
24-
uses: actions/upload-artifact@v3
24+
uses: actions/upload-artifact@v4
2525
with:
2626
name: debian_bullseye_x86_64_sysroot.tar.xz
2727
path: sysroot/out/sysroot-build/bullseye/debian_bullseye_amd64_sysroot.tar.xz
2828

29-
- uses: bazelbuild/setup-bazelisk@v2
29+
- uses: bazel-contrib/setup-bazel@0.15.0
3030

3131
- name: Mount bazel cache
32-
uses: actions/cache@v1
32+
uses: actions/cache@v4
3333
with:
3434
path: "~/.cache/bazel"
3535
key: bazel
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Release sysroot
4444
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
45-
uses: svenstaro/upload-release-action@v1-release
45+
uses: svenstaro/upload-release-action@v2
4646
with:
4747
repo_token: ${{ secrets.GITHUB_TOKEN }}
4848
file: "sysroot/out/sysroot-build/bullseye/debian_bullseye_amd64_sysroot.tar.xz"

sysroot/generated_package_lists/bullseye.amd64

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/l
22
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libgcc-s1_10.2.1-6_amd64.deb
33
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++-10-dev_10.2.1-6_amd64.deb
44
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++6_10.2.1-6_amd64.deb
5-
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_amd64.deb
65
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6-dev_2.31-13+deb11u5_amd64.deb
7-
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_amd64.deb
6+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_amd64.deb
87
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas-dev_3.9.0-3_amd64.deb
9-
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_amd64.deb
8+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_amd64.deb
109
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack-dev_3.9.0-3_amd64.deb
10+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_amd64.deb
1111
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/linux/linux-libc-dev_6.1.12-1~bpo11+1_amd64.deb
1212
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/u/util-linux/uuid-dev_2.36.1-8+deb11u1_amd64.deb

sysroot/generated_package_lists/bullseye.arm64

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/l
22
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libgcc-s1_10.2.1-6_arm64.deb
33
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++-10-dev_10.2.1-6_arm64.deb
44
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/gcc-10/libstdc++6_10.2.1-6_arm64.deb
5-
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_arm64.deb
65
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6-dev_2.31-13+deb11u5_arm64.deb
7-
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_arm64.deb
6+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/g/glibc/libc6_2.31-13+deb11u5_arm64.deb
87
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas-dev_3.9.0-3_arm64.deb
9-
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_arm64.deb
8+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/libblas3_3.9.0-3_arm64.deb
109
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack-dev_3.9.0-3_arm64.deb
10+
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/lapack/liblapack3_3.9.0-3_arm64.deb
1111
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/l/linux/linux-libc-dev_6.1.12-1~bpo11+1_arm64.deb
1212
https://snapshot.debian.org/archive/debian/20230329T085712Z/pool/main/u/util-linux/uuid-dev_2.36.1-8+deb11u1_arm64.deb

sysroot/sysroot-creator.sh

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#@ {amd64,i386,armhf,arm64,armel,mipsel,mips64el}
1212
#@
1313

14+
# partially synced with https://chromium.googlesource.com/chromium/src/+/e8df45bfd5386216b9b6ff178b26461902c7ae3a/build/linux/sysroot_scripts/sysroot-creator.sh
15+
16+
1417
######################################################################
1518
# Config
1619
######################################################################
@@ -450,35 +453,44 @@ InstallIntoSysroot() {
450453

451454
CleanupJailSymlinks() {
452455
Banner "Jail symlink cleanup"
453-
454456
SAVEDPWD=$(pwd)
455457
cd ${INSTALL_ROOT}
456458
local libdirs="lib usr/lib"
457459
if [ -d lib64 ]; then
458460
libdirs="${libdirs} lib64"
459461
fi
460-
461462
find $libdirs -type l -printf '%p %l\n' | while read link target; do
462463
# skip links with non-absolute paths
463464
echo "${target}" | grep -qs ^/ || continue
464465
echo "${link}: ${target}"
465-
# Relativize the symlink.
466-
prefix=$(echo "${link}" | sed -e 's/[^/]//g' | sed -e 's|/|../|g')
467-
ln -snfv "${prefix}${target}" "${link}"
466+
case "${link}" in
467+
usr/lib/gcc/*-linux-gnu/4.*/* | usr/lib/gcc/arm-linux-gnueabihf/4.*/* | \
468+
usr/lib/gcc/aarch64-linux-gnu/4.*/*)
469+
# Relativize the symlink.
470+
ln -snfv "../../../../..${target}" "${link}"
471+
;;
472+
usr/lib/*-linux-gnu/* | usr/lib/arm-linux-gnueabihf/*)
473+
# Relativize the symlink.
474+
ln -snfv "../../..${target}" "${link}"
475+
;;
476+
usr/lib/*)
477+
# Relativize the symlink.
478+
ln -snfv "../..${target}" "${link}"
479+
;;
480+
lib64/* | lib/*)
481+
# Relativize the symlink."
482+
ln -snfv "..${target}" "${link}"
483+
;;
484+
esac
468485
done
469-
470-
failed=0
471-
while read link target; do
486+
find $libdirs -type l -printf '%p %l\n' | while read link target; do
472487
# Make sure we catch new bad links.
473488
if [ ! -r "${link}" ]; then
474489
echo "ERROR: FOUND BAD LINK ${link}"
475490
ls -l ${link}
476-
failed=1
491+
#exit 1
477492
fi
478-
done < <(find $libdirs -type l -printf '%p %l\n')
479-
if [ $failed -eq 1 ]; then
480-
exit 1
481-
fi
493+
done
482494
cd "$SAVEDPWD"
483495
}
484496

@@ -513,7 +525,7 @@ BuildSysroot() {
513525
StripChecksumsFromPackageList "$package_file"
514526
InstallIntoSysroot ${files_and_sha256sums}
515527
HacksAndPatches
516-
# CleanupJailSymlinks
528+
CleanupJailSymlinks
517529
# VerifyLibraryDeps
518530
CreateTarBall
519531
}

0 commit comments

Comments
 (0)