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

arch/powerpc/boot/wrapper hard codes GNU tools #1601

Open
nathanchance opened this issue Feb 21, 2022 · 5 comments
Open

arch/powerpc/boot/wrapper hard codes GNU tools #1601

nathanchance opened this issue Feb 21, 2022 · 5 comments
Assignees
Labels
[ARCH] powerpc This bug impacts ARCH=powerpc [BUG] linux A bug that should be fixed in the mainline kernel. hermetic builds has implications for doing gcc/binutils-free builds [PATCH] Exists There is a patch that fixes this issue

Comments

@nathanchance
Copy link
Member

I have split this off from ClangBuiltLinux/continuous-integration2#265, as we are tracking the other issue I noted in that thread as #774.

With D115419 applied to the toolchain and the following diff to quickly work around #774:

diff --git a/arch/powerpc/kernel/vdso64/Makefile b/arch/powerpc/kernel/vdso64/Makefile
index 3c5baaa6f1e7..45dc62ba1541 100644
--- a/arch/powerpc/kernel/vdso64/Makefile
+++ b/arch/powerpc/kernel/vdso64/Makefile
@@ -39,6 +39,8 @@ asflags-y := -D__VDSO64__ -s
 targets += vdso64.lds
 CPPFLAGS_vdso64.lds += -P -C -U$(ARCH)

+vdsold-$(CONFIG_LD_IS_LLD) := -fuse-ld=lld
+
 # link rule for the .so file, .lds has to be first
 $(obj)/vdso64.so.dbg: $(src)/vdso64.lds $(obj-vdso64) $(obj)/vgettimeofday.o FORCE
        $(call if_changed,vdso64ld_and_check)
@@ -53,4 +55,4 @@ include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE

 # actual build commands
 quiet_cmd_vdso64ld_and_check = VDSO64L $@
-      cmd_vdso64ld_and_check = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check)
+      cmd_vdso64ld_and_check = $(CC) $(c_flags) $(vdsold-y) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check)
$ make -skj"$(nproc)" ARCH=powerpc LLVM=1 powernv_defconfig all
ld.lld: warning: cannot find entry symbol _start; not setting start address
objcopy: Unable to recognise the format of the input file `vmlinux'
make[2]: *** [arch/powerpc/boot/Makefile:391: arch/powerpc/boot/zImage.pseries] Error 1
objcopy: Unable to recognise the format of the input file `vmlinux'
make[2]: *** [arch/powerpc/boot/Makefile:391: arch/powerpc/boot/zImage.epapr] Error 1
make[2]: Target 'arch/powerpc/boot/zImage' not remade because of errors.
make[1]: *** [arch/powerpc/Makefile:283: zImage] Error 2

CROSS_COMPILE is used in arch/powerpc/boot/wrapper to prefix the GNU tools:

$ rg -F '${CROSS}' arch/powerpc/boot/wrapper
196:LC_ALL=C elfformat="`${CROSS}objdump -p "$kernel" | grep 'file format' | awk '{print $4}'`"
220:LD_VERSION=$(${CROSS}ld --version | ld_version)
366:    rodynamic=$(if ${CROSS}ld -V 2>&1 | grep -q LLD ; then echo "-z rodynamic"; fi)
382:${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
435:version=`${CROSS}strings "$kernel" | grep '^Linux version [-0-9.]' | \
442:membase=`${CROSS}objdump -p "$kernel" | grep -m 1 LOAD | awk '{print $7}'`
477:    ${CROSS}objcopy $4 $1 \
507:    ${CROSS}ld -m $format -T $lds $text_start $pie $nodl $rodynamic $notext -o "$ofile" $map \
513:base=0x`${CROSS}nm "$ofile" | grep ' _start$' | cut -d' ' -f1`
514:entry=`${CROSS}objdump -f "$ofile" | grep '^start address ' | cut -d' ' -f3`
518:    ${CROSS}objcopy -O binary "$ofile".elf "$ofile"
527:    ${CROSS}objcopy -O aixcoff-rs6000 --set-start "$entry" "$ofile"
555:    system_reset_overlay=0x`${CROSS}nm "$ofile" \
559:    system_reset_kernel=0x`${CROSS}nm "$ofile" \
566:    ${CROSS}objcopy -O binary "$ofile" "$ofile.bin"
584:    size=$(${CROSS}nm --no-sort --radix=d "$ofile" | egrep ' _end$' | cut -d' ' -f1)

I have a prototype series to fix this: https://git.kernel.org/pub/scm/linux/kernel/git/nathan/linux.git/log/?h=wip/llvm-1-powerpc-boot-wrapper

The original CI issue above has a couple of errors that were uncovered, hence the other patches in the series.

@nathanchance nathanchance added [BUG] linux A bug that should be fixed in the mainline kernel. [PATCH] Exists There is a patch that fixes this issue [ARCH] powerpc This bug impacts ARCH=powerpc hermetic builds has implications for doing gcc/binutils-free builds labels Feb 21, 2022
@nickdesaulniers
Copy link
Member

now that #774 is resolved, anything left to do here?

@nickdesaulniers
Copy link
Member

nickdesaulniers commented Aug 25, 2023

I can still reproduce this failure. @nathanchance do you have cycles to dust off your series and whip it into shape for upstreaming?

$ make LLVM=1 ARCH=powerpc defconfig all -j128 -s
objcopy: Unable to recognise the format of the input file `vmlinux'
objcopy: Unable to recognise the format of the input file `vmlinux'
objcopy: Unable to recognise the format of the input file `vmlinux'
objcopy: Unable to recognise the format of the input file `vmlinux'
objcopy: Unable to recognise the format of the input file `vmlinux'
make[3]: *** [arch/powerpc/boot/Makefile:399: arch/powerpc/boot/zImage.epapr] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [arch/powerpc/boot/Makefile:399: arch/powerpc/boot/zImage.maple] Error 1
make[3]: *** [arch/powerpc/boot/Makefile:399: arch/powerpc/boot/zImage.pmac] Error 1
make[3]: *** [arch/powerpc/boot/Makefile:399: arch/powerpc/boot/zImage.pseries] Error 1
make[3]: *** [arch/powerpc/boot/Makefile:406: arch/powerpc/boot/dtbImage.ps3] Error 1
make[2]: *** [arch/powerpc/Makefile:235: zImage] Error 2
make[1]: *** [/android0/kernel-all/Makefile:359: __build_one_by_one] Error 2
make: *** [Makefile:234: __sub-make] Error 2

Jason asked about ppc here, so he might be observing this build failure for the defconfig as well.

@nathanchance
Copy link
Member Author

I can still reproduce this failure. @nathanchance do you have cycles to dust off your series and whip it into shape for upstreaming?

Yeah, I will do my best to get the series into a shippable state for 6.7.

@nickdesaulniers
Copy link
Member

#774 might be relevant here. I thought #774 (comment) might have fixed this already, or at least allow you to drop the first patch from your series perhaps?

@nathanchance
Copy link
Member Author

Yeah, that patch is no longer necessary with https://git.kernel.org/linus/4406b12214f6592909b63dabdea86d69f1b5ba2e. I think the rest are still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] powerpc This bug impacts ARCH=powerpc [BUG] linux A bug that should be fixed in the mainline kernel. hermetic builds has implications for doing gcc/binutils-free builds [PATCH] Exists There is a patch that fixes this issue
Projects
None yet
Development

No branches or pull requests

2 participants