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

LLD does not support the triple version of OUTPUT_FORMAT #1025

Closed
tpimh opened this issue May 15, 2020 · 8 comments
Closed

LLD does not support the triple version of OUTPUT_FORMAT #1025

tpimh opened this issue May 15, 2020 · 8 comments
Assignees
Labels
[ARCH] arm64 This bug impacts ARCH=arm64 [ARCH] mips This bug impacts ARCH=mips [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x [TOOL] lld The issue is relevant to LLD linker

Comments

@tpimh
Copy link

tpimh commented May 15, 2020

ld.lld: error: arch/mips/vdso/elf.o is incompatible with elf32-tradlittlemips
ld.lld: error: arch/mips/vdso/vgettimeofday.o is incompatible with elf32-tradlittlemips
ld.lld: error: arch/mips/vdso/sigreturn.o is incompatible with elf32-tradlittlemips

Travis CI

@tpimh tpimh added [TOOL] lld The issue is relevant to LLD linker [BUG] linux-next This is an issue only seen in linux-next [ARCH] mips This bug impacts ARCH=mips labels May 15, 2020
@nathanchance
Copy link
Member

This is expected with the series to fix #785 because ld.lld does not support OUTPUT_FORMAT in a triple format, which is how the VDSO handles the flip between big and little endian:

llvm/llvm-project@ea8cd00

https://github.com/torvalds/linux/blob/f85c1598ddfe83f61d0656bd1d2025fa3b148b99/arch/mips/vdso/vdso.lds.S#L10

@nathanchance nathanchance added [BUG] llvm A bug that should be fixed in upstream LLVM and removed [BUG] linux-next This is an issue only seen in linux-next labels May 15, 2020
@nathanchance
Copy link
Member

So, we could in theory work around this in the kernel's Makefile by messing with the emulation value (-m); however, I do not think that is proper.

However, as it stands now, just adding support the triple version of OUTPUT_FORMAT might not currently work as #30 seems to indicate that -m has higher priority for ld.lld. This would not necessarily be an issue for the default VDSO targets since the kernel wide emulation target matches the OUTPUT_FORMAT value. It would be a problem for CONFIG_MIPS32_O32 and CONFIG_MIPS32_N32, which are the other options that the other OUTPUT_FORMAT directives deal with.

I can file a bug upstream to ask for clarification on this and what needs to be done to support this with ld.lld. For now, to unlock CI,I will push a patch to move big endian MIPS to ld.bfd.

nathanchance added a commit to nathanchance/continuous-integration that referenced this issue May 17, 2020
The series to fix ClangBuiltLinux/linux#785
exposed an issue with ld.lld, which breaks the build.

Move this target to ld.bfd while we discuss how to fix it so that this
target is not blocked for testing.

[skip ci]

Link: ClangBuiltLinux/linux#1025
Presubmit:
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
nathanchance added a commit to nathanchance/continuous-integration that referenced this issue May 17, 2020
The series to fix ClangBuiltLinux/linux#785
exposed an issue with ld.lld, which breaks the build.

Move this target to ld.bfd while we discuss how to fix it so that this
target is not blocked for testing.

[skip ci]

Link: ClangBuiltLinux/linux#1025
Presubmit: https://travis-ci.com/github/nathanchance/continuous-integration/builds/166566747
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
@nickdesaulniers
Copy link
Member

cc @MaskRay know anything about this target triple (elf32-tradlittlemips) if that's something LLD could support?

@nathanchance nathanchance changed the title Objects incompatible with elf32-tradlittlemips when linking MIPS vDSO with LLD LLD does not support the triple version of OUTPUT_FORMAT Feb 6, 2021
@nathanchance
Copy link
Member

I have updated the title of this to reflect that this does not just affect MIPS: #1288 (comment)

@nathanchance nathanchance added the [ARCH] arm64 This bug impacts ARCH=arm64 label Feb 6, 2021
@MaskRay
Copy link
Member

MaskRay commented Feb 6, 2021

Hope https://reviews.llvm.org/D96214 helps mips, too.

@nathanchance
Copy link
Member

I can confirm that D96214 resolves all of these issues :) thank you!

$  git -C "${CBL_GIT}"/tc-build/llvm-project lo -4
f495851a5b97 (HEAD -> main) [ELF] Inspect -EL & -EB for OUTPUT_FORMAT(default, big, little)
a12f54a8f216 [ELF] Support aarch64_be
bdac31815cf0 [llvm-objdump] Support PLT decoding for aarch64_be
14da287e1884 (origin/main, origin/HEAD) [ConstraintElimination] Extend test coverage.

ARCH=arm64:

$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 O=build/arm64be defconfig

$ scripts/config --file build/arm64be/.config -d CPU_LITTLE_ENDIAN -e CPU_BIG_ENDIAN

$ make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 O=build/arm64be olddefconfig Image.gz
ld.lld: error: unknown emulation: aarch64linuxb
...

