From patchwork Tue Dec 13 23:26:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 32984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp420377wrn; Tue, 13 Dec 2022 15:28:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6jebrMPT+M/KUWpAwfvUXK3rYnEa7WlZAHh3xLfnYFZRgEgs72aMOEkQUv1IVJBBU2qL80 X-Received: by 2002:aa7:d34e:0:b0:46b:cb37:117b with SMTP id m14-20020aa7d34e000000b0046bcb37117bmr21059069edr.39.1670974122717; Tue, 13 Dec 2022 15:28:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670974122; cv=none; d=google.com; s=arc-20160816; b=Ys0l3904lp5nS52JNIJbHsDyqA+1x+ejjuqpHwSa/AJU2DmKUqmZvGxkoE6MpkJpGi mCBYk9GnFfpvOEGggHopdqUTWKCpnxA2PF+0mywfD8ZVRJ8ZFKVggvzAd/DriJdrPVuK 7CfL+74B6L7i/CCxxeBnyRg+3w6QlLtMDWrcI2o0osSPkUbhJLGpXSjYDbczI2Vl/OTu q2jx2KEY6kBQoOURRkodB8hPfA9s8ktX1uBHbjYVrZssVfBXpjZxQ9i6q5HYxfYbLQfD aobAj5rUMsPtxyCb4PSnWXvyYOZpi/dkPviRPH2i2A9WTYAwgxFCWT13HXS6Nfxh8D3p 1uGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=aIVRe/cOjz9L4S8nY/UBbQxzSd/MuoYQzSglM53rsyM=; b=so4+sJVBruDTqlSZT9PQdEtv8RFAHM0Pz0NNKytfAx8VqI6BVS8L8/13gIqG1DwXDp NNkP4dB/6I1MlgSABAwRpjDTYQRTVnopZBPmySC5u76qJ+ZFeCtUQBLYNKSUKn+hfXEc pHZAS28tCEokgclmiZHJ2mteT6I9dOpKgBSi/IrJ0T5VDVwwlGwMKkwWTtYS0WfZn2wS peoVOMcOGtK+b6XRjvGkNYGqvk4emN9HA03hiJfIvuZggISfzKRZB3wXcZ8mgqez/xw2 +2pl9V51kWRcUb6q+CaFq4vRl05QY2y20BrZfty/pDnNy6ePhBf+WLewOYc0jLg27DZs tl6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MpdcS79F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a056402037000b0046351fa4ae2si9652888edw.99.2022.12.13.15.28.19; Tue, 13 Dec 2022 15:28:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=MpdcS79F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237053AbiLMX1Z (ORCPT + 99 others); Tue, 13 Dec 2022 18:27:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237009AbiLMX1Q (ORCPT ); Tue, 13 Dec 2022 18:27:16 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1E34C750 for ; Tue, 13 Dec 2022 15:27:15 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 203-20020a2502d4000000b006f94ab02400so18470207ybc.2 for ; Tue, 13 Dec 2022 15:27:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=aIVRe/cOjz9L4S8nY/UBbQxzSd/MuoYQzSglM53rsyM=; b=MpdcS79Frn7RTmMinJubNMYt88+6lL4Cqi6ZXslqSjEcj3Cc+ffaIF61e32yPrqXKr oEEqe5WgQXYXZIwaecs50menBnE+KS4PInPrB6VEHfGFllC3dcUZC0AjLUmtokz7oV3/ RhB14QI8hD+y2MaD0x09hL0YwxrlvEqzZQhSdQkJ66qn7bh41UNsjNYQ7gEdWFbaCi8b tXu8U1lQ///G1A7PA4TPQ5zf42wdDIUAdN19sx5NEmRQrmaqgG7w95voh5PLKyRm/2QZ IrA88MyZRV0FXu4tk++gTPp87PNt4e1V5zu0CGP6d4B3B7TJdjLJUdI6eQBowjNRtpwJ Ftsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=aIVRe/cOjz9L4S8nY/UBbQxzSd/MuoYQzSglM53rsyM=; b=JKR943rlUGOJbhj5zf9+IqpuWs9UQ774X0BshXIvkSMQWaF7zbJiNM5TNTfqCq+1ja isbHJOCfzrbedXnSDWVHyCdNLz/tsQCGpHjXSNCv3KLSPu8pXRht1sFtqSoNQLFQD5/V eo0nbSjZ6ya8ojZ4gpLc+K+DYF2kgZ8Nr2+/eRsJqJuMTgsCIPrZ03XQsQ1aEJphVH1a FyMOXba81LVSR29ONm+FACNb5i0lGAwTyC3QdHKKd7FisnEWsFJvPJipOC6O0RUSHAzO kkJf1h9FiZB0dJpRjXqA+R9+d3lzGctL+o46PPBqTVTVzeaLrnIn6iK2/4DY+ikcO6kW MzSg== X-Gm-Message-State: ANoB5pnOOo4gowiO3rD9uL9sW9Gf4bJezUMM1zeUMfQg0d6/NtdatNBp kD44zjAU7Ua9Z0czt0XhWyLlEXJLFADZ X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:6268:b448:f7f4:4c2]) (user=irogers job=sendgmr) by 2002:a81:4e09:0:b0:370:202b:f085 with SMTP id c9-20020a814e09000000b00370202bf085mr26434974ywb.502.1670974035210; Tue, 13 Dec 2022 15:27:15 -0800 (PST) Date: Tue, 13 Dec 2022 15:26:47 -0800 In-Reply-To: <20221213232651.1269909-1-irogers@google.com> Message-Id: <20221213232651.1269909-2-irogers@google.com> Mime-Version: 1.0 References: <20221213232651.1269909-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v1 1/5] perf build: Fix python/perf.so library's name From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexey Bayduraev , Adrian Hunter , Anshuman Khandual , Andi Kleen , James Clark , Sandipan Das , German Gomez , Leo Yan , Timothy Hayes , Kan Liang , Xing Zhengjun , Kim Phillips , Riccardo Mancini , Sean Christopherson , shaomin Deng , Eelco Chaudron , Athira Jajeev , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Cc: Stephane Eranian , Ian Rogers X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752143361479763446?= X-GMAIL-MSGID: =?utf-8?q?1752143361479763446?= Since Python 3.3 extensions have a suffix encoding platform and version information. For example, the perf extension was previously perf.so but now maybe perf.cpython-310-x86_64-linux-gnu.so. Compute the extension using Python and then use this in the target name. Doing this avoids the "perf.so" target always being rebuilt. Signed-off-by: Ian Rogers --- tools/perf/Makefile.config | 4 +++- tools/perf/Makefile.perf | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index 52a4dc029111..83ed969b95b4 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -871,6 +871,7 @@ define disable-python_code NO_LIBPYTHON := 1 endef +PYTHON_EXTENSION_SUFFIX := '.so' ifdef NO_LIBPYTHON $(call disable-python,Python support disabled by user) else @@ -889,7 +890,8 @@ else else LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) - LANG_BINDINGS += $(obj-perf)python/perf.so + PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])') + LANG_BINDINGS += $(obj-perf)python/perf$(PYTHON_EXTENSION_SUFFIX) CFLAGS += -DHAVE_LIBPYTHON_SUPPORT $(call detected,CONFIG_LIBPYTHON) endif diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 98f629bbd1aa..9b7886ce0674 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -647,7 +647,7 @@ all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) $(OTHER_PROGRAMS) # Create python binding output directory if not already present _dummy := $(shell [ -d '$(OUTPUT)python' ] || mkdir -p '$(OUTPUT)python') -$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBPERF) +$(OUTPUT)python/perf$(PYTHON_EXTENSION_SUFFIX): $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) $(LIBPERF) $(QUIET_GEN)LDSHARED="$(CC) -pthread -shared" \ CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' \ $(PYTHON_WORD) util/setup.py \