Skip to content

Make riscv64 / ppc64le / loongarch64 sysroots PIE-ready#43

Open
nikitamikhaylov wants to merge 3 commits intomasterfrom
pie-ready-linux-sysroots
Open

Make riscv64 / ppc64le / loongarch64 sysroots PIE-ready#43
nikitamikhaylov wants to merge 3 commits intomasterfrom
pie-ready-linux-sysroots

Conversation

@nikitamikhaylov
Copy link
Copy Markdown
Member

  • riscv64: add librt.so -> librt.so.1 symlink so -lrt resolves to the shared library instead of falling back to the non-PIC librt.a, which would otherwise emit R_RISCV_HI20/LO12 errors under -pie.
  • ppc64le: add Scrt1.o from Debian trixie libc6-dev-ppc64el-cross (2.41-11cross1) so linking with -pie no longer fails at 'cannot open Scrt1.o'.
  • loongarch64: same, from libc6-dev-loong64-cross. Add refresh-linux-sysroot.sh so the procedure can be re-run later.

- riscv64: add librt.so -> librt.so.1 symlink so -lrt resolves to the
  shared library instead of falling back to the non-PIC librt.a, which
  would otherwise emit R_RISCV_HI20/LO12 errors under -pie.
- ppc64le: add Scrt1.o from Debian trixie libc6-dev-ppc64el-cross
  (2.41-11cross1) so linking with -pie no longer fails at
  'cannot open Scrt1.o'.
- loongarch64: same, from libc6-dev-loong64-cross.
Add refresh-linux-sysroot.sh so the procedure can be re-run later.
Drop Scrt1.o, crtbeginS.o, crtendS.o extracted from FreeBSD
13.5-RELEASE base.txz into each FreeBSD sysroot. Without them,
linking with -pie fails at 'cannot open Scrt1.o' (and for
freebsd-x86_64 also 'crtbeginS.o' / 'crtendS.o').
Also extend refresh-freebsd-sysroot.sh to copy the PIE startup
objects as part of a full refresh so this doesn't regress next
time the sysroot is regenerated, and bump the URL examples to
13.5-RELEASE (13.4 was removed from the mirror) with the
corrected /releases/powerpc/powerpc64le/... path.
Add rcrt1.o (from Alpine musl-dev 1.2.5-r23) and crtbeginS.o /
crtendS.o (from Alpine gcc-15.2.0-r2 libgcc) to
linux-x86_64-musl/lib/. Combined with '-static-pie' in the
ClickHouse build, this lets clang's driver pick these PIC variants
instead of the non-PIC crtbeginT.o / crtend.o static-exe CRT, and
lld then successfully emits a static Position-Independent
Executable. The existing musl libc.a / crt1.o / crti.o / crtn.o
were already PIC-clean and are used unchanged.
Also extend refresh-linux-sysroot.sh with a 'x86_64-musl' target
so the procedure can be re-run later.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant