Skip to contentSkip to conversation

Revert "arm64: Use aarch64elf and aarch64elfb emulation mode variants"

PATCH Superseded Laura Abbott 7 participants 16 messages Jul 9, 2018 – Jul 19, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Revert "arm64: Use aarch64elf and aarch64elfb emulation mode variants"

This reverts commit 38fc4248677552ce35efc09902fdcb06b61d7ef9.

This breaks compilation with Fedora gcc-8 tool chains:

CHK include/generated/compile.h
LD [M] arch/arm64/crypto/sha512-ce.o
aarch64-linux-gnu-ld: cannot open linker script file ldscripts/aarch64elf.xr: No such file or directory make[1]: *** [scripts/Makefile.build:530: arch/arm64/crypto/sha512-ce.o] Error 1
make: *** [Makefile:1029: arch/arm64/crypto] Error 2

Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")

---
A bit rushed and I'm still debugging but I wanted to send this out before anyone else gets hit since it is -rc4. Seeing this on both native and cross compiles.

---
 arch/arm64/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/Makefile +2 -2
index 7976d2d242fa..f476d52ad8d6 100644
@@ -60,13 +60,13 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
 CHECKFLAGS	+= -D__AARCH64EB__
 AS		+= -EB
-LDFLAGS		+= -EB -maarch64elfb
+LDFLAGS		+= -EB -maarch64linuxb
 UTS_MACHINE	:= aarch64_be
 else
 KBUILD_CPPFLAGS	+= -mlittle-endian
 CHECKFLAGS	+= -D__AARCH64EL__
 AS		+= -EL
-LDFLAGS		+= -EL -maarch64elf
+LDFLAGS		+= -EL -maarch64linux
 UTS_MACHINE	:= aarch64
 endif
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 10 lines · Laura Abbott

This reverts commit 38fc4248677552ce35efc09902fdcb06b61d7ef9.

This breaks compilation with Fedora gcc-8 tool chains:

   CHK     include/generated/compile.h
   LD [M]  arch/arm64/crypto/sha512-ce.o

aarch64-linux-gnu-ld: cannot open linker script file ldscripts/aarch64elf.xr: No such file or directory make[1]: *** [scripts/Makefile.build:530: arch/arm64/crypto/sha512-ce.o] Error 1
make: *** [Makefile:1029: arch/arm64/crypto] Error 2

Quoted 6 lines
Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")

---
A bit rushed and I'm still debugging but I wanted to send this out before anyone else gets hit since it is -rc4. Seeing this on both native and cross compiles.

The answer appears to be that Fedora binutils does not package the assembly scripts. The logic behind this is not immediately obvious but it's been removed since 2004. Obviously this is a packaging issue on Fedora's side but I'd still like to revert since it is a build breakage and fixing this might require some coordination. I'll send a v2 with clarified commit text if there's agreement.

Thanks,
Laura

Quoted 25 lines
---
  arch/arm64/Makefile | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/Makefile +2 -2
index 7976d2d242fa..f476d52ad8d6 100644
@@ -60,13 +60,13 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
  KBUILD_CPPFLAGS	+= -mbig-endian
  CHECKFLAGS	+= -D__AARCH64EB__
  AS		+= -EB
-LDFLAGS		+= -EB -maarch64elfb
+LDFLAGS		+= -EB -maarch64linuxb
  UTS_MACHINE	:= aarch64_be
  else
  KBUILD_CPPFLAGS	+= -mlittle-endian
  CHECKFLAGS	+= -D__AARCH64EL__
  AS		+= -EL
-LDFLAGS		+= -EL -maarch64elf
+LDFLAGS		+= -EL -maarch64linux
  UTS_MACHINE	:= aarch64
  endif
 
Tested-by
#2 lore raw
Quoted 19 lines · Laura Abbott
Quoted 10 lines · Laura Abbott

This reverts commit 38fc4248677552ce35efc09902fdcb06b61d7ef9.

This breaks compilation with Fedora gcc-8 tool chains:

   CHK     include/generated/compile.h
   LD [M]  arch/arm64/crypto/sha512-ce.o

