Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rootfs] Add GCC 14.2 and make it default for riscv64 #403

Merged
merged 3 commits into from
Jan 12, 2025

Conversation

giordano
Copy link
Member

@giordano giordano commented Jan 12, 2025

GCC 14 has support for the RISV-V Vector Extension 1.0 (RVV1.0), which is important for packages like OpenBLAS. riscv64 is still niche enough that it's OK to use a more recent, but also more capable, version of GCC as default one.

Companion PR to JuliaPackaging/Yggdrasil#10132.

Fix #398.

@giordano
Copy link
Member Author

 --> Mapping 1001:118 to root:root within container namespace
--> Creating overlay workdir at /proc
At line 572, ABORTED (13: Permission denied)!
Child Process exited, exit code 1

Sigh. Will try to downgrade to ubuntu 22.04

@giordano giordano force-pushed the mg/gcc14 branch 2 times, most recently from b38f249 to a89fd1b Compare January 12, 2025 11:11
@giordano
Copy link
Member Author

ld.lld: error: undefined symbol: __libc_start_main
>>> referenced by start.S:53 (../sysdeps/riscv/start.S:53)
>>>               /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib64/lp64d/Scrt1.o:(_start)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compilation - Linux riscv64 {libc=glibc} - clang: Test Failed at /home/runner/work/BinaryBuilderBase.jl/BinaryBuilderBase.jl/test/runners.jl:192

wut

@giordano
Copy link
Member Author

giordano commented Jan 12, 2025

An update: by comparing this with the GCC 14 toolchain

sandbox:${WORKSPACE} # echo 'int main() { return 0; }' | clang -x c - -o test -Wl,-t
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib64/lp64d/Scrt1.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crti.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crtbeginS.o
/tmp/--12143a.o
/opt/riscv64-linux-gnu/riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib/../lib64/libc.so
/opt/riscv64-linux-gnu/riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crtendS.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crtn.o
ld.lld: error: undefined symbol: __libc_start_main
>>> referenced by start.S:53 (../sysdeps/riscv/start.S:53)
>>>               /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib64/lp64d/Scrt1.o:(_start)
clang: error: linker command failed with exit code 1 (use -v to see invocation)

sandbox:${WORKSPACE} # echo 'int main() { return 0; }' | gcc -x c - -o test -Wl,-t
/opt/riscv64-linux-gnu/bin/../riscv64-linux-gnu/sys-root/usr/lib64/lp64d/crt1.o
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/crti.o
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/crtbegin.o
/tmp/cclffLPd.o
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/libgcc.a
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/../../../../riscv64-linux-gnu/lib/libgcc_s.so
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/../../../../riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/libgcc.a
/opt/riscv64-linux-gnu/bin/../riscv64-linux-gnu/sys-root/usr/lib64/lp64d/libc.so
/opt/riscv64-linux-gnu/bin/../riscv64-linux-gnu/sys-root/lib64/lp64d/libc.so.6
/opt/riscv64-linux-gnu/bin/../riscv64-linux-gnu/sys-root/usr/lib64/lp64d/libc_nonshared.a
/opt/riscv64-linux-gnu/bin/../riscv64-linux-gnu/sys-root/lib/ld-linux-riscv64-lp64d.so.1
/opt/riscv64-linux-gnu/bin/../riscv64-linux-gnu/sys-root/usr/lib64/lp64d/libc_nonshared.a
/opt/riscv64-linux-gnu/bin/../riscv64-linux-gnu/sys-root/lib/ld-linux-riscv64-lp64d.so.1
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/libgcc.a
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/../../../../riscv64-linux-gnu/lib/libgcc_s.so
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/../../../../riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/libgcc.a
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/crtend.o
/opt/riscv64-linux-gnu/bin/../lib/gcc/riscv64-linux-gnu/14.2.0/crtn.o

and this with GCC 13:

sandbox:${WORKSPACE} # echo 'int main() { return 0; }' | clang -x c - -o test -Wl,-t
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib64/lp64d/Scrt1.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/13.2.0/crti.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/13.2.0/crtbeginS.o
/tmp/--1ee62c.o
/opt/riscv64-linux-gnu/riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/lib64/lp64d/libc.so.6
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/lib/ld-linux-riscv64-lp64d.so.1
/opt/riscv64-linux-gnu/riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/13.2.0/crtendS.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/13.2.0/crtn.o

I believe the issue is that clang with GCC 14 is trying to link to the wrong libc.so, it's using /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib/../lib64/libc.so instead of /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/lib64/lp64d/libc.so.6, and the former is basically empty, while the latter is the real one:

sandbox:${WORKSPACE} # nm /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib/../lib64/libc.so
0000000000001f08 a _DYNAMIC
0000000000001ff8 a _GLOBAL_OFFSET_TABLE_
00000000000001e0 a _PROCEDURE_LINKAGE_TABLE_
sandbox:${WORKSPACE} # nm /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/lib64/lp64d/libc.so.6|grep __libc_start_main
0000000000026636 T __libc_start_main@@GLIBC_2.34
0000000000026636 T __libc_start_main@GLIBC_2.27
0000000000026636 t __libc_start_main_alias_1
0000000000026636 t __libc_start_main_alias_2
0000000000026636 t __libc_start_main_impl

I believe we can just delete the extra dummy libc.so to avoid confusing the compilers:

sandbox:${WORKSPACE} # echo 'int main() { return 0; }' | clang -x c - -o test
ld.lld: error: undefined symbol: __libc_start_main
>>> referenced by start.S:53 (../sysdeps/riscv/start.S:53)
>>>               /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib64/lp64d/Scrt1.o:(_start)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
sandbox:${WORKSPACE} # rm /opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib/../lib64/libc.so
sandbox:${WORKSPACE} # echo 'int main() { return 0; }' | clang -x c - -o test -Wl,-t
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/usr/lib64/lp64d/Scrt1.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crti.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crtbeginS.o
/tmp/--d0737a.o
/opt/riscv64-linux-gnu/riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/lib64/lp64d/libc.so.6
/opt/riscv64-linux-gnu/riscv64-linux-gnu/sys-root/lib/ld-linux-riscv64-lp64d.so.1
/opt/riscv64-linux-gnu/riscv64-linux-gnu/lib/libgcc_s.so.1
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crtendS.o
/opt/riscv64-linux-gnu/lib/gcc/riscv64-linux-gnu/14.2.0/crtn.o
sandbox:${WORKSPACE} # file test
test: ELF 64-bit LSB pie executable, UCB RISC-V, RVC, double-float ABI, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped

I don't see similar duplicates for the other architectures, no clue why it was created for riscv64.

GCC 14 has support for the RISV-V Vector Extension 1.0 (RVV1.0), which is
important for packages like OpenBLAS.  `riscv64` is still niche enough that it's
OK to use a more recent, but also more capable, version of GCC as default one.
We [skip ci] because we don't actually use it anywhere at the moment, but we
just have it.
@giordano giordano merged commit bcde7e8 into JuliaPackaging:master Jan 12, 2025
@giordano giordano deleted the mg/gcc14 branch January 12, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide GCC 14
1 participant