Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3278348pxv; Sun, 4 Jul 2021 13:30:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3CLbDaS/SoV0rFNVEqg9uGpVMH277B8X4Ehf3uMUXfITc+vFdzFDoi/V9US0tJG7VyI4j X-Received: by 2002:a05:6638:688:: with SMTP id i8mr6603083jab.75.1625430625428; Sun, 04 Jul 2021 13:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625430625; cv=none; d=google.com; s=arc-20160816; b=vGRCLi7tEkmDaYv394X8Fz97cfhvPat7MPYnn+FrQSyIkwPGUfGOiI+XXgbjblU41p HSOWXxKd2M7TNOtV/PbAcLKMG/QYLAZjG2ALccnFDnjE2n1MsuJSa3dgfyHRR0s8CZnq ZCDm9Ir9ky14KueM40S0CRxHwD/upKkhx2Hrwk5ySvmGyUQXBUEL+/eAZsENN2rfuHQP d5QycqsD7wv8V3G1VYfeB6hb1jd4oVJ9Ho+nE++v5eXLNxFMGxjwfXhaBDVCwSxve5gv IsV9nTM26B3OXi838cBMdWIBE0BK7LQLfjA0nOJ359roo3vk5Y5HJYVQe8MQGFbXjiDb dKDQ== 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=Ziz7e+DuQW5OzWKEaQJB7pzZN+f4K4PSGqq9AvqpPMA=; b=fkRwEWipaJcJ7NKnpYHNf0FSwPrjQMofPKrCE8p0ZjdM6X6GedoD/DHVtD9G2yNQfi 1C9X95pFHLRHMjb+IY++UQt+8h+3IyF2Ds9lrQGPVzWqX1G4Er76JFHIys11eZLWzdLh uAzOKv3VfiZ4JS68QEyfU46jubeMGUJdMyp552a2J9UJcnQcyd4oRBKl2lRPm66hn22T UENKYS7nOfMTX5azHXxAj4/jeMKsSmPqEealbad647wT8m+UACRQRtMp/MLljYVPlkTC 1p7un54gRGt+1aHcn+ZQ7pARdEV8Ojn1IJuIUvEJgUd6biS5GF3F8PGPew0YM5q4kryQ fNaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r+yIfuhn; 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 j6si5399533ils.161.2021.07.04.13.30.14; Sun, 04 Jul 2021 13:30: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=r+yIfuhn; 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 S229757AbhGDUcL (ORCPT + 99 others); Sun, 4 Jul 2021 16:32:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:37428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbhGDUcA (ORCPT ); Sun, 4 Jul 2021 16:32:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 97DF9613F1; Sun, 4 Jul 2021 20:29:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625430565; bh=vuDWSd1GEIV5ugXAqkDxSRnynfu4GedxOVsgR/rkskU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+yIfuhn3cWLLR8YFI5pHtJC3C7PigHa5BITa6bkXa6mw9LyP7qoVhyfFAPwj2GCg uO9w16ujAkjnqjP4IXc/yAi5M22f2Cljhpo5TiIL3LlBG15et3WcumpFwJI0MAR1DE QrfhIzL9yQWYEADST2x+IbDi4kkM9l13qZ97PcEp3YevwfQlrwEFuV6WFzoYBGtEed FYFzKKAS9e9brry1/GRCbbMy0Gz0IN1kOHfrpmswFRhvJmSntGX4kmsqM9+BxScTbZ 1hjOVUWL3Psouj1ia0h39kcLV46CssrDMRQ/I3UgTOB82ejTBbvl3gMNnWnMNAGo9C gC6B/hRI2+2gg== 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 , Boqun Feng , Sumera Priyadarsini , Michael Ellerman , Sven Van Asbroeck , Gary Guo , Boris-Chengbiao Zhou , Fox Chen , Ayaan Zaidi , Douglas Su , Yuki Okushi Subject: [PATCH 11/17] rust: export generated symbols Date: Sun, 4 Jul 2021 22:27:50 +0200 Message-Id: <20210704202756.29107-12-ojeda@kernel.org> In-Reply-To: <20210704202756.29107-1-ojeda@kernel.org> References: <20210704202756.29107-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 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: 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 Co-developed-by: Boqun Feng Signed-off-by: Boqun Feng Co-developed-by: Sumera Priyadarsini Signed-off-by: Sumera Priyadarsini Co-developed-by: Michael Ellerman Signed-off-by: Michael Ellerman Co-developed-by: Sven Van Asbroeck Signed-off-by: Sven Van Asbroeck Co-developed-by: Gary Guo Signed-off-by: Gary Guo Co-developed-by: Boris-Chengbiao Zhou Signed-off-by: Boris-Chengbiao Zhou Co-developed-by: Fox Chen Signed-off-by: Fox Chen Co-developed-by: Ayaan Zaidi Signed-off-by: Ayaan Zaidi Co-developed-by: Douglas Su Signed-off-by: Douglas Su Co-developed-by: Yuki Okushi Signed-off-by: Yuki Okushi Signed-off-by: Miguel Ojeda --- rust/exports.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rust/exports.c diff --git a/rust/exports.c b/rust/exports.c new file mode 100644 index 00000000000..d7dff1b3b91 --- /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.32.0