Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp356309pxb; Wed, 14 Apr 2021 17:41:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwye7g5HRZl05XK4GdTj46gZPILb0vQNWPhI+v8PSxV/iFvAX7p+v3mvtRo+YjJCmm+eSuT X-Received: by 2002:a05:6402:3592:: with SMTP id y18mr981296edc.360.1618447285925; Wed, 14 Apr 2021 17:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447285; cv=none; d=google.com; s=arc-20160816; b=aC3qKRWn5FMKAxNEBcheeGMRyuVpbkee9IqdapDaNyxdE9YG8lhdOMGlngoMsoxIw8 jaRKXXN9PQ/GJ6kDZVAbT3iyOHTWjna8qgHHwkNeC+ZnXGrWqg/0D2gTyBg7OhXw/HL0 sSDZuXvyHWUSN6rrxxzEcbpjMKLdnSTf0IdBuz5mWE7YGlzSDmfeRksW05AVG+ElatQX a0wmN02l5Mx+Bxx8GSgLBBytj3SBino4rjhVFdJJi9SGms9bGz7VhHDAYZiGJI5KbWVi K8VeTf9WaDbrOWOcIvoE9geTVFQRv8kKgqkC3E1/fJiHaAEvH9xL6DkscEUc/iIK53+v lOvQ== 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=SWyIt24KcDr6o9IDk1UPa1l86tas5Hod0mxp2M9CLIA=; b=OyuEVi02zDd/GT9sHQzom1KxpHokEMGoBQazWSHQELnzzXChyl/H4cW64CW5i2+RHC cXM6YGOQKkLApm5igIaReGn1/ldYEyHhQw3z0eBBMztjpMcV8VVcMnU5pVIk7BQ1oBJu 71pasyZxikN61p1qc+CsWpMz56p/REt+LCo+VvWL465kOiCFWR9WatCsGoNr/uYZW4yT 2wa1pd/1vd0nyZdml4nXAQiRZMiCUt4jHp1mnpn3x+wHSSzlq6WBBJ4aplps6ZFSJfK3 f+CzS5r3vza5PuC6leilfdf3oByNPRmEAom2LY4f2OazN33Wy+2dx5F+r/EzbtIJWecz Hf6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KpUs7fRO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr36si749982ejc.239.2021.04.14.17.41.03; Wed, 14 Apr 2021 17:41:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KpUs7fRO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1352953AbhDNSsH (ORCPT + 99 others); Wed, 14 Apr 2021 14:48:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:49456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353087AbhDNSrQ (ORCPT ); Wed, 14 Apr 2021 14:47:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D470161153; Wed, 14 Apr 2021 18:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618426015; bh=O0lL9Ycy6w5ZehTDvmANxUVy4sdu6XTD/gExW0gRZqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KpUs7fROxIbk7t+Z0RQoRJ2BBI+72Chp3K8K8SnLqAUGeaVPoIejyEsqskpm24b1v FdDtfc4GbDg1iYTWNwUtPYZ6PFoPyzjVdKFxX+nk9VCTyg6oETf1+gJa3akvjegS6H RMRfmX76aGvwykiWzAnv5mvDPaW4b3NoO0zk6cTd9ecqWLy7YSgvWPAX4Fe/wp5Smy 2/Vg5RYoAVfGPKiNg4kvn7nw6jOs5piBDRZ17z+n5cDQUNDtZi3caYCWHvqE1Us2SO kUP+ROGN3Yuw0syCqQoiXB8YiTLIv92cyIR3C6g0MuGNv9dUEClW4lDmwPtY/TUEqa TFoShQ9EWEoZw== From: ojeda@kernel.org To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Miguel Ojeda , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho Subject: [PATCH 08/13] Rust: Export generated symbols Date: Wed, 14 Apr 2021 20:45:59 +0200 Message-Id: <20210414184604.23473-9-ojeda@kernel.org> In-Reply-To: <20210414184604.23473-1-ojeda@kernel.org> References: <20210414184604.23473-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miguel Ojeda Now that all the shared Rust infrastructure is in, we export all the symbols reusing the `EXPORT_SYMBOL_GPL` macro from C. The lists of symbols are generated on the fly when compiling the crates. 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: Geoffrey Thomas Signed-off-by: Geoffrey Thomas Co-developed-by: Finn Behrens Signed-off-by: Finn Behrens Co-developed-by: Adam Bratschi-Kaye Signed-off-by: Adam Bratschi-Kaye Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Signed-off-by: Miguel Ojeda --- rust/Makefile | 2 ++ rust/exports.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 rust/exports.c diff --git a/rust/Makefile b/rust/Makefile index dbbbdbad6941..2d1d9d7af77c 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -9,6 +9,8 @@ extra-$(CONFIG_RUST) += bindings_generated.rs obj-$(CONFIG_RUST) += alloc.o kernel.o extra-$(CONFIG_RUST) += exports_alloc_generated.h exports_kernel_generated.h +obj-$(CONFIG_RUST) += exports.o + RUSTDOC = rustdoc quiet_cmd_rustdoc = RUSTDOC $< diff --git a/rust/exports.c b/rust/exports.c new file mode 100644 index 000000000000..d7dff1b3b919 --- /dev/null +++ b/rust/exports.c @@ -0,0 +1,16 @@ +// 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). + +#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_kernel_generated.h" -- 2.17.1