linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf: Support Python 3.8+ in Makefile
@ 2020-01-25 14:56 Sam Lunt
  2020-01-29  7:54 ` Jiri Olsa
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Lunt @ 2020-01-25 14:56 UTC (permalink / raw)
  To: linux-kernel, peterz, mingo, acme
  Cc: mark.rutland, alexander.shishkin, jolsa, namhyung, trivial

Python 3.8 changed the output of 'python-config --ldflags' to no longer
include the '-lpythonX.Y' flag (this apparently fixed an issue loading
modules with a statically linked Python executable).  The libpython
feature check in linux/build/feature fails if the Python library is not
included in FEATURE_CHECK_LDFLAGS-libpython variable.

This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
the '--embed' flag and passes that flag alongside '--ldflags' if so.

tools/perf is the only place the libpython feature check is used.

Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
---
 tools/perf/Makefile.config | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index c90f4146e5a2..ccf99351f058 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))

 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))

+# Python 3.8 changed the output of `python-config --ldflags` to not include the
+# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
+# libpython fails if that flag is not included in LDFLAGS
+ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null;
echo $$?), 0)
+  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
+else
+  PYTHON_CONFIG_LDFLAGS := --ldflags
+endif
+
 ifdef PYTHON_CONFIG
-  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ)
$(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
   PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
   PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
   PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)

base-commit: d5d359b0ac3ffc319ca93c46a4cfd87093759ad6
-- 
2.25.0

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

* Re: [PATCH] perf: Support Python 3.8+ in Makefile
  2020-01-25 14:56 [PATCH] perf: Support Python 3.8+ in Makefile Sam Lunt
@ 2020-01-29  7:54 ` Jiri Olsa
  2020-01-31 18:06   ` Sam Lunt
  0 siblings, 1 reply; 8+ messages in thread
From: Jiri Olsa @ 2020-01-29  7:54 UTC (permalink / raw)
  To: Sam Lunt
  Cc: linux-kernel, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, namhyung, trivial

On Sat, Jan 25, 2020 at 08:56:12AM -0600, Sam Lunt wrote:
> Python 3.8 changed the output of 'python-config --ldflags' to no longer
> include the '-lpythonX.Y' flag (this apparently fixed an issue loading
> modules with a statically linked Python executable).  The libpython
> feature check in linux/build/feature fails if the Python library is not
> included in FEATURE_CHECK_LDFLAGS-libpython variable.
> 
> This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
> the '--embed' flag and passes that flag alongside '--ldflags' if so.
> 
> tools/perf is the only place the libpython feature check is used.

seems ok to me, but your patch came malformed, check below

jirka


> 
> Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
> ---
>  tools/perf/Makefile.config | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index c90f4146e5a2..ccf99351f058 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))
> 
>  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
> 
> +# Python 3.8 changed the output of `python-config --ldflags` to not include the
> +# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
> +# libpython fails if that flag is not included in LDFLAGS
> +ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null;
> echo $$?), 0)

patching file tools/perf/Makefile.config
patch: **** malformed patch at line 108: echo $$?), 0)


> +  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
> +else
> +  PYTHON_CONFIG_LDFLAGS := --ldflags
> +endif
> +
>  ifdef PYTHON_CONFIG
> -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
> +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ)
> $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)

patching file tools/perf/Makefile.config
patch: **** malformed patch at line 116: $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)

>    PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
>    PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
>    PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
> 
> base-commit: d5d359b0ac3ffc319ca93c46a4cfd87093759ad6
> -- 
> 2.25.0
> 


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

* Re: [PATCH] perf: Support Python 3.8+ in Makefile
  2020-01-29  7:54 ` Jiri Olsa
