Skip to contentSkip to conversation

uboot: Strip "-Wl," from LDFLAGS

PATCH New Jeroen Roovers 2 participants 7 messages Feb 10, 2016 – Jun 3, 2016 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 uboot: Strip "-Wl," from LDFLAGS

---------- Forwarded message ----------
From: Jeroen Roovers <[email protected]>
Date: 10 February 2016 at 12:15
Subject: [PATCH 1/1] uboot: Strip "-Wl," from LDFLAGS
To: buildroot at buildroot.org
Cc: Jeroen Roovers <[email protected]>

If we want to set proper LDFLAGS, then we need to mangle that in the uboot build system as it calls ld(1) (in fact ld.bfd) directly, where the "-Wl," prefix should only be used when the linker is called indirectly through gcc(1).

---
 boot/uboot/uboot.mk | 1 +
 1 file changed, 1 insertion(+)
boot/uboot/uboot.mk +1 -0
index d539b31..9996aca 100644
@@ -83,6 +83,7 @@ endif
 
 UBOOT_MAKE_OPTS += \
        CROSS_COMPILE="$(TARGET_CROSS)" \
+       LDFLAGS="$(TARGET_LDFLAGS:-Wl,%=%)" \
        ARCH=$(UBOOT_ARCH)
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)

--
2.4.10

#2 lore raw

PATCH 1/1 uboot: Strip "-Wl," from LDFLAGS

Hello,

Thanks for this patch! See some comments below.

Quoted 8 lines · Jeroen Roovers

---------- Forwarded message ----------
From: Jeroen Roovers <[email protected]>
Date: 10 February 2016 at 12:15
Subject: [PATCH 1/1] uboot: Strip "-Wl," from LDFLAGS
To: buildroot at buildroot.org
Cc: Jeroen Roovers <[email protected]>

Quoted 6 lines

If we want to set proper LDFLAGS, then we need to mangle that in the uboot build system as it calls ld(1) (in fact ld.bfd) directly, where the "-Wl," prefix should only be used when the linker is called indirectly through gcc(1).

What specific/real problem is this fixing? I.e in which situation/configuration are you seeing that TARGET_LDFLAGS contains a -Wl option?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

A message that is not in the archive (sent off-list or not yet received): CANCHnQogKCY-OTT2=wTkNJ8D52QWetBqdnWbfAqRKKcoW8Yrpw@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CANCHnQp5E4kx=2VpVDXAC-sn+ruxe=0nwamG=DXp_WEgQVCRjw@mail.gmail.com

#5 lore raw

PATCH 1/1 uboot: Strip "-Wl, " from LDFLAGS

Apparently this didn't make it to the list.

---------- Forwarded message ----------
From: Jeroen Roovers <[email protected]>
Date: 10 February 2016 at 17:47
Subject: Re: [Buildroot] Fwd: [PATCH 1/1] uboot: Strip "-Wl," from LDFLAGS
To: Thomas Petazzoni <[email protected]>
Cc: buildroot at buildroot.org

I set BR2_TARGET_LDFLAGS="-Wl,-O1 -Wl,--as-needed" in .config. Everywere else, the resulting LDFLAGS is correctly used, i.e. as linker flags passed to GCC.

The specific problem I am fixing is that ld.bfd, as called by uboot, does not know what -Wl,-O1 or -Wl,--as-needed are, but does know what -O1 and --as-needed are. So it's sort of a build failure, which that patch fixes.

Quoted 31 lines · Thomas Petazzoni

Hello,

Thanks for this patch! See some comments below.

Quoted 8 lines · Jeroen Roovers

---------- Forwarded message ----------
From: Jeroen Roovers <[email protected]>
Date: 10 February 2016 at 12:15
Subject: [PATCH 1/1] uboot: Strip "-Wl," from LDFLAGS
To: buildroot at buildroot.org
Cc: Jeroen Roovers <[email protected]>

Quoted 6 lines

If we want to set proper LDFLAGS, then we need to mangle that in the uboot build system as it calls ld(1) (in fact ld.bfd) directly, where the "-Wl," prefix should only be used when the linker is called indirectly through gcc(1).

What specific/real problem is this fixing? I.e in which situation/configuration are you seeing that TARGET_LDFLAGS contains a -Wl option?

Thanks,

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

#6 lore raw

PATCH 1/1 uboot: Strip "-Wl," from LDFLAGS

In reply to Jeroen Roovers

Hello,

Quoted 8 lines · Jeroen Roovers

---------- Forwarded message ----------
From: Jeroen Roovers <[email protected]>
Date: 10 February 2016 at 12:15
Subject: [PATCH 1/1] uboot: Strip "-Wl," from LDFLAGS
To: buildroot at buildroot.org
Cc: Jeroen Roovers <[email protected]>

