All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed
@ 2022-04-04 21:05 Herton R. Krzesinski
  2022-04-04 23:09 ` Prarit Bhargava
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Herton R. Krzesinski @ 2022-04-04 21:05 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: srinivas.pandruvada, prarit, jforbes, darcari, dzickus, herton

Build of intel-speed-select will fail if you run:

$ LDFLAGS="-Wl,--as-needed" /usr/bin/make V=1
...
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
/usr/bin/ld: intel-speed-select-in.o: in function `handle_event':
(...)/linux/tools/power/x86/intel-speed-select/hfi-events.c:189: undefined reference to `nlmsg_hdr'
...

In this case the problem is that order when linking matters when using
the flag -Wl,--as-needed, symbols not used at that point are discarded.
So since intel-speed-select-in.o comes after, at that point the
libraries/symbols are already discarded and then missing/undefined
references are reported.

To fix this, make sure we specify LDFLAGS after the object file.

Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
---
 tools/power/x86/intel-speed-select/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/x86/intel-speed-select/Makefile b/tools/power/x86/intel-speed-select/Makefile
index 846f785e278d..7221f2f55e8b 100644
--- a/tools/power/x86/intel-speed-select/Makefile
+++ b/tools/power/x86/intel-speed-select/Makefile
@@ -42,7 +42,7 @@ ISST_IN := $(OUTPUT)intel-speed-select-in.o
 $(ISST_IN): prepare FORCE
 	$(Q)$(MAKE) $(build)=intel-speed-select
 $(OUTPUT)intel-speed-select: $(ISST_IN)
-	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
+	$(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
 
 clean:
 	rm -f $(ALL_PROGRAMS)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed
  2022-04-04 21:05 [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed Herton R. Krzesinski
@ 2022-04-04 23:09 ` Prarit Bhargava
  2022-04-05  1:08 ` srinivas pandruvada
  2022-04-05  9:51 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Prarit Bhargava @ 2022-04-04 23:09 UTC (permalink / raw)
  To: Herton R. Krzesinski, platform-driver-x86
  Cc: srinivas.pandruvada, jforbes, darcari, dzickus

On 4/4/22 17:05, Herton R. Krzesinski wrote:
> Build of intel-speed-select will fail if you run:
> 
> $ LDFLAGS="-Wl,--as-needed" /usr/bin/make V=1
> ...
> 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
> /usr/bin/ld: intel-speed-select-in.o: in function `handle_event':
> (...)/linux/tools/power/x86/intel-speed-select/hfi-events.c:189: undefined reference to `nlmsg_hdr'
> ...
> 

Srinivas, This is important as it blocks ARK (ie think of RHEL-next) 
kernel builds and blocks us from bringing this code into current 
versions of RHEL.

Just an FYI,

P.

> In this case the problem is that order when linking matters when using
> the flag -Wl,--as-needed, symbols not used at that point are discarded.
> So since intel-speed-select-in.o comes after, at that point the
> libraries/symbols are already discarded and then missing/undefined
> references are reported.
> 
> To fix this, make sure we specify LDFLAGS after the object file.
> 
> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
> ---
>   tools/power/x86/intel-speed-select/Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/x86/intel-speed-select/Makefile b/tools/power/x86/intel-speed-select/Makefile
> index 846f785e278d..7221f2f55e8b 100644
> --- a/tools/power/x86/intel-speed-select/Makefile
> +++ b/tools/power/x86/intel-speed-select/Makefile
> @@ -42,7 +42,7 @@ ISST_IN := $(OUTPUT)intel-speed-select-in.o
>   $(ISST_IN): prepare FORCE
>   	$(Q)$(MAKE) $(build)=intel-speed-select
>   $(OUTPUT)intel-speed-select: $(ISST_IN)
> -	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
> +	$(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
>   
>   clean:
>   	rm -f $(ALL_PROGRAMS)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed
  2022-04-04 21:05 [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed Herton R. Krzesinski
  2022-04-04 23:09 ` Prarit Bhargava
