Skip to contentSkip to conversation

tools/resolve_btfids: Pass HOSTCFLAGS as EXTRA_CFLAGS to prepare targets

PATCH Applied Jiri Olsa 3 participants 3 messages Feb 9, 2023 – Feb 10, 2023 BPF

lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/1 tools/resolve_btfids: Pass HOSTCFLAGS as EXTRA_CFLAGS to prepare targets

Thorsten reported build issue with command line that defined extra HOSTCFLAGS that were not passed into 'prepare' targets, but were used to build resolve_btfids objects.

This results in build fail when these objects are linked together:

  /usr/bin/ld: /build.../tools/bpf/resolve_btfids//libbpf/libbpf.a(libbpf-in.o):
  relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE \
  object; recompile with -fPIE

Fixing this by passing HOSTCFLAGS in EXTRA_CFLAGS as part of HOST_OVERRIDES variable for prepare targets.

[1] https://lore.kernel.org/bpf/[email protected]/

Fixes 56a2df7615fa ("tools/resolve_btfids: Compile resolve_btfids as host program")
---
 tools/bpf/resolve_btfids/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/resolve_btfids/Makefile +1 -1
index 2abdd85b4a08..ac548a7baa73 100644
@@ -19,7 +19,7 @@ endif
 
 # Overrides for the prepare step libraries.
 HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \
-		  CROSS_COMPILE=""
+		  CROSS_COMPILE="" EXTRA_CFLAGS="$(HOSTCFLAGS)"
 
 RM      ?= rm
 HOSTCC  ?= gcc
Signature · 1 line
2.39.1
Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Jiri Olsa

Thorsten reported build issue with command line that defined extra HOSTCFLAGS that were not passed into 'prepare' targets, but were used to build resolve_btfids objects.

This results in build fail when these objects are linked together:

  /usr/bin/ld: /build.../tools/bpf/resolve_btfids//libbpf/libbpf.a(libbpf-in.o):
  relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE \
  object; recompile with -fPIE

Fixing this by passing HOSTCFLAGS in EXTRA_CFLAGS as part of HOST_OVERRIDES variable for prepare targets.

Quoted 6 lines

[1] https://lore.kernel.org/bpf/[email protected]/

Fixes 56a2df7615fa ("tools/resolve_btfids: Compile resolve_btfids as host program")

Thanks,
Ian

Quoted 20 lines
---
 tools/bpf/resolve_btfids/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/resolve_btfids/Makefile +1 -2
index 2abdd85b4a08..ac548a7baa73 100644
@@ -19,7 +19,7 @@ endif
 
 # Overrides for the prepare step libraries.
 HOST_OVERRIDES := AR="$(HOSTAR)" CC="$(HOSTCC)" LD="$(HOSTLD)" ARCH="$(HOSTARCH)" \
-                 CROSS_COMPILE=""
+                 CROSS_COMPILE="" EXTRA_CFLAGS="$(HOSTCFLAGS)"
 
 RM      ?= rm
 HOSTCC  ?= gcc
--

2.39.1

#2 lore raw
In reply to Jiri Olsa
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Quoted 11 lines · On Thu, 9 Feb 2023 15:37:35 +0100 you wrote:

Thorsten reported build issue with command line that defined extra HOSTCFLAGS that were not passed into 'prepare' targets, but were used to build resolve_btfids objects.

This results in build fail when these objects are linked together:

  /usr/bin/ld: /build.../tools/bpf/resolve_btfids//libbpf/libbpf.a(libbpf-in.o):
  relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE \
  object; recompile with -fPIE

[...]

Here is the summary with links:
- [bpf-next] tools/resolve_btfids: Pass HOSTCFLAGS as EXTRA_CFLAGS to prepare targets

    https://git.kernel.org/bpf/bpf-next/c/2531ba0e4ae6

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html