aarch64-linux-gnu-ld: cannot open linker script file ldscripts/aarch64elf.xr: No such file or directory make[1]: *** [scripts/Makefile.build:530: arch/arm64/crypto/sha512-ce.o] Error 1
make: *** [Makefile:1029: arch/arm64/crypto] Error 2

Quoted 6 lines
Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")

---
A bit rushed and I'm still debugging but I wanted to send this out before anyone else gets hit since it is -rc4. Seeing this on both native and cross compiles.

Quoted 6 lines

The answer appears to be that Fedora binutils does not package the assembly scripts. The logic behind this is not immediately obvious but it's been removed since 2004. Obviously this is a packaging issue on Fedora's side but I'd still like to revert since it is a build breakage and fixing this might require some coordination. I'll send a v2 with clarified commit text if there's agreement.

FWIW, the build is broken with debian packaged toolchain also. I noticed it on stretch[1], and this patch gets things building again.

Kevin

[1]

$ aarch64-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/6/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian
6.3.0-18' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++
--prefix=/usr --program-suffix=-6 --enable-shared
--enable-linker-build-id --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --libdir=/usr/lib
--enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-libquadmath --enable-plugin --enable-default-pie
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-arm64-cross/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-arm64-cross
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-arm64-cross
--with-arch-directory=aarch64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj
--enable-multiarch --enable-fix-cortex-a53-843419
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=aarch64-linux-gnu
--program-prefix=aarch64-linux-gnu-
--includedir=/usr/aarch64-linux-gnu/include
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18)
#3 lore raw
In reply to Laura Abbott

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

Will

Quoted 43 lines · Laura Abbott

This reverts commit 38fc4248677552ce35efc09902fdcb06b61d7ef9.

This breaks compilation with Fedora gcc-8 tool chains:

CHK include/generated/compile.h
LD [M] arch/arm64/crypto/sha512-ce.o
aarch64-linux-gnu-ld: cannot open linker script file ldscripts/aarch64elf.xr: No such file or directory make[1]: *** [scripts/Makefile.build:530: arch/arm64/crypto/sha512-ce.o] Error 1
make: *** [Makefile:1029: arch/arm64/crypto] Error 2

Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")

---
A bit rushed and I'm still debugging but I wanted to send this out before anyone else gets hit since it is -rc4. Seeing this on both native and cross compiles.

---
 arch/arm64/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/Makefile +2 -2
index 7976d2d242fa..f476d52ad8d6 100644
@@ -60,13 +60,13 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
 CHECKFLAGS	+= -D__AARCH64EB__
 AS		+= -EB
-LDFLAGS		+= -EB -maarch64elfb
+LDFLAGS		+= -EB -maarch64linuxb
 UTS_MACHINE	:= aarch64_be
 else
 KBUILD_CPPFLAGS	+= -mlittle-endian
 CHECKFLAGS	+= -D__AARCH64EL__
 AS		+= -EL
-LDFLAGS		+= -EL -maarch64elf
+LDFLAGS		+= -EL -maarch64linux
 UTS_MACHINE	:= aarch64
 endif
 
Signature · 1 line
2.17.1
#4 lore raw

Hi,

Quoted 4 lines · Will Deacon

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

So this comes down to either breaking fedora/debian toolchains (that don't support elf emulation mode) or breaking bare-metal toolchains (that don't support linux emulation mode).

Since Linux is a bare-metal project that does not technically require the linux target (who said using "Linux" for all things is confusing?), I think it should aim for the elf target in the long term.

But well, breaking Linux build in common distros isn't good either, so I guess it makes sense to revert this while distros toolchains are being fixed. Hopefully, it won't take too long.

What do you think?

Cheers,

Paul

Quoted 46 lines

Will

Quoted 43 lines · Laura Abbott

This reverts commit 38fc4248677552ce35efc09902fdcb06b61d7ef9.

This breaks compilation with Fedora gcc-8 tool chains:

CHK include/generated/compile.h
LD [M] arch/arm64/crypto/sha512-ce.o
aarch64-linux-gnu-ld: cannot open linker script file ldscripts/aarch64elf.xr: No such file or directory make[1]: *** [scripts/Makefile.build:530: arch/arm64/crypto/sha512-ce.o] Error 1
make: *** [Makefile:1029: arch/arm64/crypto] Error 2

Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")

