Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5030650rwl; Sun, 8 Jan 2023 07:28:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXvAQzX4pDkUJKFHblNzsUxzUY95xHCK7qZero00RQpLy83OJB4PhW6UgqOYPEuMC6TeCX5F X-Received: by 2002:aa7:d0c9:0:b0:498:d121:6e00 with SMTP id u9-20020aa7d0c9000000b00498d1216e00mr3194191edo.35.1673191711545; Sun, 08 Jan 2023 07:28:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673191711; cv=none; d=google.com; s=arc-20160816; b=PTQhbG6hd3oI9IyBdjYCu+5fgulhgTNqNsa2I7hPWljySsHCNKI05XcqPbnQ1vZtCL 4aRzwxPzGkv3aB2kD16dNlUrPJB9Y5qETFDM+ToG+dNmC+nJyZMrvtokkOdGW80RrygL OA3zvVuA0OrPXIG3DhGPteMcLrqqjXDgCparxxqU7OhDJPWABlV3uC4WMQ6GwIFSP4rZ j329c0VgESC24N6/o25G92xKFLcWS1RY11XYJf4BSGpPu4bQ6TZC8sGnmqOWrk2Zh+02 +Bvai1Gk8ptxYjOTaWB2D573bqBz/qrm3MNqUYiDBNbnErBrj9rPX1lb4UiaB6HHG6Wz qm8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EPjethgfbpXdoRd0XcBNPqRZDZHvORJ5WlXtoiZqGUc=; b=mkE+TwEWmRYjG19fC8k1JxdEEIBF84iHTa6hXp31Awj1+HOWPlQzOLr0B5ln/Wvrx2 QzJXNuWs+nWxgYetFU5EmFeSOPT4qrEYNepPJjilQnllAVOr3PHc5ROGzCcoOSotsxG8 2i4J8zy/dvubbdOp5COOI6eJxZxoN7d5DH5MtOwopPd0EJphI8knhwI4fjeuZ+BnDm03 4cw8xyr/amBEUNLEPnSPzq7ess1Iyb5f7L+OVw3SQ0nf69o84iIuukiTKunnzj0M7N9H qNf34nlQcPKnKYmBhaYbx7agvVVMDdkoCsyQYz4+E5uv2HgME+jQHEFoxLW1dgh+57zo TSIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TIqzD15S; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm19-20020a0564020c9300b0048eda35a868si5780920edb.222.2023.01.08.07.28.19; Sun, 08 Jan 2023 07:28:31 -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=@redhat.com header.s=mimecast20190719 header.b=TIqzD15S; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233691AbjAHPTI (ORCPT + 53 others); Sun, 8 Jan 2023 10:19:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbjAHPTF (ORCPT ); Sun, 8 Jan 2023 10:19:05 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CBFAB1CF for ; Sun, 8 Jan 2023 07:18:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673191099; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EPjethgfbpXdoRd0XcBNPqRZDZHvORJ5WlXtoiZqGUc=; b=TIqzD15Sz/YmSo6ZiKCBD7lhIXiz/VX4KHAfQVuj26zt1/6ET2VRRNklxxQH0oHQQFCz7L IhM4h35BdvsYk3MPMDrhIWj1E4MkV/76nrDTpkVcN3PR3xLiIuoKneA8TR16PzKlunl264 KIEVnPzLL96WoVIH9VjrnU8BmN1nrak= Received: from mail-ua1-f71.google.com (mail-ua1-f71.google.com [209.85.222.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-589-Tzi3t9spPV2cvrLd0nrjEA-1; Sun, 08 Jan 2023 10:18:18 -0500 X-MC-Unique: Tzi3t9spPV2cvrLd0nrjEA-1 Received: by mail-ua1-f71.google.com with SMTP id z12-20020ab0564c000000b00516777f7197so3066036uaa.11 for ; Sun, 08 Jan 2023 07:18:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EPjethgfbpXdoRd0XcBNPqRZDZHvORJ5WlXtoiZqGUc=; b=FgxrUlUbo0TiczX8BvN9AvGtdtvzJCTgWC5n6nU2Z1TDo8xV4xO/6UTKJ35/gzTABE PVlfq1QFlCBLEl+mY9AgEa3hkwiilUuKLULY2jl0ZVZyS+8xguiFH+3dghWoIM+1AhCV aJbAiYK7k7ILrOZpoTQW7nuBSV+zw4acgJnw1r4XYTryxhSp8W1Yt7h9hwvOr4Zc6zjQ MwTss2QW8TDK3GxSfZuR+1jGY4fr6eC0dlxwnwZ9wplkQZjnNhSCxQ87PX7Qk7d7xjGK VIku3SCuAp0U5qv+zx2BrAAUuNH0dQNLoI2bQpyxVSBKM0mzaa/9rA2g+33K7rsxxxNz FfLw== X-Gm-Message-State: AFqh2koLjzA+BqcHQRWNw924HA+bEc3XQ90PouCv6Xf5dHo9pn/4ob4v 3QLR6fTpy027TyWM8NIaMf38Ea9d2GlD+e/ij/sLb57mIh262HpV2Db1vGU1rg7/Uw5Fwys6TdK BhcdEU/keurrVNcIK7UEtJ3MziRqNrlmCVBQvzMkf X-Received: by 2002:a05:6102:cd4:b0:3c8:92b3:7a28 with SMTP id g20-20020a0561020cd400b003c892b37a28mr8001454vst.13.1673191097006; Sun, 08 Jan 2023 07:18:17 -0800 (PST) X-Received: by 2002:a05:6102:cd4:b0:3c8:92b3:7a28 with SMTP id g20-20020a0561020cd400b003c892b37a28mr8001446vst.13.1673191096800; Sun, 08 Jan 2023 07:18:16 -0800 (PST) MIME-Version: 1.0 References: <20230108021450.120791-1-yakoyoku@gmail.com> In-Reply-To: <20230108021450.120791-1-yakoyoku@gmail.com> From: Eric Curtin Date: Sun, 8 Jan 2023 15:18:01 +0000 Message-ID: Subject: Re: [PATCH v2] scripts: Exclude Rust CUs with pahole To: Martin Rodriguez Reboredo Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Neal Gompa , bpf@vger.kernel.org, rust-for-linux@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Jiri Olsa , Yonghong Song , Miguel Ojeda Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 On Sun, 8 Jan 2023 at 02:15, Martin Rodriguez Reboredo wrote: > > Version 1.24 of pahole has the capability to exclude compilation units > (CUs) of specific languages. Rust, as of writing, is not currently > supported by pahole and if it's used with a build that has BTF debugging > enabled it results in malformed kernel and module binaries (see > Rust-for-Linux/linux#735). So it's better for pahole to exclude Rust > CUs until support for it arrives. > > Reviewed-by: Eric Curtin > Tested-by: Eric Curtin > Reviewed-by: Neal Gompa > Tested-by: Neal Gompa > Signed-off-by: Martin Rodriguez Reboredo > --- > V1 -> V2: Removed dependency on auto.conf > > init/Kconfig | 2 +- > lib/Kconfig.debug | 9 +++++++++ > scripts/Makefile.modfinal | 4 ++++ > scripts/link-vmlinux.sh | 4 ++++ > 4 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/init/Kconfig b/init/Kconfig > index 694f7c160c9c..360aef8d7292 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -1913,7 +1913,7 @@ config RUST > depends on !MODVERSIONS > depends on !GCC_PLUGINS > depends on !RANDSTRUCT > - depends on !DEBUG_INFO_BTF > + depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDE > select CONSTRUCTORS > help > Enables Rust support in the kernel. > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug > index ea4c903c9868..d473d491e709 100644 > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -364,6 +364,15 @@ config PAHOLE_HAS_BTF_TAG > btf_decl_tag) or not. Currently only clang compiler implements > these attributes, so make the config depend on CC_IS_CLANG. > > +config PAHOLE_HAS_LANG_EXCLUDE > + def_bool PAHOLE_VERSION >= 124 > + help > + Support for the --lang_exclude flag which makes pahole exclude > + compilation units from the supplied language. Used in Kbuild to > + omit Rust CUs which are not supported in version 1.24 of pahole, > + otherwise it would emit malformed kernel and module binaries when > + using DEBUG_INFO_BTF_MODULES. > + > config DEBUG_INFO_BTF_MODULES > def_bool y > depends on DEBUG_INFO_BTF && MODULES && PAHOLE_HAS_SPLIT_BTF > diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal > index 25bedd83644b..a880f2d6918f 100644 > --- a/scripts/Makefile.modfinal > +++ b/scripts/Makefile.modfinal > @@ -30,6 +30,10 @@ quiet_cmd_cc_o_c = CC [M] $@ > > ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) > > +ifdef CONFIG_RUST > +PAHOLE_FLAGS += --lang_exclude=rust > +endif > + > quiet_cmd_ld_ko_o = LD [M] $@ > cmd_ld_ko_o += \ > $(LD) -r $(KBUILD_LDFLAGS) \ > diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh > index 918470d768e9..69eb0bea89bf 100755 > --- a/scripts/link-vmlinux.sh > +++ b/scripts/link-vmlinux.sh > @@ -122,6 +122,10 @@ gen_btf() > return 1 > fi > > + if is_enabled CONFIG_RUST; then > + PAHOLE_FLAGS="${PAHOLE_FLAGS} --lang_exclude=rust" > + fi If it was me, I would do things more like v1 of the patch (instead just checking pahole version), because this is the only flag set in scripts/Makefile.modfinal, which is a little confusing and inconsistent. It's ok to set --lang_exclude=rust in all cases, as long as pahole_ver is recent enough. +if [ "${pahole_ver}" -ge "124" ]; then + # see PAHOLE_HAS_LANG_EXCLUDE + extra_paholeopt="${extra_paholeopt} --lang_exclude=rust" +fi But I'm not too opinionated either on this so... Reviewed-by: Eric Curtin can be reapplied. I'm gonna test this again to see if it works in a Fedora Asahi rpm build. > + > vmlinux_link ${1} > > info "BTF" ${2} > -- > 2.39.0 >