Skip to contentSkip to conversation

arch: um: rust: Use the generated target.json again

PATCH In review David Gow 4 participants 4 messages May 29, 2024 – Jun 13, 2024

Subsystems (3)
lore
Share & tools
lore

David Gow

author
#0 lore raw

PATCH 1/1 arch: um: rust: Use the generated target.json again

The Rust compiler can take a target config from 'target.json', which is generated by scripts/generate_rust_target.rs. It used to be that all Linux architectures used this to generate a target.json, but now architectures must opt-in to this, or they will default to the Rust compiler's built-in target definition.

This is mostly okay for (64-bit) x86 and UML, except that it can generate SSE instructions, which we can't use in the kernel. So re-instate the custom target.json, which disables SSE (and generally enables the 'soft-float' feature). This fixes the following compile error:

error: <unknown>:0:0: in function _RNvMNtCs5QSdWC790r4_4core3f32f7next_up float (float): SSE register return with SSE disabled

Fixes f82811e22b48 ("rust: Refactor the build target to allow the use of builtin targets")
---
 arch/x86/Makefile.um | 1 +
 1 file changed, 1 insertion(+)
arch/x86/Makefile.um +1 -0
index 2106a2bd152b..a46b1397ad01 100644
@@ -9,6 +9,7 @@ core-y += arch/x86/crypto/
 #
 ifeq ($(CONFIG_CC_IS_CLANG),y)
 KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
+KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
 KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
 endif
 
Signature · 1 line
2.45.1.288.g0e0cd299f1-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · David Gow

The Rust compiler can take a target config from 'target.json', which is generated by scripts/generate_rust_target.rs. It used to be that all Linux architectures used this to generate a target.json, but now architectures must opt-in to this, or they will default to the Rust compiler's built-in target definition.

This is mostly okay for (64-bit) x86 and UML, except that it can generate SSE instructions, which we can't use in the kernel. So re-instate the custom target.json, which disables SSE (and generally enables the 'soft-float' feature). This fixes the following compile error:

Quoted 4 lines

error: <unknown>:0:0: in function _RNvMNtCs5QSdWC790r4_4core3f32f7next_up float (float): SSE register return with SSE disabled

Fixes f82811e22b48 ("rust: Refactor the build target to allow the use of builtin targets")

Regards,
Boqun

Quoted 19 lines
---
 arch/x86/Makefile.um | 1 +
 1 file changed, 1 insertion(+)
arch/x86/Makefile.um +1 -0
index 2106a2bd152b..a46b1397ad01 100644
@@ -9,6 +9,7 @@ core-y += arch/x86/crypto/
 #
 ifeq ($(CONFIG_CC_IS_CLANG),y)
 KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
+KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
 KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
 endif
 
Signature · 1 line
2.45.1.288.g0e0cd299f1-goog
Tested-by Reviewed-by on v1 1/1
#2 lore raw
In reply to David Gow
Quoted 13 lines · David Gow

The Rust compiler can take a target config from 'target.json', which is generated by scripts/generate_rust_target.rs. It used to be that all Linux architectures used this to generate a target.json, but now architectures must opt-in to this, or they will default to the Rust compiler's built-in target definition.

This is mostly okay for (64-bit) x86 and UML, except that it can generate SSE instructions, which we can't use in the kernel. So re-instate the custom target.json, which disables SSE (and generally enables the 'soft-float' feature). This fixes the following compile error:

Quoted 4 lines

error: <unknown>:0:0: in function _RNvMNtCs5QSdWC790r4_4core3f32f7next_up float (float): SSE register return with SSE disabled

Fixes f82811e22b48 ("rust: Refactor the build target to allow the use of builtin targets")

I guess this should go through UML, but please let me know otherwise (I don't see it in next).

Should this have a

too?

Thanks!

Cheers,
Miguel

#3 lore raw

----- Ursprüngliche Mail -----

Quoted 6 lines

Von: "Miguel Ojeda" <[email protected]>

Quoted 3 lines
Fixes f82811e22b48 ("rust: Refactor the build target to allow the use of

builtin targets")

I guess this should go through UML, but please let me know otherwise

Yeah, that's the plan.

Quoted 8 lines

Should this have a

too?

Ok!

Thanks,
//richard