---
A bit rushed and I'm still debugging but I wanted to send this out before anyone else gets hit since it is -rc4. Seeing this on both native and cross compiles.

---
 arch/arm64/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/Makefile +2 -2
index 7976d2d242fa..f476d52ad8d6 100644
@@ -60,13 +60,13 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
 CHECKFLAGS	+= -D__AARCH64EB__
 AS		+= -EB
-LDFLAGS		+= -EB -maarch64elfb
+LDFLAGS		+= -EB -maarch64linuxb
 UTS_MACHINE	:= aarch64_be
 else
 KBUILD_CPPFLAGS	+= -mlittle-endian
 CHECKFLAGS	+= -D__AARCH64EL__
 AS		+= -EL
-LDFLAGS		+= -EL -maarch64elf
+LDFLAGS		+= -EL -maarch64linux
 UTS_MACHINE	:= aarch64
 endif
 
Signature · 1 line
2.17.1
Signature · 5 lines
Developer of free digital technology and hardware support.

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/
#5 lore raw
Quoted 14 lines · Paul Kocialkowski
Quoted 4 lines · Will Deacon

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

So this comes down to either breaking fedora/debian toolchains (that don't support elf emulation mode) or breaking bare-metal toolchains (that don't support linux emulation mode).

Since Linux is a bare-metal project that does not technically require the linux target (who said using "Linux" for all things is confusing?), I think it should aim for the elf target in the long term.

Quoted 5 lines

But well, breaking Linux build in common distros isn't good either, so I guess it makes sense to revert this while distros toolchains are being fixed. Hopefully, it won't take too long.

What do you think?

Yes, we need to revert the change since it's a regression otherwise. I think the best course of action here would be to find a way that we can either tell the linker that it doesn't need the missing linker scripts because we're providing our own, or find a way to pass different LD flags depending on whether or not we have a linux toolchain.

For now, I've pushed the revert to for-next/fixes.

Will

#6 lore raw
Quoted 21 lines · Will Deacon
Quoted 14 lines · Paul Kocialkowski
Quoted 4 lines · Will Deacon

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

So this comes down to either breaking fedora/debian toolchains (that don't support elf emulation mode) or breaking bare-metal toolchains (that don't support linux emulation mode).

Since Linux is a bare-metal project that does not technically require the linux target (who said using "Linux" for all things is confusing?), I think it should aim for the elf target in the long term.

Quoted 5 lines

But well, breaking Linux build in common distros isn't good either, so I guess it makes sense to revert this while distros toolchains are being fixed. Hopefully, it won't take too long.

What do you think?

Quoted 7 lines

Yes, we need to revert the change since it's a regression otherwise. I think the best course of action here would be to find a way that we can either tell the linker that it doesn't need the missing linker scripts because we're providing our own, or find a way to pass different LD flags depending on whether or not we have a linux toolchain.

For now, I've pushed the revert to for-next/fixes.

Hi Will,

This is regressed in mainline as well. But I think we can just use a (slightly improved) ld-option here? I checked it for x86 regression since it uses the one-argument version. Patch is here, can you pick that up instead and get it in for 4.18-rc?

Thanks,

-Olof

Quoted 1 line

From 0d73b2d1774d5edce20aac919ba356b61d098646 Mon Sep 17 00:00:00 2001

From: Olof Johansson <[email protected]>
Date: Fri, 13 Jul 2018 07:56:11 -0700
Subject: [PATCH] arm64: Fix build on some toolchains

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")
---
 arch/arm64/Makefile    | 4 ++--
 scripts/Kbuild.include | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm64/Makefile +2 -2
index 7976d2d242fa..c5ce97f69731 100644
@@ -60,13 +60,13 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
 CHECKFLAGS	+= -D__AARCH64EB__
 AS		+= -EB
-LDFLAGS		+= -EB -maarch64elfb
+LDFLAGS		+= -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
 UTS_MACHINE	:= aarch64_be
 else
 KBUILD_CPPFLAGS	+= -mlittle-endian
 CHECKFLAGS	+= -D__AARCH64EL__
 AS		+= -EL
