public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] objtool: make use of pkg-config for libelf
@ 2018-03-01 12:55 Philipp Puschmann
  2018-03-05 14:53 ` Josh Poimboeuf
  0 siblings, 1 reply; 3+ messages in thread
From: Philipp Puschmann @ 2018-03-01 12:55 UTC (permalink / raw)
  To: yamada.masahiro
  Cc: michal.lkml, jpoimboe, peterz, linux-kbuild, Philipp Puschmann

For libelf with non-standard paths make use of pkg-config.

Signed-off-by: Philipp Puschmann <pp@emlix.com>
---
 Makefile               | 4 +++-
 tools/objtool/Makefile | 8 ++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 659a7780aeb3..31b296b0e941 100644
--- a/Makefile
+++ b/Makefile
@@ -953,8 +953,10 @@ endif
 export mod_sign_cmd
 
 ifdef CONFIG_STACK_VALIDATION
+  LIBELF_LIBS = $(shell pkg-config --libs libelf 2> /dev/null || \
+                        echo -lelf)
   has_libelf := $(call try-run,\
-		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
+		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(LIBELF_LIBS) -,1,0)
   ifeq ($(has_libelf),1)
     objtool_target := tools/objtool FORCE
   else
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index e6acc281dd37..c565eff8c393 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -27,12 +27,16 @@ OBJTOOL_IN := $(OBJTOOL)-in.o
 
 all: $(OBJTOOL)
 
+LIBELF_LIBS     = $(shell pkg-config --libs libelf 2> /dev/null || \
+                        echo -lelf)
+LIBELF_INCLUDES = $(shell pkg-config --cflags libelf 2> /dev/null)
 INCLUDES := -I$(srctree)/tools/include \
 	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
-	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include
+	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include \
+	    $(LIBELF_INCLUDES)
 WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
 CFLAGS   += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
-LDFLAGS  += -lelf $(LIBSUBCMD)
+LDFLAGS  += $(LIBELF_LIBS) $(LIBSUBCMD)
 
 # Allow old libelf to be used:
 elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
-- 
2.16.1


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

* Re: [PATCH] objtool: make use of pkg-config for libelf
  2018-03-01 12:55 [PATCH] objtool: make use of pkg-config for libelf Philipp Puschmann
@ 2018-03-05 14:53 ` Josh Poimboeuf
  2018-03-05 15:21   ` Robin Jarry
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Poimboeuf @ 2018-03-05 14:53 UTC (permalink / raw)
  To: Philipp Puschmann, Robin Jarry
  Cc: yamada.masahiro, michal.lkml, peterz, linux-kbuild

[ Adding Robin ]

Robin, does this fix the same issue as your recent patches?  If so, I'd
prefer this one because it doesn't need any new environment variables.

On Thu, Mar 01, 2018 at 01:55:37PM +0100, Philipp Puschmann wrote:
> For libelf with non-standard paths make use of pkg-config.
> 
> Signed-off-by: Philipp Puschmann <pp@emlix.com>
> ---
>  Makefile               | 4 +++-
>  tools/objtool/Makefile | 8 ++++++--
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 659a7780aeb3..31b296b0e941 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -953,8 +953,10 @@ endif
>  export mod_sign_cmd
>  
>  ifdef CONFIG_STACK_VALIDATION
> +  LIBELF_LIBS = $(shell pkg-config --libs libelf 2> /dev/null || \
> +                        echo -lelf)
>    has_libelf := $(call try-run,\
> -		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null -lelf -,1,0)
> +		echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(LIBELF_LIBS) -,1,0)
>    ifeq ($(has_libelf),1)
>      objtool_target := tools/objtool FORCE
>    else
> diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
> index e6acc281dd37..c565eff8c393 100644
> --- a/tools/objtool/Makefile
> +++ b/tools/objtool/Makefile
> @@ -27,12 +27,16 @@ OBJTOOL_IN := $(OBJTOOL)-in.o
>  
>  all: $(OBJTOOL)
>  
> +LIBELF_LIBS     = $(shell pkg-config --libs libelf 2> /dev/null || \
> +                        echo -lelf)
> +LIBELF_INCLUDES = $(shell pkg-config --cflags libelf 2> /dev/null)
>  INCLUDES := -I$(srctree)/tools/include \
>  	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
> -	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include
> +	    -I$(srctree)/tools/objtool/arch/$(ARCH)/include \
> +	    $(LIBELF_INCLUDES)
>  WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed
>  CFLAGS   += -Wall -Werror $(WARNINGS) -fomit-frame-pointer -O2 -g $(INCLUDES)
> -LDFLAGS  += -lelf $(LIBSUBCMD)
> +LDFLAGS  += $(LIBELF_LIBS) $(LIBSUBCMD)
>  
>  # Allow old libelf to be used:
>  elfshdr := $(shell echo '\#include <libelf.h>' | $(CC) $(CFLAGS) -x c -E - | grep elf_getshdr)
> -- 
> 2.16.1
> 

-- 
Josh

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

* Re: [PATCH] objtool: make use of pkg-config for libelf
  2018-03-05 14:53 ` Josh Poimboeuf
@ 2018-03-05 15:21   ` Robin Jarry
  0 siblings, 0 replies; 3+ messages in thread
From: Robin Jarry @ 2018-03-05 15:21 UTC (permalink / raw)
  To: Josh Poimboeuf
  Cc: Philipp Puschmann, yamada.masahiro, michal.lkml, peterz,
	linux-kbuild

2018-03-05, Josh Poimboeuf:
> [ Adding Robin ]
> 
> Robin, does this fix the same issue as your recent patches?  If so, I'd
> prefer this one because it doesn't need any new environment variables.

Hi Josh,

this looks like it would work. I need to do proper testing before
confirmation. Also, I did not have time to work on a v3. I'll wait a bit
to see where this goes first.

-- 
Robin

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

end of thread, other threads:[~2018-03-05 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-01 12:55 [PATCH] objtool: make use of pkg-config for libelf Philipp Puschmann
2018-03-05 14:53 ` Josh Poimboeuf
2018-03-05 15:21   ` Robin Jarry

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox