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

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