-LDFLAGS		+= -EL -maarch64elf
+LDFLAGS		+= -EL $(call ld-option, -maarch64elf, -maarch64linux)
 UTS_MACHINE	:= aarch64
 endif
 
scripts/Kbuild.include +2 -2
index c8156d61678c..1e13f502b42f 100644
@@ -163,8 +163,8 @@ cc-ldoption = $(call try-run,\
 	$(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
 
 # ld-option
-# Usage: LDFLAGS += $(call ld-option, -X)
-ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2))
+# Usage: LDFLAGS += $(call ld-option, -X, -Y)
+ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2),$(3))
 
 # ar-option
 # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
Signature · 1 line
2.11.0
#7 lore raw
Quoted 47 lines · Olof Johansson
Quoted 21 lines · Will Deacon
Quoted 14 lines · Paul Kocialkowski
Quoted 4 lines · Will Deacon

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

So this comes down to either breaking fedora/debian toolchains (that don't support elf emulation mode) or breaking bare-metal toolchains (that don't support linux emulation mode).

Since Linux is a bare-metal project that does not technically require the linux target (who said using "Linux" for all things is confusing?), I think it should aim for the elf target in the long term.

Quoted 5 lines

But well, breaking Linux build in common distros isn't good either, so I guess it makes sense to revert this while distros toolchains are being fixed. Hopefully, it won't take too long.

What do you think?

Quoted 7 lines

Yes, we need to revert the change since it's a regression otherwise. I think the best course of action here would be to find a way that we can either tell the linker that it doesn't need the missing linker scripts because we're providing our own, or find a way to pass different LD flags depending on whether or not we have a linux toolchain.

For now, I've pushed the revert to for-next/fixes.

Hi Will,

This is regressed in mainline as well. But I think we can just use a (slightly improved) ld-option here? I checked it for x86 regression since it uses the one-argument version. Patch is here, can you pick that up instead and get it in for 4.18-rc?

Thanks,

-Olof

From 0d73b2d1774d5edce20aac919ba356b61d098646 Mon Sep 17 00:00:00 2001
From: Olof Johansson <[email protected]>
Date: Fri, 13 Jul 2018 07:56:11 -0700
Subject: [PATCH] arm64: Fix build on some toolchains

Quoted 6 lines

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")

Of course, please add:

or other suitable tag. Sloppy of me to miss.

-Olof

#8 lore raw

Hi,

Quoted 52 lines · Olof Johansson
Quoted 51 lines · Olof Johansson
Quoted 21 lines · Will Deacon
Quoted 14 lines · Paul Kocialkowski
Quoted 4 lines · Will Deacon

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

So this comes down to either breaking fedora/debian toolchains (that don't support elf emulation mode) or breaking bare-metal toolchains (that don't support linux emulation mode).

Since Linux is a bare-metal project that does not technically require the linux target (who said using "Linux" for all things is confusing?), I think it should aim for the elf target in the long term.

Quoted 5 lines

But well, breaking Linux build in common distros isn't good either, so I guess it makes sense to revert this while distros toolchains are being fixed. Hopefully, it won't take too long.

What do you think?

Quoted 7 lines

Yes, we need to revert the change since it's a regression otherwise. I think the best course of action here would be to find a way that we can either tell the linker that it doesn't need the missing linker scripts because we're providing our own, or find a way to pass different LD flags depending on whether or not we have a linux toolchain.

For now, I've pushed the revert to for-next/fixes.

Hi Will,

This is regressed in mainline as well. But I think we can just use a (slightly improved) ld-option here? I checked it for x86 regression since it uses the one-argument version. Patch is here, can you pick that up instead and get it in for 4.18-rc?

Thanks,

-Olof

From 0d73b2d1774d5edce20aac919ba356b61d098646 Mon Sep 17 00:00:00 2001
From: Olof Johansson <[email protected]>
Date: Fri, 13 Jul 2018 07:56:11 -0700
Subject: [PATCH] arm64: Fix build on some toolchains

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

Quoted 7 lines
Quoted 2 lines
Fixes 38fc42486775 ("arm64: Use aarch64elf and aarch64elfb emulation mode variants")

