Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp529308ybv; Sat, 22 Feb 2020 08:39:46 -0800 (PST) X-Google-Smtp-Source: APXvYqxFuFg/Rw2LFniCkZdmgB5uX2wgplLvDE0bq6UbvTafXLjgY70KBfGh/Y50BEfWFffu5/7V X-Received: by 2002:a05:6808:4cc:: with SMTP id a12mr6966349oie.115.1582389586644; Sat, 22 Feb 2020 08:39:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582389586; cv=none; d=google.com; s=arc-20160816; b=qV74cHoQkEuutTVj6EzPZ+titNohJiZXIZWsOB4Yb27VyynRBFg8x6Cqn+uSYdh2BK Og5z5tvRWKjoEcqYtr2IeV2ZpWIZgIjKdJnXe4/nlvcah16rPTGnOk5ztZ+vhmvd7GQz 32v5u9G8bxxKG4UJtgjTDT6E8SnNFHVQHMOwMbCF17hAhZ1C3Qolnblwb9Qzcs8EZjkn Z2wGJDepj40GvDzZg8TJ/POSWoDlekD6ijC2jtzGbSSYXlzvsBFkim6pyomxPZ3FuXu0 5pbOIdtCGyRc/2ucaBAvfFu0CGURB0ET12OaWkJyfm7w9sf8Ez5rwH+JveaAUmyr0RML yCnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J2lcmTwyMrOPuCOwLWRYUM2f987UesfeSpFXzubq3M0=; b=PS92CwlROepbjTgloCWQkbBjKvP74rt2VYQbGghipvtbGjrKjWe8HVfrTxOVUZXx3t dvZH/Swm5wdV1lYIuzsKqim1jn1Uj1iLGme0dInCcE1qOkSLDboKurka7ZnHvXV9NULn gVhJ3ORK38NtJ1/wX9Tbk20gAirf1BdYdmauIEwiPwAMh3ujchvqmjaMankXvaglbanI MnwqRfqNWB4tRWcQ5BBrNtw4yekGnos290cm/5zSYZtH30m9eqLulrk0hhpf1CWnmv1+ +p+UhYK4GFim/oLPNdjyikjVah/zWM4kd296Rl81M7eSsBhiggOYG2Yz+C/4trcW8DAG 5M0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VPhhDO0X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si3545662otf.143.2020.02.22.08.39.33; Sat, 22 Feb 2020 08:39:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VPhhDO0X; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726688AbgBVQiW (ORCPT + 99 others); Sat, 22 Feb 2020 11:38:22 -0500 Received: from mail-il1-f195.google.com ([209.85.166.195]:39055 "EHLO mail-il1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbgBVQiV (ORCPT ); Sat, 22 Feb 2020 11:38:21 -0500 Received: by mail-il1-f195.google.com with SMTP id f70so4272017ill.6 for ; Sat, 22 Feb 2020 08:38:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=J2lcmTwyMrOPuCOwLWRYUM2f987UesfeSpFXzubq3M0=; b=VPhhDO0XyvOXJuHhhyDeMkuLbqYI5Te3zM8LnOL8z1b7LTEJwYCmtBvh1otLek2RPz hEdXIdQPvAnqSRxDK8XUv1p+OYhx/6X2oJNJ6sX57BIM/adWC+i9Mcg+Lubch6/dQ8XF dj7nljIPBod1kcjm77bWEv+fLG/e9yz62sJxuS5FeFR1U7/twvF4x7zISC2E8HsqP06D 8iVWeKPMn3hQozjvqvK8jJ+aRURyq/PRXTTiOOW6Ct0L/APNPqYFLI7TbrxQQg9wjRUV lGtyU3IQLxIbHZbHbCzE7DaPJCRP5u1KjhfLkZ95BNfdECp/dZ3i0RBvbWH7ns1+Dkc8 LgTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=J2lcmTwyMrOPuCOwLWRYUM2f987UesfeSpFXzubq3M0=; b=myHPkstwbAybzFd5B4wHwedkxfhUV6rFKp6S9xQS/flDDdq2vyumKQowg0hBVx2VPz lc6YmoKFly6jQNqFtN3hMCaqlf3952Um95EJ91q1wKIB7le0jsZXqdx85wQB0MwTM1zc kEch2Epv25QgkAjXSTQfutXL2+vYwBWvfLnDaKuNM0MFz+Z+w8e6PUwRoIY2IQP/YE8p QmaaLIZ1L1b4CjztuNQZqZd53XK0ouYmc5c/w4CMzJieADWdq9XTssG7mnc4RRwkWvtp n6JG0HS0BF5ZEvTNcXKmirbgJzQxi8SpEYH5N/XhvhxpOBvkhTUnBg92PqBD3SY2sdnw h7TA== X-Gm-Message-State: APjAAAWBE7EAjMlf7sCKCGMK7xUlNFnX0irdSCKY4f+W4O9dKDcUnEEV fwZciAf6CJZ73sphMMuU/sD6EP2+MphpuBHgG8g= X-Received: by 2002:a92:9ac5:: with SMTP id c66mr48316823ill.232.1582389500921; Sat, 22 Feb 2020 08:38:20 -0800 (PST) MIME-Version: 1.0 References: <20200131181123.tmamivhq4b7uqasr@gmail.com> <30752f2a-fe0b-4150-c32d-07690fb43b82@windriver.com> In-Reply-To: <30752f2a-fe0b-4150-c32d-07690fb43b82@windriver.com> From: Sam Lunt Date: Sat, 22 Feb 2020 10:38:09 -0600 Message-ID: Subject: Re: [PATCH] perf: Support Python 3.8+ in Makefile To: He Zhe Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, Jiri Olsa , namhyung@kernel.org, trivial@kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 16, 2020 at 8:24 PM He Zhe 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 > > --- > > 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