Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cpu/native/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,22 @@ ifeq ($(USE_LIBUCONTEXT),1)
CFLAGS += $(pkg-config libucontext --cflags) -DUSE_LIBUCONTEXT=1
LINKFLAGS += $(shell pkg-config libucontext --libs)
endif

ifeq (x86_64,$(OS_ARCH))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we also need that on 32 bit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I wonder if someone actually still has an i585/i686 CPU in use these days.

It won't hurt to add the check, though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more about testing the code on a 32 bit target which is what most of our targets are.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the output of uname -m would still be x86_64, even with BOARD=native32.

But I honestly don't really see a path forward here with including C++ headers resulting in compilation errors when SSE is disabled.

Copy link
Contributor

@benpicco benpicco Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I thought OS_ARCH was referring to RIOT 😅

# Disable use of FPU/SSE registers if FPU is not used. This prevents radom
# stack corruptions and floating point exceptions to not occur during
# context switching.
ifeq (,$(filter float_math,$(FEATURES_USED)))
# FPU/SSE registers are not reliably saved and restored in glibc's ucontext
# implementation (see https://github.com/RIOT-OS/RIOT/issues/495) and not at
# all in libucontext's (but there at least this is documented). So we force
# the compiler to only use registers known to be properly backed up and
# restored during context switching
CFLAGS += -mgeneral-regs-only

# Since we disabled the use of non-general registers (such as FPU registers),
# we need to use a soft FPU
CFLAGS += -msoft-float
LINKFLAGS += -msoft-float
endif
endif
Loading