Of course, please add:

or other suitable tag. Sloppy of me to miss.

Thanks for taking care of this patch!

I will definitely try it when I get the chance.

Cheers,

Paul

Signature · 5 lines
Developer of free digital technology and hardware support.

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/
#9 lore raw
In reply to Olof Johansson

Hi Olof,

Quoted 28 lines · Olof Johansson
Quoted 27 lines · Will Deacon
Quoted 14 lines · Paul Kocialkowski
Quoted 4 lines · Will Deacon

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

So this comes down to either breaking fedora/debian toolchains (that don't support elf emulation mode) or breaking bare-metal toolchains (that don't support linux emulation mode).

Since Linux is a bare-metal project that does not technically require the linux target (who said using "Linux" for all things is confusing?), I think it should aim for the elf target in the long term.

Quoted 5 lines

But well, breaking Linux build in common distros isn't good either, so I guess it makes sense to revert this while distros toolchains are being fixed. Hopefully, it won't take too long.

What do you think?

Yes, we need to revert the change since it's a regression otherwise. I think the best course of action here would be to find a way that we can either tell the linker that it doesn't need the missing linker scripts because we're providing our own, or find a way to pass different LD flags depending on whether or not we have a linux toolchain.

Quoted 8 lines
Quoted 1 line

For now, I've pushed the revert to for-next/fixes.

Hi Will,

This is regressed in mainline as well. But I think we can just use a (slightly improved) ld-option here? I checked it for x86 regression since it uses the one-argument version. Patch is here, can you pick that up instead and get it in for 4.18-rc?

I already sent the revert to Linus, but I can certainly queue the ld-option for 4.19 if we pick up some more tested-bys. Could you send it out as its own patch please?

Cheers,

Will

#10 lore raw
Quoted 35 lines · Will Deacon

Hi Olof,

Quoted 32 lines · Olof Johansson
Quoted 21 lines · Will Deacon
Quoted 14 lines · Paul Kocialkowski
Quoted 4 lines · Will Deacon

Thanks, Laura.

I'll take this as a fix, and add a comment to the Makefile to justify why we need the linux target.

So this comes down to either breaking fedora/debian toolchains (that don't support elf emulation mode) or breaking bare-metal toolchains (that don't support linux emulation mode).

Since Linux is a bare-metal project that does not technically require the linux target (who said using "Linux" for all things is confusing?), I think it should aim for the elf target in the long term.

Quoted 5 lines

But well, breaking Linux build in common distros isn't good either, so I guess it makes sense to revert this while distros toolchains are being fixed. Hopefully, it won't take too long.

What do you think?

Quoted 7 lines

Yes, we need to revert the change since it's a regression otherwise. I think the best course of action here would be to find a way that we can either tell the linker that it doesn't need the missing linker scripts because we're providing our own, or find a way to pass different LD flags depending on whether or not we have a linux toolchain.

For now, I've pushed the revert to for-next/fixes.

Hi Will,

Quoted 8 lines
Quoted 4 lines

This is regressed in mainline as well. But I think we can just use a (slightly improved) ld-option here? I checked it for x86 regression since it uses the one-argument version. Patch is here, can you pick that up instead and get it in for 4.18-rc?

I already sent the revert to Linus, but I can certainly queue the ld-option for 4.19 if we pick up some more tested-bys. Could you send it out as its own patch please?

Definitely, separate email shortly.

-Olof

#11 lore raw

PATCH 1/1 arm64: build with baremetal linker target instead of Linux when available

In reply to Will Deacon

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

---
 arch/arm64/Makefile    | 9 +++++----
 scripts/Kbuild.include | 4 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)
arch/arm64/Makefile +5 -4
index e7101b19d590..efe61a2e4b5e 100644
@@ -60,15 +60,16 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS	+= -mbig-endian
 CHECKFLAGS	+= -D__AARCH64EB__
 AS		+= -EB