Quoted 6 lines

If we want to set proper LDFLAGS, then we need to mangle that in the uboot build system as it calls ld(1) (in fact ld.bfd) directly, where the "-Wl," prefix should only be used when the linker is called indirectly through gcc(1).

I have not been able to reproduce a build problem, since TARGET_LDFLAGS are currently not passed to U-Boot. So the following defconfig builds fine:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2016.05-rc2-3-g011d4e2.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_8=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TARGET_LDFLAGS="-Wl,--as-needed"
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_UBOOT=y
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
BR2_TARGET_UBOOT_BOARD_DEFCONFIG="clearfog"

So maybe your patch is also about *passing* LDFLAGS down to U-Boot ?

In any case, your commit log had some "mail forwarding" related contents. Could you resend an updated version, which explains a bit better that the patch also *passes* LDFLAGS down to U-Boot, and with fixed up commit log?

Thanks a lot!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#7 lore raw

PATCH 1/1 uboot: Strip "-Wl," from LDFLAGS

The patch *doesn't* pass LDFLAGS down; GNU make simply picks up the exported LDFLAGS from buildroot and integrates it with its own flags. I only found out because when I set BR2_TARGET_LDFLAGS using the usual GCC flags and did a complete rebuild, I found that only uboot failed to build.

I'll resend the patch when I find the time.

Quoted 56 lines · Thomas Petazzoni

Hello,

Quoted 8 lines · Jeroen Roovers

---------- Forwarded message ----------
From: Jeroen Roovers <[email protected]>
Date: 10 February 2016 at 12:15
Subject: [PATCH 1/1] uboot: Strip "-Wl," from LDFLAGS
To: buildroot at buildroot.org
Cc: Jeroen Roovers <[email protected]>

Quoted 6 lines

If we want to set proper LDFLAGS, then we need to mangle that in the uboot build system as it calls ld(1) (in fact ld.bfd) directly, where the "-Wl," prefix should only be used when the linker is called indirectly through gcc(1).

I have not been able to reproduce a build problem, since TARGET_LDFLAGS are currently not passed to U-Boot. So the following defconfig builds fine:

BR2_arm=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/br-arm-full-2016.05-rc2-3-g011d4e2.tar.bz2" BR2_TOOLCHAIN_EXTERNAL_GCC_4_8=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_10=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
# BR2_TOOLCHAIN_EXTERNAL_HAS_THREADS_DEBUG is not set
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TARGET_LDFLAGS="-Wl,--as-needed"
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_UBOOT=y
BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
BR2_TARGET_UBOOT_BOARD_DEFCONFIG="clearfog"

So maybe your patch is also about *passing* LDFLAGS down to U-Boot ?

In any case, your commit log had some "mail forwarding" related contents. Could you resend an updated version, which explains a bit better that the patch also *passes* LDFLAGS down to U-Boot, and with fixed up commit log?

Thanks a lot!

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

#8 lore raw

PATCH 1/1 uboot: Strip "-Wl," from LDFLAGS

Hello,

Quoted 5 lines · Jeroen Roovers

The patch *doesn't* pass LDFLAGS down; GNU make simply picks up the exported LDFLAGS from buildroot and integrates it with its own flags. I only found out because when I set BR2_TARGET_LDFLAGS using the usual GCC flags and did a complete rebuild, I found that only uboot failed to build.

Buildroot does not export LDFLAGS, and only passes it down to packages if it's explicitly done in the package .mk file.

Try the defconfig I posted, it built just fine, even though it has -Wl,--as-needed in BR2_TARGET_LDFLAGS.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#9 lore raw

PATCH 1/1 uboot: Strip "-Wl," from LDFLAGS

Hm, OK. I did just discover that I'm on an AllWinner fork of uboot, so maybe it doesn't apply to mainline uboot at all. If you cannot reproduce the issue, then that may be the cause, in which case I guess you would want to drop that patch.

Regards,
jer

Quoted 21 lines · Thomas Petazzoni

Hello,

Quoted 5 lines · Jeroen Roovers

The patch *doesn't* pass LDFLAGS down; GNU make simply picks up the exported LDFLAGS from buildroot and integrates it with its own flags. I only found out because when I set BR2_TARGET_LDFLAGS using the usual GCC flags and did a complete rebuild, I found that only uboot failed to build.

Buildroot does not export LDFLAGS, and only passes it down to packages if it's explicitly done in the package .mk file.

Try the defconfig I posted, it built just fine, even though it has -Wl,--as-needed in BR2_TARGET_LDFLAGS.

Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com