Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4279505ybv; Sun, 16 Feb 2020 18:24:57 -0800 (PST) X-Google-Smtp-Source: APXvYqy4SBTLsPvGsQML/ke3Fs7fHpJmD5yPpeXbWxMfdJjSe7LSg5l77fyFDXLamyKEa9+oPKvH X-Received: by 2002:a9d:7d9a:: with SMTP id j26mr10051072otn.21.1581906297288; Sun, 16 Feb 2020 18:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581906297; cv=none; d=google.com; s=arc-20160816; b=NbjxgxGJDX6wgBeYId6TKSLfEFduoGRswZnSwTRl5OKiv8zeNyztHjUT2tdOvUh3bh fvh2KoNCsZRHfYVBpQGYZWWFevxQv0t4Z+wAl6o2vzqC822Q141g5npvG4gN8iVmMPuj 1KspSktAavxGbcBhwYfgYUkukC6ZxF1RMbnqayLwdZiQxD470lpKijSPI4DX6pODAvKj Ci2FPRPArmvkzqiSYGmzc/U8PmPlJ2Buv9H5nGJVvsXYMcYhKStgC6wCkHGFG/AKHDL3 j/GOOz8BBJ7wPLF6qgezVYbev4LEBf8Str5AidNPTA+EimiuGjdKhZmVnAVhsvL6/txK +FNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/DiObY9TAM9bQ2/KGY7cOYIdt9DfQ0d/SvVueSBX1mY=; b=pzlC7v8OVZMY9X409Vw/CNPxbijbFgsbaZixwnzsJ8lnIRkkG9DRHslkA5HA+pFm6g HU15MMUINxG2Zbhka/YpZcdt5fZwmga9iNabWcD+k41zogvgN4X+R4eXeQ6EhY8NkZYU y7Dwu5CqiD/tA7Iaf8TdU0OgnEymsatj/BdxgfGvAShRLY0UtGc9v2ORYMKgtuuEjp1h k9MsvfQlguDOKd1zb3zo55Cili2FBBU9zOrmtWvHufsfhVivQ7NfwuPE2LATkvrx59rc Vuc9exZRvjNd8b/q8x4UGrJ9p0X5WwLZSo1dGYH8x/69qWKr59bxzUxeIQmWHAVbqCXL EtSg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l20si6146368otr.202.2020.02.16.18.24.44; Sun, 16 Feb 2020 18:24:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbgBQCYX (ORCPT + 99 others); Sun, 16 Feb 2020 21:24:23 -0500 Received: from mail.windriver.com ([147.11.1.11]:49039 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgBQCYX (ORCPT ); Sun, 16 Feb 2020 21:24:23 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.15.2/8.15.2) with ESMTPS id 01H2O0lY002285 (version=TLSv1 cipher=AES256-SHA bits=256 verify=FAIL); Sun, 16 Feb 2020 18:24:00 -0800 (PST) Received: from [128.224.162.175] (128.224.162.175) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.3.468.0; Sun, 16 Feb 2020 18:23:59 -0800 Subject: Re: [PATCH] perf: Support Python 3.8+ in Makefile To: Sam Lunt , , , , CC: , , , , References: <20200131181123.tmamivhq4b7uqasr@gmail.com> From: He Zhe Message-ID: <30752f2a-fe0b-4150-c32d-07690fb43b82@windriver.com> Date: Mon, 17 Feb 2020 10:23:54 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200131181123.tmamivhq4b7uqasr@gmail.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [128.224.162.175] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) 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