-# We must use the linux target here, since distributions don't tend to package
-# the ELF linker scripts with binutils, and this results in a build failure.
-LDFLAGS		+= -EB -maarch64linuxb
+# Prefer the baremetal ELF build target, but not all toolchains include
+# it so fall back to the standard linux version if needed.
+LDFLAGS		+= -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
 UTS_MACHINE	:= aarch64_be
 else
 KBUILD_CPPFLAGS	+= -mlittle-endian
 CHECKFLAGS	+= -D__AARCH64EL__
 AS		+= -EL
-LDFLAGS		+= -EL -maarch64linux # See comment above
+# Same as above, prefer ELF but fall back to linux target if needed.
+LDFLAGS		+= -EL $(call ld-option, -maarch64elf, -maarch64linux)
 UTS_MACHINE	:= aarch64
 endif
 
scripts/Kbuild.include +2 -2
index c8156d61678c..1e13f502b42f 100644
@@ -163,8 +163,8 @@ cc-ldoption = $(call try-run,\
 	$(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
 
 # ld-option
-# Usage: LDFLAGS += $(call ld-option, -X)
-ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2))
+# Usage: LDFLAGS += $(call ld-option, -X, -Y)
+ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2),$(3))
 
 # ar-option
 # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
Signature · 1 line
2.11.0
author Tested-by on v1 1/1
#12 lore raw

Re: [PATCH] arm64: build with baremetal linker target instead of Linux when available

Quoted 4 lines · Olof Johansson

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

For the Fedora toolchains:

Quoted 49 lines
---
  arch/arm64/Makefile    | 9 +++++----
  scripts/Kbuild.include | 4 ++--
  2 files changed, 7 insertions(+), 6 deletions(-)
arch/arm64/Makefile +5 -4
index e7101b19d590..efe61a2e4b5e 100644
@@ -60,15 +60,16 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
  KBUILD_CPPFLAGS	+= -mbig-endian
  CHECKFLAGS	+= -D__AARCH64EB__
  AS		+= -EB
-# We must use the linux target here, since distributions don't tend to package
-# the ELF linker scripts with binutils, and this results in a build failure.
-LDFLAGS		+= -EB -maarch64linuxb
+# Prefer the baremetal ELF build target, but not all toolchains include
+# it so fall back to the standard linux version if needed.
+LDFLAGS		+= -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
  UTS_MACHINE	:= aarch64_be
  else
  KBUILD_CPPFLAGS	+= -mlittle-endian
  CHECKFLAGS	+= -D__AARCH64EL__
  AS		+= -EL
-LDFLAGS		+= -EL -maarch64linux # See comment above
+# Same as above, prefer ELF but fall back to linux target if needed.
+LDFLAGS		+= -EL $(call ld-option, -maarch64elf, -maarch64linux)
  UTS_MACHINE	:= aarch64
  endif
 
scripts/Kbuild.include +2 -2
index c8156d61678c..1e13f502b42f 100644
@@ -163,8 +163,8 @@ cc-ldoption = $(call try-run,\
  	$(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
 
  # ld-option
-# Usage: LDFLAGS += $(call ld-option, -X)
-ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2))
+# Usage: LDFLAGS += $(call ld-option, -X, -Y)
+ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2),$(3))
 
  # ar-option
  # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
#13 lore raw

Re: [PATCH] arm64: build with baremetal linker target instead of Linux when available

Quoted 11 lines · Laura Abbott
Quoted 5 lines · Olof Johansson

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

For the Fedora toolchains:

Thanks!

-Olof

Acked-by on v1 1/1
#14 lore raw

Re: [PATCH] arm64: build with baremetal linker target instead of Linux when available

In reply to Olof Johansson

2018-07-14 0:30 GMT+09:00 Olof Johansson <[email protected]>:

Quoted 42 lines

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

---
 arch/arm64/Makefile    | 9 +++++----
 scripts/Kbuild.include | 4 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)
arch/arm64/Makefile +5 -4
index e7101b19d590..efe61a2e4b5e 100644
@@ -60,15 +60,16 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS        += -mbig-endian
 CHECKFLAGS     += -D__AARCH64EB__
 AS             += -EB
