Blame 0001-Fix-build-flag-passing-for-intel-speed-select.patch

1ed1330
From a0c122c4fb17f350396cb664d2fc184df9872279 Mon Sep 17 00:00:00 2001
1ed1330
From: "Herton R. Krzesinski" <herton@redhat.com>
1ed1330
Date: Mon, 4 Apr 2022 17:43:26 -0300
1ed1330
Subject: [PATCH] tools/power/x86/intel-speed-select: fix build failure when
1ed1330
 using -Wl,--as-needed
1ed1330
1ed1330
Upstream Status: patch submitted to platform-driver-x86/upstream maintainer
1ed1330
1ed1330
Build of intel-speed-select will fail if you run:
1ed1330
1ed1330
$ LDFLAGS="-Wl,--as-needed" /usr/bin/make V=1
1ed1330
...
1ed1330
gcc -O2 -Wall -g -D_GNU_SOURCE -Iinclude -I/usr/include/libnl3 -Wl,--as-needed -lnl-genl-3 -lnl-3 intel-speed-select-in.o -o intel-speed-select
1ed1330
/usr/bin/ld: intel-speed-select-in.o: in function `handle_event':
1ed1330
(...)/linux/tools/power/x86/intel-speed-select/hfi-events.c:189: undefined reference to `nlmsg_hdr'
1ed1330
...
1ed1330
1ed1330
In this case the problem is that order when linking matters when using
1ed1330
the flag -Wl,--as-needed, symbols not used at that point are discarded.
1ed1330
So since intel-speed-select-in.o comes after, at that point the
1ed1330
libraries/symbols are already discarded and then missing/undefined
1ed1330
references are reported.
1ed1330
1ed1330
To fix this, make sure we specify LDFLAGS after the object file.
1ed1330
1ed1330
Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
1ed1330
---
1ed1330
 tools/power/x86/intel-speed-select/Makefile | 2 +-
1ed1330
 1 file changed, 1 insertion(+), 1 deletion(-)
1ed1330
1ed1330
diff --git a/tools/power/x86/intel-speed-select/Makefile b/tools/power/x86/intel-speed-select/Makefile
1ed1330
index 846f785e278d..7221f2f55e8b 100644
1ed1330
--- a/tools/power/x86/intel-speed-select/Makefile
1ed1330
+++ b/tools/power/x86/intel-speed-select/Makefile
1ed1330
@@ -42,7 +42,7 @@ ISST_IN := $(OUTPUT)intel-speed-select-in.o
1ed1330
 $(ISST_IN): prepare FORCE
1ed1330
 	$(Q)$(MAKE) $(build)=intel-speed-select
1ed1330
 $(OUTPUT)intel-speed-select: $(ISST_IN)
1ed1330
-	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
1ed1330
+	$(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
1ed1330
 
1ed1330
 clean:
1ed1330
 	rm -f $(ALL_PROGRAMS)
1ed1330
-- 
1ed1330
GitLab
1ed1330