Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2294043imn; Mon, 1 Aug 2022 19:29:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR582sTLjEbNF+OR1Aulv1fsa0j/3V/c9tO3ZYS2lWB3TsBH+aBmHDq7C8Cs0AqAHmJ1yLIx X-Received: by 2002:a17:902:7005:b0:16d:bcca:443e with SMTP id y5-20020a170902700500b0016dbcca443emr18901977plk.73.1659407381750; Mon, 01 Aug 2022 19:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659407381; cv=none; d=google.com; s=arc-20160816; b=sQ8HhT8LV7UBQqc7eHXl7z4xx0j9bpSQHjeh6yeDk266ZgKa5U8hy3vXmRaTMNxH4r Ww1mjkV1H0esenyLBQU06+fDeMxPHfepQS/ZiBYkrY9Gzy93mszKx/doke6oMNJThqwW 6Rn/qcRG+TCv1b12uwrbVxoeWIYr0RgUNTF0KRUFAPnxm9+wAexJbJkhOGIbrF9O0ozA Hj9nBFhckunm8P5jfBDGzOVZsAirme4sTj4mUZRQUBZuelmllzn0QzuWZqA/WEn+/hP9 RZM6Ip/rEcAS/Da9qxRPSpMNVYyCoEkLb4VMd/lfxDZXS5PTQNzwAvZRdRlL/REitn47 vc/Q== 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=ojuLC1I5SuVc9vx4q9LKXkKLYoo9NC6IB8ZMCB1B4ob9Xa2Xp+sA8WOyNHGuWVqBfO xVjLva8JrgElytxF9BDt6eHAvocRPg1XBF/gCf1NPzW1JqjNPDBhnT9iCx71/emgsJFY xGsA6sDuQ26VLIZsoMMmYe8TA7JJkavrOHD1iyKPGpNNxzMRQif70aIqhfqP6+6jMOkg K9lD18H2bRC9t+eosAfhh6+d5dl2ZLGhRCECuqGolQ3qRO5pWp2BehlUImuNtKzMl2aH Q5U2rbr8mCLi1AqdDz5dfsI7w16FCJQb94jqgoscv3MQbj4PU7ZHhoLUra9JVLSUDiHy shvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uULhgZSf; 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 m9-20020a63f609000000b0041b022ba97csi13175439pgh.87.2022.08.01.19.29.27; Mon, 01 Aug 2022 19:29:41 -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=uULhgZSf; 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 S235628AbiHBBy4 (ORCPT + 99 others); Mon, 1 Aug 2022 21:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235616AbiHBBxp (ORCPT ); Mon, 1 Aug 2022 21:53:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3084C4AD79; Mon, 1 Aug 2022 18:53:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id A60BDB81919; Tue, 2 Aug 2022 01:53:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BDC7C433D6; Tue, 2 Aug 2022 01:52:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659405179; bh=Nwvosf4rZfVbsrgfu4jpbeEbnBmN8SkCMgwgVSEaawY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uULhgZSfIhDGavNWTZfQMGmjXiXiDSzPz5L0SCTzw0lG6qg1bPz1jHVyS1guvWqj7 jQIw8fFyBNq7Twc/xoUsq68GHc39/tMV0i4G7mWtaZY0lf5YNxxuNbvrjwUi0+KUKP m34bVwdU4H+Re4N+T1WX6uv2YuFgjbAwStb4d3RWutxN4YnVCDfMWGGOa3FzzK9PCV tlquGbehZ4+iGuzAi2VagvlwQkzjyJSnXb3MjDEV/BQHNxe80964sw5deBFZ/afSvD 72+6B1wBWhOoO8Pal/cvjhngyLwgjWqnWzPlm8LoPZki+e6uutB1KWMzz6f39wqZOA dcmIBVzcQmdVQ== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Jarkko Sakkinen , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= Subject: [PATCH v8 18/31] rust: export generated symbols Date: Tue, 2 Aug 2022 03:50:05 +0200 Message-Id: <20220802015052.10452-19-ojeda@kernel.org> In-Reply-To: <20220802015052.10452-1-ojeda@kernel.org> References: <20220802015052.10452-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 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