-# We must use the linux target here, since distributions don't tend to package
-# the ELF linker scripts with binutils, and this results in a build failure.
-LDFLAGS                += -EB -maarch64linuxb
+# Prefer the baremetal ELF build target, but not all toolchains include
+# it so fall back to the standard linux version if needed.
+LDFLAGS                += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
 UTS_MACHINE    := aarch64_be
 else
 KBUILD_CPPFLAGS        += -mlittle-endian
 CHECKFLAGS     += -D__AARCH64EL__
 AS             += -EL
-LDFLAGS                += -EL -maarch64linux # See comment above
+# Same as above, prefer ELF but fall back to linux target if needed.
+LDFLAGS                += -EL $(call ld-option, -maarch64elf, -maarch64linux)
 UTS_MACHINE    := aarch64
 endif
 
scripts/Kbuild.include +0 -0
index c8156d61678c..1e13f502b42f 100644

scripts/Kbuild.include cc-ldoption = $(call try-run,\ · line 170

Quoted 10 lines
scripts/Kbuild.include +2 -2
@@ -163,8 +163,8 @@ cc-ldoption = $(call try-run,\
        $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
 
 # ld-option
-# Usage: LDFLAGS += $(call ld-option, -X)
-ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2))
+# Usage: LDFLAGS += $(call ld-option, -X, -Y)
+ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2),$(3))
 
 # ar-option
 # Usage: KBUILD_ARFLAGS := $(call ar-option,D)

I guess this patch will go through the arm64 tree.

I am fine with the change of scripts/Kbuild.include

Signature · 2 lines
Best Regards
Masahiro Yamada
#15 lore raw

Re: [PATCH] arm64: build with baremetal linker target instead of Linux when available

In reply to Olof Johansson
Quoted 27 lines · Olof Johansson

Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't.

---
 arch/arm64/Makefile    | 9 +++++----
 scripts/Kbuild.include | 4 ++--
 2 files changed, 7 insertions(+), 6 deletions(-)
arch/arm64/Makefile +3 -3
index e7101b19d590..efe61a2e4b5e 100644
@@ -60,15 +60,16 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS        += -mbig-endian
 CHECKFLAGS     += -D__AARCH64EB__
 AS             += -EB
-# We must use the linux target here, since distributions don't tend to package
-# the ELF linker scripts with binutils, and this results in a build failure.
-LDFLAGS                += -EB -maarch64linuxb
+# Prefer the baremetal ELF build target, but not all toolchains include
+# it so fall back to the standard linux version if needed.
+LDFLAGS                += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
 UTS_MACHINE    := aarch64_be

arch/arm64/Makefile ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) · line 75

Quoted 10 lines
arch/arm64/Makefile +2 -1
 else
 KBUILD_CPPFLAGS        += -mlittle-endian
 CHECKFLAGS     += -D__AARCH64EL__
 AS             += -EL
-LDFLAGS                += -EL -maarch64linux # See comment above
+# Same as above, prefer ELF but fall back to linux target if needed.
+LDFLAGS                += -EL $(call ld-option, -maarch64elf, -maarch64linux)
 UTS_MACHINE    := aarch64
 endif
 

Did anyone check if just removing these options altogether would be an option?

The commit that introduced them does not even mention them, but only mentions adding -mabi=lp64 to the cc/as flags:

commit 3d6a7b99e3fa29b92d6288487e057e0a596bd2b0

Author: Andrew Pinski <[email protected]>
Date:   Mon Sep 18 11:20:20 2017 +0100

arm64: ensure the kernel is compiled for LP64

The kernel needs to be compiled as a LP64 binary for ARM64, even when using a compiler that defaults to code-generation for the ILP32 ABI. Consequently, we need to explicitly pass '-mabi=lp64' (supported on gcc-4.9 and newer).

Quoted 23 lines
scripts/Kbuild.include +2 -3
index c8156d61678c..1e13f502b42f 100644
@@ -163,8 +163,8 @@ cc-ldoption = $(call try-run,\
        $(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
 
 # ld-option
-# Usage: LDFLAGS += $(call ld-option, -X)
-ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2))
+# Usage: LDFLAGS += $(call ld-option, -X, -Y)
+ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2),$(3))
 
 # ar-option
 # Usage: KBUILD_ARFLAGS := $(call ar-option,D)
--

2.11.0

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel