linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Fix python feature detection
@ 2019-07-07 14:44 Joel Fernandes (Google)
  2019-07-14 15:40 ` Jiri Olsa
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Fernandes (Google) @ 2019-07-07 14:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: Joel Fernandes (Google), acme, jolsa, Jiri Olsa

I am having a hard time building BPF samples by doing a make in
samples/bpf. While I am debugging that, I ran into the Python issue.
Even though the system has libpython2.7-dev:

If I just do a 'make' inside tools/build/feature/ I get:
Python.h: No such file or directory

This led me to this patch which fixes Python feature detection for me.
I am not sure if it is the right fix for Python since it is hardcoded
for Python version 2, but I thought it could be useful.

My system is a Debian buster release.

Cc: acme@kernel.org
Cc: jolsa@redhat.com
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
---
 tools/build/feature/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
index 4b8244ee65ce..cde44cb38a5e 100644
--- a/tools/build/feature/Makefile
+++ b/tools/build/feature/Makefile
@@ -83,7 +83,7 @@ __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(
 ###############################
 
 $(OUTPUT)test-all.bin:
-	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma
+	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(shell $(PKG_CONFIG) --libs --cflags python2 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma
 
 $(OUTPUT)test-hello.bin:
 	$(BUILD)
@@ -205,7 +205,7 @@ $(OUTPUT)test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
 $(OUTPUT)test-libpython.bin:
-	$(BUILD) $(FLAGS_PYTHON_EMBED)
+	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags python2 2>/dev/null) $(FLAGS_PYTHON_EMBED)
 
 $(OUTPUT)test-libpython-version.bin:
 	$(BUILD)
-- 
2.22.0.410.gd8fdbe21b5-goog


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

* Re: [RFC] Fix python feature detection
  2019-07-07 14:44 [RFC] Fix python feature detection Joel Fernandes (Google)
@ 2019-07-14 15:40 ` Jiri Olsa
  2019-07-14 17:57   ` Joel Fernandes
  0 siblings, 1 reply; 3+ messages in thread
From: Jiri Olsa @ 2019-07-14 15:40 UTC (permalink / raw)
  To: Joel Fernandes (Google); +Cc: linux-kernel, acme, Jiri Olsa

On Sun, Jul 07, 2019 at 10:44:17AM -0400, Joel Fernandes (Google) wrote:
> I am having a hard time building BPF samples by doing a make in
> samples/bpf. While I am debugging that, I ran into the Python issue.
> Even though the system has libpython2.7-dev:
> 
> If I just do a 'make' inside tools/build/feature/ I get:
> Python.h: No such file or directory

because you don't have FLAGS_PYTHON_EMBED set?

> 
> This led me to this patch which fixes Python feature detection for me.
> I am not sure if it is the right fix for Python since it is hardcoded
> for Python version 2, but I thought it could be useful.

we detect python in tools/perf/Makefile.config and
set FLAGS_PYTHON_EMBED properly

it's supposed to be set by a project using tools/build
for feature detection.. what are you building? AFAICS
samples/bpf do not use tools/build

jirka

> 
> My system is a Debian buster release.
> 
> Cc: acme@kernel.org
> Cc: jolsa@redhat.com
> Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> ---
>  tools/build/feature/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
> index 4b8244ee65ce..cde44cb38a5e 100644
> --- a/tools/build/feature/Makefile
> +++ b/tools/build/feature/Makefile
> @@ -83,7 +83,7 @@ __BUILDXX = $(CXX) $(CXXFLAGS) -MD -Wall -Werror -o $@ $(patsubst %.bin,%.cpp,$(
>  ###############################
>  
>  $(OUTPUT)test-all.bin:
> -	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma
> +	$(BUILD) -fstack-protector-all -O2 -D_FORTIFY_SOURCE=2 -ldw -lelf -lnuma -lelf -laudit -I/usr/include/slang -lslang $(shell $(PKG_CONFIG) --libs --cflags gtk+-2.0 2>/dev/null) $(shell $(PKG_CONFIG) --libs --cflags python2 2>/dev/null) $(FLAGS_PERL_EMBED) $(FLAGS_PYTHON_EMBED) -DPACKAGE='"perf"' -lbfd -ldl -lz -llzma
>  
>  $(OUTPUT)test-hello.bin:
>  	$(BUILD)
> @@ -205,7 +205,7 @@ $(OUTPUT)test-libperl.bin:
>  	$(BUILD) $(FLAGS_PERL_EMBED)
>  
>  $(OUTPUT)test-libpython.bin:
> -	$(BUILD) $(FLAGS_PYTHON_EMBED)
> +	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags python2 2>/dev/null) $(FLAGS_PYTHON_EMBED)
>  
>  $(OUTPUT)test-libpython-version.bin:
>  	$(BUILD)
> -- 
> 2.22.0.410.gd8fdbe21b5-goog
> 

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

* Re: [RFC] Fix python feature detection
  2019-07-14 15:40 ` Jiri Olsa
@ 2019-07-14 17:57   ` Joel Fernandes
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Fernandes @ 2019-07-14 17:57 UTC (permalink / raw)
  To: Jiri Olsa; +Cc: linux-kernel, acme, Jiri Olsa

On Sun, Jul 14, 2019 at 05:40:06PM +0200, Jiri Olsa wrote:
> On Sun, Jul 07, 2019 at 10:44:17AM -0400, Joel Fernandes (Google) wrote:
> > I am having a hard time building BPF samples by doing a make in
> > samples/bpf. While I am debugging that, I ran into the Python issue.
> > Even though the system has libpython2.7-dev:
> > 
> > If I just do a 'make' inside tools/build/feature/ I get:
> > Python.h: No such file or directory
> 
> because you don't have FLAGS_PYTHON_EMBED set?
> 
> > 
> > This led me to this patch which fixes Python feature detection for me.
> > I am not sure if it is the right fix for Python since it is hardcoded
> > for Python version 2, but I thought it could be useful.
> 
> we detect python in tools/perf/Makefile.config and
> set FLAGS_PYTHON_EMBED properly
> 
> it's supposed to be set by a project using tools/build
> for feature detection.. what are you building? AFAICS
> samples/bpf do not use tools/build

Yes, you are right. Never mind then. I was debugging feature detection and
ended doing a make in this directory like:

make <something>.bin which works always except for python. But as you said it
is likely a non-issue.

thanks!

 - Joel


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

end of thread, other threads:[~2019-07-14 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-07 14:44 [RFC] Fix python feature detection Joel Fernandes (Google)
2019-07-14 15:40 ` Jiri Olsa
2019-07-14 17:57   ` Joel Fernandes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).