Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2763469pxb; Mon, 17 Jan 2022 05:22:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNhzA+OpqG4fxKEPiK/JXSEO/COPqTWVmypLZVFzLQSwH022l9qzH/ImQJwAieWhrvzBdV X-Received: by 2002:a17:902:ab16:b0:14a:912d:4502 with SMTP id ik22-20020a170902ab1600b0014a912d4502mr14451435plb.93.1642425768677; Mon, 17 Jan 2022 05:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642425768; cv=none; d=google.com; s=arc-20160816; b=ChKfSoYEmL3LmR0Y/WahomDfZ70q0O39NdYblau2g7EjuWnyixfvCce0hvfJubGNNp zzIKcsD1aCjtErucngzLzXPKw3BcWr4XotxZx4Srtmwjb9PUxOokw2o7gCIlgolY31Cv 0NFnPr9mEM1kpzchuDOX0xcDl7vMHxv//DB51SG+k+GqKXQl5yb7bHCvGvOZnlceab2g 2yz7YSPzJ3fg0nWi9501PnpK8hjSjwkDCnrQYsEbnk6snWW74Y2zXTdiimcuXZQiSjJO ZCyUl/B6bBrMQ3B/oqL5USSZwVYlGwa9rtJz6eKw8ccaVtlEKmJN++zmRcggK9OaRB5k 0+qA== 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=E0M1QCNxfeCKQgqjpPTIL4ZvVohAmHgZFKz9MB68whQ=; b=LXa6yciTNcUopsVagY7uf/YCll07PUPQqJkThkKoFjNq1fY297t0MuNUKBznxiZJJg UQdM7sOfMTjV6qqrG8TNI4MkB8PQPjQNNEZLl4o94m3akCIClftvulr+WJJWenhrYGs5 I/7n4VNrXEIzHLfRaNNn6RBPhZdT9sncChu91zdqUOKbF2JUMptMzPqJyvglT5wDV/Tg nN3scRkH3groA9eCP5t3k9XqT2QPIZUBDA2hmAOLzPx2Be1xe747OY0SXt4DhFmurB3m eV2ZEvAuJ2WDCWURF9xEYWUc7YxtJkISnPnCBq0YWxWhLCKIxfJUN9Ki6knQfLxmmYtP BHEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IUn1GUnK; 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 d127si14071081pgc.97.2022.01.17.05.22.36; Mon, 17 Jan 2022 05:22:48 -0800 (PST) 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=IUn1GUnK; 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 S234336AbiAQFfA (ORCPT + 99 others); Mon, 17 Jan 2022 00:35:00 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:40836 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234302AbiAQFek (ORCPT ); Mon, 17 Jan 2022 00:34:40 -0500 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 B17AD60DFF; Mon, 17 Jan 2022 05:34:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52D02C36AED; Mon, 17 Jan 2022 05:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642397679; bh=5sO+DVq/B8LfLiCRXoo9vrGP1/bmz/YXbgCFN+RtTx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IUn1GUnKX2r0MiWblWp4CWoPAnflgTGFC12IMZvNlbd8ekmTxqUzCuw9LjWD4aXTO b3zMELQcDY1kzPEnh6FZAsP86O0nLUcta4d5lU1jPKnTMXumryAgSkYGFPQXV7mL+Y CYBRrgmSxFSzLTzJafi2GbllCYxXKokksqSwvr2npRlRi0UWS3gAuEn5i1ndj4TQ45 3Lj2rY8ZI/z9/u9/lGvH3+c0NLTdcKoeHnhNlOUdS0ErmctxpPQ+k81gnSJC0Z/zKl VFN5+dgM+zLSibErbCEf7gxl9/YWrsIa+pEwiZk/pgDaZ9eYT3J/8YUpSAu78uOzlu uI8/bXGLydEFQ== From: Miguel Ojeda 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 , Wedson Almeida Filho Subject: [PATCH v3 10/19] rust: export generated symbols Date: Mon, 17 Jan 2022 06:33:40 +0100 Message-Id: <20220117053349.6804-11-ojeda@kernel.org> In-Reply-To: <20220117053349.6804-1-ojeda@kernel.org> References: <20220117053349.6804-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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.34.1