@ 2020-01-31 18:06   ` Sam Lunt
  0 siblings, 0 replies; 8+ messages in thread
From: Sam Lunt @ 2020-01-31 18:06 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: linux-kernel, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, namhyung, trivial

Sorry about that, Gmail's web client reflowed the text of the patch.
I'll try again with mutt.

On Wed, Jan 29, 2020 at 1:55 AM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Sat, Jan 25, 2020 at 08:56:12AM -0600, Sam Lunt wrote:
> > Python 3.8 changed the output of 'python-config --ldflags' to no longer
> > include the '-lpythonX.Y' flag (this apparently fixed an issue loading
> > modules with a statically linked Python executable).  The libpython
> > feature check in linux/build/feature fails if the Python library is not
> > included in FEATURE_CHECK_LDFLAGS-libpython variable.
> >
> > This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
> > the '--embed' flag and passes that flag alongside '--ldflags' if so.
> >
> > tools/perf is the only place the libpython feature check is used.
>
> seems ok to me, but your patch came malformed, check below
>
> jirka
>
>
> >
> > Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
> > ---
> >  tools/perf/Makefile.config | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index c90f4146e5a2..ccf99351f058 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))
> >
> >  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
> >
> > +# Python 3.8 changed the output of `python-config --ldflags` to not include the
> > +# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
> > +# libpython fails if that flag is not included in LDFLAGS
> > +ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null;
> > echo $$?), 0)
>
> patching file tools/perf/Makefile.config
> patch: **** malformed patch at line 108: echo $$?), 0)
>
>
> > +  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
> > +else
> > +  PYTHON_CONFIG_LDFLAGS := --ldflags
> > +endif
> > +
> >  ifdef PYTHON_CONFIG
> > -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
> > +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ)
> > $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
>
> patching file tools/perf/Makefile.config
> patch: **** malformed patch at line 116: $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
>
> >    PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
> >    PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
> >    PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
> >
> > base-commit: d5d359b0ac3ffc319ca93c46a4cfd87093759ad6
> > --
> > 2.25.0
> >
>

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

* Re: [PATCH] perf: Support Python 3.8+ in Makefile
  2020-02-22 16:38   ` Sam Lunt
@ 2020-02-24  7:00     ` He Zhe
  0 siblings, 0 replies; 8+ messages in thread
From: He Zhe @ 2020-02-24  7:00 UTC (permalink / raw)
  To: Sam Lunt
  Cc: linux-kernel, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, Jiri Olsa, namhyung, trivial



On 2/23/20 12:38 AM, Sam Lunt wrote:
> On Sun, Feb 16, 2020 at 8:24 PM He Zhe <zhe.he@windriver.com> wrote:
>> On 2/1/20 2:11 AM, Sam Lunt wrote:
>>> Python 3.8 changed the output of 'python-config --ldflags' to no longer
>>> include the '-lpythonX.Y' flag (this apparently fixed an issue loading
>>> modules with a statically linked Python executable).  The libpython
>>> feature check in linux/build/feature fails if the Python library is not
>>> included in FEATURE_CHECK_LDFLAGS-libpython variable.
>>>
>>> This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
>>> the '--embed' flag and passes that flag alongside '--ldflags' if so.
>>>
>>> tools/perf is the only place the libpython feature check is used.
>>>
>>> Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
>>> ---
>>>  tools/perf/Makefile.config | 11 ++++++++++-
>>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>>> index c90f4146e5a2..ccf99351f058 100644
>>> --- a/tools/perf/Makefile.config
>>> +++ b/tools/perf/Makefile.config
>>> @@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))
>>>
>>>  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
>>>
>>> +# Python 3.8 changed the output of `python-config --ldflags` to not include the
>>> +# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
>>> +# libpython fails if that flag is not included in LDFLAGS
>>> +ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
>>> +  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
>>> +else
>>> +  PYTHON_CONFIG_LDFLAGS := --ldflags
>>> +endif
>>> +
>>>  ifdef PYTHON_CONFIG
>>> -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
>>> +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
>> I met the same problem. Would the following change be more simple and clear?
>>
>> -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
>> +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>/dev/null || $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
> That change is nearly equivalent to the change I'd suggested, just
> squashed into one line. I think it's certainly more terse, but I'm not
> sure it's any clearer.
>
> It's also making the implicit assumption that PYTHON_CONFIG_SQ does
> not print anything to stdout when it exits with a non-zero return
> code. I think that's probably a safe assumption, but it seems more
> robust not to make that assumption at all.

That said, such assumption was also made in the "else" case of your change and
in the original line. If we wanted that robustness, we'd better give a stricter
condition and a warning like below.

+ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
+  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
+else ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags 2>&1 1>/dev/null; echo $$?), 0)
+  PYTHON_CONFIG_LDFLAGS := --ldflags
+else
+  $(warning Failed to get python ldflags.)
+endif

Given that such kind of assumptions spread across kernel makefiles, the
one-liner might be good enough.


Regards,
Zhe

>
> Best,
> Sam


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

* Re: [PATCH] perf: Support Python 3.8+ in Makefile
  2020-02-17  2:23 ` He Zhe