$ PATH=${CBL_GIT}/tc-build/build/llvm/stage1/bin:${PATH} make -skj"$(nproc)" ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LLVM=1 O=build/arm64be olddefconfig Image.gz

$ "${CBL_GIT}"/boot-utils/boot-qemu.sh -a arm64be -k build/arm64be -t 20s
...
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510]
[    0.000000] Linux version 5.11.0-rc6-00274-g825b5991a46e (nathan@ubuntu-m3-large-x86) (ClangBuiltLinux clang version 13.0.0 (https://github.com/llvm/llvm-project f495851a5b97a83a3e09eda4ccdb868830993a96),
LLD 13.0.0 (https://github.com/llvm/llvm-project f495851a5b97a83a3e09eda4ccdb868830993a96)) #1 SMP PREEMPT Sat Feb 6 18:35:17 MST 2021
...

ARCH=mips:

$ make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux-gnu- LLVM=1 O=build/mips malta_kvm_guest_defconfig

$ scripts/config --file build/mips/.config -d CPU_LITTLE_ENDIAN -e CPU_BIG_ENDIAN

$ make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux-gnu- LLVM=1 O=build/mips olddefconfig vmlinux
ld.lld: error: arch/mips/vdso/elf.o is incompatible with elf32-tradlittlemips
ld.lld: error: arch/mips/vdso/vgettimeofday.o is incompatible with elf32-tradlittlemips
ld.lld: error: arch/mips/vdso/sigreturn.o is incompatible with elf32-tradlittlemips
...

$ PATH=${CBL_GIT}/tc-build/build/llvm/stage1/bin:${PATH} make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux-gnu- LLVM=1 O=build/mips vmlinux

$ "${CBL_GIT}"/boot-utils/boot-qemu.sh -a mips-k build/mips -t 20s
...
Linux version 5.11.0-rc6-00274-g825b5991a46e (nathan@ubuntu-m3-large-x86) (ClangBuiltLinux clang version 13.0.0 (https://github.com/llvm/llvm-project f495851a5b97a83a3e09eda4ccdb868830993a96), LLD 13.0.0 (https://github.com/llvm/llvm-project f495851a5b97a83a3e09eda4ccdb868830993a96)) #1 Sat Feb 6 18:54:01 MST 2021
...
$ make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux-gnu- LLVM=1 O=build/mips64 distclean 64r2_defconfig

# https://github.com/ClangBuiltLinux/linux/issues/884
$ scripts/config --file build/mips64/.config -d MIPS32_O32

$ make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux-gnu- LLVM=1 O=build/mips64 olddefconfig arch/mips/vdso/
...
ld.lld: error: arch/mips/vdso/elf.o is incompatible with elf64-tradlittlemips
ld.lld: error: arch/mips/vdso/vgettimeofday.o is incompatible with elf64-tradlittlemips
ld.lld: error: arch/mips/vdso/sigreturn.o is incompatible with elf64-tradlittlemips
...
ld.lld: error: arch/mips/vdso/elf-n32.o is incompatible with elf32-ntradlittlemips
ld.lld: error: arch/mips/vdso/vgettimeofday-n32.o is incompatible with elf32-ntradlittlemips
ld.lld: error: arch/mips/vdso/sigreturn-n32.o is incompatible with elf32-ntradlittlemips
...

$ PATH=${CBL_GIT}/tc-build/build/llvm/stage1/bin:${PATH} make -skj"$(nproc)" ARCH=mips CROSS_COMPILE=mips-linux-gnu- LLVM=1 O=build/mips64 olddefconfig arch/mips/vdso/

@nickdesaulniers nickdesaulniers added the [PATCH] Submitted A patch has been submitted for review label Feb 8, 2021
@nickdesaulniers nickdesaulniers added [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x and removed [PATCH] Submitted A patch has been submitted for review labels Feb 8, 2021
@nickdesaulniers
Copy link
Member

Do we want to cherry pick this to 12.x branch?

@MaskRay
Copy link
Member

MaskRay commented Feb 9, 2021

LG for release/12.x if it caused problems. The change is pretty safe.

nathanchance added a commit to nathanchance/continuous-integration2 that referenced this issue Feb 10, 2021
Link: ClangBuiltLinux/linux#1025
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
nathanchance added a commit to ClangBuiltLinux/continuous-integration2 that referenced this issue Feb 11, 2021
Link: ClangBuiltLinux/linux#1025
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Choose big if -EB is specified, little if -EL is specified, or default if neither is specified.
The new behavior matches GNU ld.

Fixes: ClangBuiltLinux/linux#1025

Differential Revision: https://reviews.llvm.org/D96214
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[ARCH] arm64 This bug impacts ARCH=arm64 [ARCH] mips This bug impacts ARCH=mips [BUG] llvm A bug that should be fixed in upstream LLVM [FIXED][LLVM] 13 This bug was fixed in LLVM 13.x [TOOL] lld The issue is relevant to LLD linker
Projects
None yet
Development

No branches or pull requests

4 participants