[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20230627121422.112246-1-wangrui@loongson.cn>
Date: Tue, 27 Jun 2023 20:14:22 +0800
From: WANG Rui <wangrui@...ngson.cn>
To: Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Tom Rix <trix@...hat.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev, WANG Rui <wangrui@...ngson.cn>
Subject: [PATCH] rust: build: Define MODULE macro iif the CONFIG_MODULES is enabled
The LoongArch does not currently support modules when built with clang.
A pre-processor error is expected on building modules, that's caused by:
#if defined(MODULE) && defined(CONFIG_AS_HAS_EXPLICIT_RELOCS)
# if __has_attribute(model)
# define PER_CPU_ATTRIBUTES __attribute__((model("extreme")))
# else
# error compiler support for the model attribute is necessary when a recent assembler is used
# endif
#endif
This also happens with bindgen too, so it would be better to define
MODULE macro if and only if the CONFIG_MODULES is enabled.
Signed-off-by: WANG Rui <wangrui@...ngson.cn>
---
rust/Makefile | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/rust/Makefile b/rust/Makefile
index fc8cdcfcc9e5..d31d9fa27ef0 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -295,12 +295,16 @@ endif
bindgen_c_flags_final = $(bindgen_c_flags_lto) -D__BINDGEN__
+ifdef CONFIG_MODULES
+bindgen_c_flags_final += -DMODULE
+endif
+
quiet_cmd_bindgen = BINDGEN $@
cmd_bindgen = \
$(BINDGEN) $< $(bindgen_target_flags) \
--use-core --with-derive-default --ctypes-prefix core::ffi --no-layout-tests \
--no-debug '.*' \
- -o $@ -- $(bindgen_c_flags_final) -DMODULE \
+ -o $@ -- $(bindgen_c_flags_final) \
$(bindgen_target_cflags) $(bindgen_target_extra)
$(obj)/bindings/bindings_generated.rs: private bindgen_target_flags = \
--
2.41.0
Powered by blists - more mailing lists