@ 2020-02-22 16:38   ` Sam Lunt
  2020-02-24  7:00     ` He Zhe
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Lunt @ 2020-02-22 16:38 UTC (permalink / raw)
  To: He Zhe
  Cc: linux-kernel, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, Jiri Olsa, namhyung, trivial

On Sun, Feb 16, 2020 at 8:24 PM He Zhe <zhe.he@windriver.com> wrote:
> On 2/1/20 2:11 AM, Sam Lunt wrote:
> > Python 3.8 changed the output of 'python-config --ldflags' to no longer
> > include the '-lpythonX.Y' flag (this apparently fixed an issue loading
> > modules with a statically linked Python executable).  The libpython
> > feature check in linux/build/feature fails if the Python library is not
> > included in FEATURE_CHECK_LDFLAGS-libpython variable.
> >
> > This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
> > the '--embed' flag and passes that flag alongside '--ldflags' if so.
> >
> > tools/perf is the only place the libpython feature check is used.
> >
> > Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
> > ---
> >  tools/perf/Makefile.config | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> > index c90f4146e5a2..ccf99351f058 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))
> >
> >  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
> >
> > +# Python 3.8 changed the output of `python-config --ldflags` to not include the
> > +# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
> > +# libpython fails if that flag is not included in LDFLAGS
> > +ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
> > +  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
> > +else
> > +  PYTHON_CONFIG_LDFLAGS := --ldflags
> > +endif
> > +
> >  ifdef PYTHON_CONFIG
> > -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
> > +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
>
> I met the same problem. Would the following change be more simple and clear?
>
> -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
> +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>/dev/null || $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)

That change is nearly equivalent to the change I'd suggested, just
squashed into one line. I think it's certainly more terse, but I'm not
sure it's any clearer.

It's also making the implicit assumption that PYTHON_CONFIG_SQ does
not print anything to stdout when it exits with a non-zero return
code. I think that's probably a safe assumption, but it seems more
robust not to make that assumption at all.

Best,
Sam

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

* Re: [PATCH] perf: Support Python 3.8+ in Makefile
  2020-01-31 18:11 Sam Lunt
  2020-02-06 18:57 ` Jiri Olsa
@ 2020-02-17  2:23 ` He Zhe
  2020-02-22 16:38   ` Sam Lunt
  1 sibling, 1 reply; 8+ messages in thread
From: He Zhe @ 2020-02-17  2:23 UTC (permalink / raw)
  To: Sam Lunt, linux-kernel, peterz, mingo, acme
  Cc: mark.rutland, alexander.shishkin, jolsa, namhyung, trivial



On 2/1/20 2:11 AM, Sam Lunt wrote:
> Python 3.8 changed the output of 'python-config --ldflags' to no longer
> include the '-lpythonX.Y' flag (this apparently fixed an issue loading
> modules with a statically linked Python executable).  The libpython
> feature check in linux/build/feature fails if the Python library is not
> included in FEATURE_CHECK_LDFLAGS-libpython variable.
>
> This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
> the '--embed' flag and passes that flag alongside '--ldflags' if so.
>
> tools/perf is the only place the libpython feature check is used.
>
> Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
> ---
>  tools/perf/Makefile.config | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index c90f4146e5a2..ccf99351f058 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))
>
>  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
>
> +# Python 3.8 changed the output of `python-config --ldflags` to not include the
> +# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
> +# libpython fails if that flag is not included in LDFLAGS
> +ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
> +  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
> +else
> +  PYTHON_CONFIG_LDFLAGS := --ldflags
> +endif
> +
>  ifdef PYTHON_CONFIG
> -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
> +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)

I met the same problem. Would the following change be more simple and clear?

-  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>/dev/null || $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)


Thanks,
Zhe


>    PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
>    PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
>    PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
>
> base-commit: d5d359b0ac3ffc319ca93c46a4cfd87093759ad6


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

* Re: [PATCH] perf: Support Python 3.8+ in Makefile
  2020-01-31 18:11 Sam Lunt
@ 2020-02-06 18:57 ` Jiri Olsa
  2020-02-17  2:23 ` He Zhe
  1 sibling, 0 replies; 8+ messages in thread
From: Jiri Olsa @ 2020-02-06 18:57 UTC (permalink / raw)
  To: Sam Lunt
  Cc: linux-kernel, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, namhyung, trivial

On Fri, Jan 31, 2020 at 12:11:23PM -0600, Sam Lunt wrote:
> Python 3.8 changed the output of 'python-config --ldflags' to no longer
> include the '-lpythonX.Y' flag (this apparently fixed an issue loading
> modules with a statically linked Python executable).  The libpython
> feature check in linux/build/feature fails if the Python library is not
> included in FEATURE_CHECK_LDFLAGS-libpython variable.
> 
> This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
> the '--embed' flag and passes that flag alongside '--ldflags' if so.
> 
> tools/perf is the only place the libpython feature check is used.
> 
> Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>

Acked-by: Jiri Olsa <jolsa@redhat.com>

thanks,
jirka

> ---
>  tools/perf/Makefile.config | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index c90f4146e5a2..ccf99351f058 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))
> 
>  PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
> 
> +# Python 3.8 changed the output of `python-config --ldflags` to not include the
> +# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
> +# libpython fails if that flag is not included in LDFLAGS
> +ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
> +  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
> +else
> +  PYTHON_CONFIG_LDFLAGS := --ldflags
> +endif
> +
>  ifdef PYTHON_CONFIG
> -  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
> +  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
>    PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
>    PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
>    PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)
> 
> base-commit: d5d359b0ac3ffc319ca93c46a4cfd87093759ad6
> -- 
> 2.25.0
> 


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

* [PATCH] perf: Support Python 3.8+ in Makefile
@ 2020-01-31 18:11 Sam Lunt
  2020-02-06 18:57 ` Jiri Olsa
  2020-02-17  2:23 ` He Zhe
  0 siblings, 2 replies; 8+ messages in thread
From: Sam Lunt @ 2020-01-31 18:11 UTC (permalink / raw)
  To: linux-kernel, peterz, mingo, acme
  Cc: mark.rutland, alexander.shishkin, jolsa, namhyung, trivial

Python 3.8 changed the output of 'python-config --ldflags' to no longer
include the '-lpythonX.Y' flag (this apparently fixed an issue loading
modules with a statically linked Python executable).  The libpython
feature check in linux/build/feature fails if the Python library is not
included in FEATURE_CHECK_LDFLAGS-libpython variable.

This adds a check in the Makefile to determine if PYTHON_CONFIG accepts
the '--embed' flag and passes that flag alongside '--ldflags' if so.

tools/perf is the only place the libpython feature check is used.

Signed-off-by: Sam Lunt <samuel.j.lunt@gmail.com>
---
 tools/perf/Makefile.config | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index c90f4146e5a2..ccf99351f058 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -228,8 +228,17 @@ strip-libs  = $(filter-out -l%,$(1))

 PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))

+# Python 3.8 changed the output of `python-config --ldflags` to not include the
+# '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
+# libpython fails if that flag is not included in LDFLAGS
+ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
+  PYTHON_CONFIG_LDFLAGS := --ldflags --embed
+else
+  PYTHON_CONFIG_LDFLAGS := --ldflags
+endif
+
 ifdef PYTHON_CONFIG
-  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
+  PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) $(PYTHON_CONFIG_LDFLAGS) 2>/dev/null)
   PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
   PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) -lutil
   PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --includes 2>/dev/null)

base-commit: d5d359b0ac3ffc319ca93c46a4cfd87093759ad6
-- 
2.25.0

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

end of thread, other threads:[~2020-02-24  7:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-25 14:56 [PATCH] perf: Support Python 3.8+ in Makefile Sam Lunt
2020-01-29  7:54 ` Jiri Olsa
2020-01-31 18:06   ` Sam Lunt
2020-01-31 18:11 Sam Lunt
2020-02-06 18:57 ` Jiri Olsa
2020-02-17  2:23 ` He Zhe
2020-02-22 16:38   ` Sam Lunt
2020-02-24  7:00     ` He Zhe

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).