Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1893604rwb; Fri, 5 Aug 2022 09:26:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR4eyqAgaAkv+zdylxxt9Y+/UIAgGvyX+mTNq7LmdR1+HWWMZm36Ow2/yxoInuf8C30jHP8C X-Received: by 2002:a17:902:c943:b0:16f:15a0:d497 with SMTP id i3-20020a170902c94300b0016f15a0d497mr7554031pla.80.1659716814352; Fri, 05 Aug 2022 09:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659716814; cv=none; d=google.com; s=arc-20160816; b=enZ7co2FYbX6ZRfkEOJ/rIbzEWUByWYv3mUqE8jjfwNAa8jFD7N/MAOBieq1I8ySLI ZoKesBQ7FHp4Do/2zU3b1/BAOVMRhyFNjdldecmyJ1Fptu6Y6OZytomfcTF8xxMQC/gE 1hXXurcGZSzwHUnp7xk+oaTPwTJUM2JIf1BBAcplddpxr4449NyQfl85gmnrQujYZ39M w3ciW/+u2TCgQ+j7aQKgHnrAs6N7pDgqvr+7w/AurSgq1FWVxgP8EXlMghSqeosDQZVO JrgRJ+Z3AUL9Ny+PbjTlmPjgMwqVKGRQ4e3KECcgoflX5tEyt9zvmT84FntTdePUx9Wt kSIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QNrv1ESQzEweDe52ZLjeAM8SBxn8bGFUvf0V9ibKnK8=; b=TcG+kHgEQ6EMpzDs0wqHYvsAd9r6KHYlByyN9dyR8s9SmCkUJ0pL3uIojyKWPpuB7o XTgMq7nrfENjd4mDAnjNMJ4WYj8DM+FbiuEGB1QrtS/47QueVE9b9oOKYgXHIytiRGF+ yh7TcYv5j7tfPuzKjlOazT5qqxXaMOGvX8St4T4Vz+zxK5ombYolV9ZreVshF/6nf6xc JEWwtV20ErgEcnu/A+EzIbM9LM4ckOWWxe2ki4st7zi7xUsIpFu4j7w4M6Pd2GLdEoqy jlzGbCwl7mOS8MYwR1oLwOk26IpL93koDKPCAqYOTvZE7XbFBu4bxC72ebxXikDgA/cM OqIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dKQAqL9y; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020a170902d54800b0016ef08bddc9si4289813plf.170.2022.08.05.09.26.40; Fri, 05 Aug 2022 09:26:54 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=dKQAqL9y; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241276AbiHEPro (ORCPT + 99 others); Fri, 5 Aug 2022 11:47:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241198AbiHEPoV (ORCPT ); Fri, 5 Aug 2022 11:44:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909AC65836; Fri, 5 Aug 2022 08:43:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0520561640; Fri, 5 Aug 2022 15:43:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A75F1C433D6; Fri, 5 Aug 2022 15:43:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659714233; bh=Nwvosf4rZfVbsrgfu4jpbeEbnBmN8SkCMgwgVSEaawY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dKQAqL9y/UdkbINsrxej3GbQq0WaNvo8dW8VgNB3CHHOZ+pJ2hsnJV/JU37fLShDg OLNrj5pVOGJybhT9GxjTBuidD8fXfGgCcQDO8d3mpb68ffrmwz87n07/8r//ZKzzMu sYU9B35juZR33OMSSxKJ598DHBkYVYAJMRF9s7yqpcr1l+nRswhNMoUe/RuAPd5fm0 TshspJBSLYGfJ25R1EuNeK3f4Vi1jKixV38aSpEhRik2D1ON22ofDDcH1QlXnWTs+8 dh3ODin4phNHT2XTSlmzZJ3+9e4lhistJ7FNAE67hI49b9m3s7xGbmyuKoGfU+0Uw3 /USY/bWq9dtMA== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Boqun Feng , Gary Guo Subject: [PATCH v9 13/27] rust: export generated symbols Date: Fri, 5 Aug 2022 17:41:58 +0200 Message-Id: <20220805154231.31257-14-ojeda@kernel.org> In-Reply-To: <20220805154231.31257-1-ojeda@kernel.org> References: <20220805154231.31257-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 All symbols are reexported reusing the `EXPORT_SYMBOL_GPL` macro from C. The lists of symbols are generated on the fly. There are three main sets of symbols to distinguish: - The ones from the `core` and `alloc` crates (from the Rust standard library). The code is licensed as Apache/MIT. - The ones from our abstractions in the `kernel` crate. - The helpers (already exported since they are not generated). We export everything as GPL. This ensures we do not mistakenly expose GPL kernel symbols/features as non-GPL, even indirectly. Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Co-developed-by: Björn Roy Baron Signed-off-by: Björn Roy Baron Signed-off-by: Miguel Ojeda --- rust/exports.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 rust/exports.c diff --git a/rust/exports.c b/rust/exports.c new file mode 100644 index 000000000000..bb7cc64cecd0 --- /dev/null +++ b/rust/exports.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * A hack to export Rust symbols for loadable modules without having to redo + * the entire `include/linux/export.h` logic in Rust. + * + * This requires the Rust's new/future `v0` mangling scheme because the default + * one ("legacy") uses invalid characters for C identifiers (thus we cannot use + * the `EXPORT_SYMBOL_*` macros). + * + * All symbols are exported as GPL-only to guarantee no GPL-only feature is + * accidentally exposed. + */ + +#include + +#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym) + +#include "exports_core_generated.h" +#include "exports_alloc_generated.h" +#include "exports_bindings_generated.h" +#include "exports_kernel_generated.h" -- 2.37.1