Skip to contentSkip to conversation

arch:um: Only disable SSE on clang to work around old GCC bugs

PATCH In review David Gow 5 participants 7 messages Mar 18, 2023 – Apr 4, 2023

Subsystems (3)
lore
Share & tools
lore

David Gow

author
#0 lore raw

PATCH 1/1 arch:um: Only disable SSE on clang to work around old GCC bugs

As part of the Rust support for UML, we disable SSE (and similar flags) to match the normal x86 builds. This both makes sense (we ideally want a similar configuration to x86), and works around a crash bug with SSE generation under Rust with LLVM.

However, this breaks compiling stdlib.h under gcc < 11, as the x86_64 ABI requires floating-point return values be stored in an SSE register. gcc 11 fixes this by only doing register allocation when a function is actually used, and since we never use atof(), it shouldn't be a problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652

Nevertheless, only disable SSE on clang setups, as that's a simple way of working around everyone's bugs.

Fixes 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")
---
 arch/x86/Makefile.um | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/Makefile.um +5 -0
index b70559b821df..2106a2bd152b 100644
@@ -3,9 +3,14 @@ core-y += arch/x86/crypto/
 
 #
 # Disable SSE and other FP/SIMD instructions to match normal x86
+# This is required to work around issues in older LLVM versions, but breaks
+# GCC versions < 11. See:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
 #
+ifeq ($(CONFIG_CC_IS_CLANG),y)
 KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
 KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
+endif
 
 ifeq ($(CONFIG_X86_32),y)
 START := 0x8048000
Signature · 1 line
2.40.0.rc1.284.g88254d51c5-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 45 lines

As part of the Rust support for UML, we disable SSE (and similar flags) to match the normal x86 builds. This both makes sense (we ideally want a similar configuration to x86), and works around a crash bug with SSE generation under Rust with LLVM.

However, this breaks compiling stdlib.h under gcc < 11, as the x86_64 ABI requires floating-point return values be stored in an SSE register. gcc 11 fixes this by only doing register allocation when a function is actually used, and since we never use atof(), it shouldn't be a problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652

Nevertheless, only disable SSE on clang setups, as that's a simple way of working around everyone's bugs.

Fixes 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")
---
 arch/x86/Makefile.um | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/Makefile.um +5 -0
index b70559b821df..2106a2bd152b 100644
@@ -3,9 +3,14 @@ core-y += arch/x86/crypto/
 
 #
 # Disable SSE and other FP/SIMD instructions to match normal x86
+# This is required to work around issues in older LLVM versions, but breaks
+# GCC versions < 11. See:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
 #
+ifeq ($(CONFIG_CC_IS_CLANG),y)
 KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
 KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
+endif
 
 ifeq ($(CONFIG_X86_32),y)
 START := 0x8048000
Signature · 1 line
2.40.0.rc1.284.g88254d51c5-goog
Tested-by on v1 1/1
#2 lore raw
In reply to David Gow
Quoted 33 lines · David Gow' via KUnit Development

As part of the Rust support for UML, we disable SSE (and similar flags) to match the normal x86 builds. This both makes sense (we ideally want a similar configuration to x86), and works around a crash bug with SSE generation under Rust with LLVM.

However, this breaks compiling stdlib.h under gcc < 11, as the x86_64 ABI requires floating-point return values be stored in an SSE register. gcc 11 fixes this by only doing register allocation when a function is actually used, and since we never use atof(), it shouldn't be a problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652

Nevertheless, only disable SSE on clang setups, as that's a simple way of working around everyone's bugs.

Fixes 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")
---
 arch/x86/Makefile.um | 5 +++++
 1 file changed, 5 insertions(+)
arch/x86/Makefile.um +1 -0
index b70559b821df..2106a2bd152b 100644
@@ -3,9 +3,14 @@ core-y += arch/x86/crypto/
 
 #
 # Disable SSE and other FP/SIMD instructions to match normal x86
+# This is required to work around issues in older LLVM versions, but breaks

arch/x86/Makefile.um core-y += arch/x86/crypto/ · line 16

Quoted 10 lines
arch/x86/Makefile.um +4 -0
+# GCC versions < 11. See:
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652
 #
+ifeq ($(CONFIG_CC_IS_CLANG),y)
 KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
 KBUILD_RUSTFLAGS += -Ctarget-feature=-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2
+endif
 
 ifeq ($(CONFIG_X86_32),y)
 START := 0x8048000

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author
#3 lore raw
In reply to David Gow
Quoted 15 lines · David Gow

As part of the Rust support for UML, we disable SSE (and similar flags) to match the normal x86 builds. This both makes sense (we ideally want a similar configuration to x86), and works around a crash bug with SSE generation under Rust with LLVM.

However, this breaks compiling stdlib.h under gcc < 11, as the x86_64 ABI requires floating-point return values be stored in an SSE register. gcc 11 fixes this by only doing register allocation when a function is actually used, and since we never use atof(), it shouldn't be a problem:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99652

Nevertheless, only disable SSE on clang setups, as that's a simple way of working around everyone's bugs.

Quoted 7 lines
Fixes 884981867947 ("rust: arch/um: Disable FP/SIMD instruction to match x86")

---

Any chance we could get this picked up as a fix for 6.3? The UML build is still broken with older gcc versions.

Cheers,
-- David

#4 lore raw

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

Quoted 4 lines

Von: "davidgow" <[email protected]>
An: "richard" <[email protected]>, "anton ivanov" <[email protected]>, "Johannes Berg" Any chance we could get this picked up as a fix for 6.3? The UML build
is still broken with older gcc versions.

Sure. Just got flooded with other stuff. :-S

Thanks,
//richard

#5 lore raw

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

Quoted 7 lines
Quoted 5 lines

Von: "davidgow" <[email protected]>
An: "richard" <[email protected]>, "anton ivanov" <[email protected]>, "Johannes Berg"
Any chance we could get this picked up as a fix for 6.3? The UML build is still broken with older gcc versions.

Sure. Just got flooded with other stuff. :-S

Patch applied to fixes branch. PR will happen soon.

Thanks everyone and sorry for the delay on my side!

--
Thanks,
//richard

#6 lore raw
In reply to David Gow
Quoted 3 lines · David Gow

Nevertheless, only disable SSE on clang setups, as that's a simple way of working around everyone's bugs.

Sounds good to me. If GCC >= 11 has fixed it, should we instead test for GCC < 11, i.e. it could help catching future new regressions like the linked GCC bug, if I understand correctly, right? Of course, that could be done for the next cycle, since this one minimizes the original change w.r.t. v6.2.

By the way, missing space on the title (arch:um).

Cheers,
Miguel