@ 2022-04-05  1:08 ` srinivas pandruvada
  2022-04-05  9:51 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: srinivas pandruvada @ 2022-04-05  1:08 UTC (permalink / raw)
  To: Herton R. Krzesinski, platform-driver-x86, hdegoede
  Cc: prarit, jforbes, darcari, dzickus

On Mon, 2022-04-04 at 18:05 -0300, Herton R. Krzesinski wrote:
> Build of intel-speed-select will fail if you run:
> 
> $ LDFLAGS="-Wl,--as-needed" /usr/bin/make V=1

We realized this for some OS recently have an internal patch.
So agree with the change.

> ...
> 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
> /usr/bin/ld: intel-speed-select-in.o: in function `handle_event':
> (...)/linux/tools/power/x86/intel-speed-select/hfi-events.c:189:
> undefined reference to `nlmsg_hdr'
> ...
> 
> In this case the problem is that order when linking matters when using
> the flag -Wl,--as-needed, symbols not used at that point are discarded.
> So since intel-speed-select-in.o comes after, at that point the
> libraries/symbols are already discarded and then missing/undefined
> references are reported.
> 
> To fix this, make sure we specify LDFLAGS after the object file.
> 
> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  tools/power/x86/intel-speed-select/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/x86/intel-speed-select/Makefile
> b/tools/power/x86/intel-speed-select/Makefile
> index 846f785e278d..7221f2f55e8b 100644
> --- a/tools/power/x86/intel-speed-select/Makefile
> +++ b/tools/power/x86/intel-speed-select/Makefile
> @@ -42,7 +42,7 @@ ISST_IN := $(OUTPUT)intel-speed-select-in.o
>  $(ISST_IN): prepare FORCE
>         $(Q)$(MAKE) $(build)=intel-speed-select
>  $(OUTPUT)intel-speed-select: $(ISST_IN)
> -       $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
> +       $(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
>  
>  clean:
>         rm -f $(ALL_PROGRAMS)



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed
  2022-04-04 21:05 [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed Herton R. Krzesinski
  2022-04-04 23:09 ` Prarit Bhargava
  2022-04-05  1:08 ` srinivas pandruvada
@ 2022-04-05  9:51 ` Hans de Goede
  2 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-04-05  9:51 UTC (permalink / raw)
  To: Herton R. Krzesinski, platform-driver-x86
  Cc: srinivas.pandruvada, prarit, jforbes, darcari, dzickus

Hi All,

On 4/4/22 23:05, Herton R. Krzesinski wrote:
> Build of intel-speed-select will fail if you run:
> 
> $ LDFLAGS="-Wl,--as-needed" /usr/bin/make V=1
> ...
> 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
> /usr/bin/ld: intel-speed-select-in.o: in function `handle_event':
> (...)/linux/tools/power/x86/intel-speed-select/hfi-events.c:189: undefined reference to `nlmsg_hdr'
> ...
> 
> In this case the problem is that order when linking matters when using
> the flag -Wl,--as-needed, symbols not used at that point are discarded.
> So since intel-speed-select-in.o comes after, at that point the
> libraries/symbols are already discarded and then missing/undefined
> references are reported.
> 
> To fix this, make sure we specify LDFLAGS after the object file.
> 
> Signed-off-by: Herton R. Krzesinski <herton@redhat.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

I've also added this to my fixes branch and it will be included
when I send the next fixes for 5.18 pull-req to Linus.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans

> ---
>  tools/power/x86/intel-speed-select/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/x86/intel-speed-select/Makefile b/tools/power/x86/intel-speed-select/Makefile
> index 846f785e278d..7221f2f55e8b 100644
> --- a/tools/power/x86/intel-speed-select/Makefile
> +++ b/tools/power/x86/intel-speed-select/Makefile
> @@ -42,7 +42,7 @@ ISST_IN := $(OUTPUT)intel-speed-select-in.o
>  $(ISST_IN): prepare FORCE
>  	$(Q)$(MAKE) $(build)=intel-speed-select
>  $(OUTPUT)intel-speed-select: $(ISST_IN)
> -	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
> +	$(QUIET_LINK)$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
>  
>  clean:
>  	rm -f $(ALL_PROGRAMS)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-05 11:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 21:05 [PATCH] tools/power/x86/intel-speed-select: fix build failure when using -Wl,--as-needed Herton R. Krzesinski
2022-04-04 23:09 ` Prarit Bhargava
2022-04-05  1:08 ` srinivas pandruvada
2022-04-05  9:51 ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.