rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: build: Define MODULE macro iif the CONFIG_MODULES is enabled
@ 2023-06-27 12:14 WANG Rui
  0 siblings, 0 replies; only message in thread
From: WANG Rui @ 2023-06-27 12:14 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Nathan Chancellor,
	Nick Desaulniers, Tom Rix
  Cc: rust-for-linux, linux-kernel, llvm, WANG Rui

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@loongson.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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-27 12:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-27 12:14 [PATCH] rust: build: Define MODULE macro iif the CONFIG_MODULES is enabled WANG Rui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).