diff mbox

[2/2] objtool: use host flags to detect if libelf is missing

Message ID 2afbfc7911a0eb0642c33e8c2582f137a4fda2f3.1519393674.git.robin.jarry@6wind.com (mailing list archive)
State New, archived
Headers show

Commit Message

Robin Jarry Feb. 23, 2018, 2:22 p.m. UTC
When libelf headers and libs are not found and CONFIG_UNWINDER_ORC is
selected, there is a make error introduced by
commit 3dd40cb320fe ("objtool: Upgrade libelf-devel warning to error for
CONFIG_ORC_UNWINDER").

Host headers and libs may be in a non-standard location and the check is
performed without host flags. Make sure to use host flags for the check
(they will be used later when building objtool anyway).

Fixes: 3b27a0c85d70 ("objtool: Detect and warn if libelf is missing and don't break the build")
Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Josh Poimboeuf Feb. 23, 2018, 3:37 p.m. UTC | #1
On Fri, Feb 23, 2018 at 03:22:15PM +0100, Robin Jarry wrote:
> When libelf headers and libs are not found and CONFIG_UNWINDER_ORC is
> selected, there is a make error introduced by
> commit 3dd40cb320fe ("objtool: Upgrade libelf-devel warning to error for
> CONFIG_ORC_UNWINDER").
> 
> Host headers and libs may be in a non-standard location and the check is
> performed without host flags. Make sure to use host flags for the check
> (they will be used later when building objtool anyway).
> 
> Fixes: 3b27a0c85d70 ("objtool: Detect and warn if libelf is missing and don't break the build")
> Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index e9609319d2b8..4e8c667b9f3f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -955,7 +955,7 @@ export mod_sign_cmd
>  
>  ifdef CONFIG_STACK_VALIDATION
>    has_libelf := $(call try-run,\
> -		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
> +		echo "int main() {}" | $(HOSTCC) $(host_clfags) $(HOSTLDFLAGS) -xc -o /dev/null -lelf -,1,0)
>    ifeq ($(has_libelf),1)
>      objtool_target := tools/objtool FORCE
>    else
> -- 
> 2.11.0
> 

Hi Robin,

Did you test this?  I see some issues:

a) I don't see where the host_cflags variable comes from (and btw, it's
   misspelled...)

b) I don't see where objtool uses HOSTLDFLAGS.
Robin Jarry Feb. 23, 2018, 4:22 p.m. UTC | #2
2018-02-23, Josh Poimboeuf:
> Hi Robin,
> 
> Did you test this?  I see some issues:
> 
> a) I don't see where the host_cflags variable comes from (and btw, it's
>    misspelled...)

Hi Josh,

Shame on me... Last minute fix. I had tested this first by forcing
HOSTCC="gcc <CFLAGS> <LDFLAGS>" but I found it rather dirty. As it turns
out, my patch is not better.

> b) I don't see where objtool uses HOSTLDFLAGS.

Indeed, I also missed this (see above).

It looks like objtool does not use HOSTCFLAGS nor HOSTLDFLAGS (defined
in top Makefile). Do you see a reason why? Maybe it would be a good idea
to share these flags (adding some specific ones for objtool, if needed).

What do you think?
Josh Poimboeuf Feb. 23, 2018, 4:34 p.m. UTC | #3
On Fri, Feb 23, 2018 at 05:22:55PM +0100, Robin Jarry wrote:
> 2018-02-23, Josh Poimboeuf:
> > Hi Robin,
> > 
> > Did you test this?  I see some issues:
> > 
> > a) I don't see where the host_cflags variable comes from (and btw, it's
> >    misspelled...)
> 
> Hi Josh,
> 
> Shame on me... Last minute fix. I had tested this first by forcing
> HOSTCC="gcc <CFLAGS> <LDFLAGS>" but I found it rather dirty. As it turns
> out, my patch is not better.
> 
> > b) I don't see where objtool uses HOSTLDFLAGS.
> 
> Indeed, I also missed this (see above).
> 
> It looks like objtool does not use HOSTCFLAGS nor HOSTLDFLAGS (defined
> in top Makefile). Do you see a reason why? Maybe it would be a good idea
> to share these flags (adding some specific ones for objtool, if needed).
> 
> What do you think?

Yeah, I think it would be a good idea for objtool to use HOSTCC,
HOSTCFLAGS, and HOSTLDFLAGS.
diff mbox

Patch

diff --git a/Makefile b/Makefile
index e9609319d2b8..4e8c667b9f3f 100644
--- a/Makefile
+++ b/Makefile
@@ -955,7 +955,7 @@  export mod_sign_cmd
 
 ifdef CONFIG_STACK_VALIDATION
   has_libelf := $(call try-run,\
-		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
+		echo "int main() {}" | $(HOSTCC) $(host_clfags) $(HOSTLDFLAGS) -xc -o /dev/null -lelf -,1,0)
   ifeq ($(has_libelf),1)
     objtool_target := tools/objtool FORCE
   else