Skip to content

Commit

Permalink
rtai_math.ko and musl: Switch from gnu89/C99 to GNU11
Browse files Browse the repository at this point in the history
The RTAI math kernel module (rtai_math.ko) was originally
built with gnu89, with musl itself being built with C99.
This is because musl is built outside of Kbuild
(therefore not a kernel module) and then is linked to
rtai_math.ko as the final step.

musl's libm libary provides the nitty gritty of math functions
which are used and exported by rtai_math.ko so it can be used
by external projects such as LinuxCNC.

This commit forces both the RTAI math module (rtai_math.ko)
and musl itself to pure GNU11.

With this, no modification to LinuxCNC is required. LinuxCNC
uses `rtai-config --module-cflags` to capture the appropriate
compiler flags to pass to it's Kbuild system (what builds the
LinuxCNC kernel modules.) The `--module-cflags` option
represents RTAI_FP_CFLAGS.

Signed-off-by: Alec Ari <neotheuser@ymail.com>
  • Loading branch information
NTULINUX committed Sep 20, 2023
1 parent ca6d63e commit a649bbb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ RTAI_KBUILD_DISTCLEAN=""

dnl Extra options to be passed to the compiler
RTAI_USER_CFLAGS="-O2 -march=x86-64 -fomit-frame-pointer -pipe"
RTAI_FP_CFLAGS="${RTAI_USER_CFLAGS} -D__IN_RTAI__ -mcmodel=kernel -nostdinc -ffreestanding -fno-pic -fno-builtin -fno-common -fno-unwind-tables -fno-asynchronous-unwind-tables -frounding-math -mpreferred-stack-boundary=4 -mstackrealign -mfpmath=sse -msse -msse2"
RTAI_FP_CFLAGS="${RTAI_USER_CFLAGS} -D__IN_RTAI__ -mcmodel=kernel -std=gnu11 -nostdinc -ffreestanding -fno-pic -fno-builtin -fno-common -fno-unwind-tables -fno-asynchronous-unwind-tables -frounding-math -mpreferred-stack-boundary=4 -mstackrealign -mfpmath=sse -msse -msse2"

AC_SUBST(RTAI_TARGET_SUBARCH)
AC_SUBST(RTAI_BUILTIN_MODLIST)
Expand Down
2 changes: 1 addition & 1 deletion src/math/Makefile.kbuild
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ EXTRA_CFLAGS += -I$(rtai_srctree)/include \
$(rtai_extradef) \
-D__IN_RTAI__ \
-D_IEEE_LIBM \
-D_ISOC99_SOURCE \
-D_ISOC11_SOURCE \
-D_DEFAULT_SOURCE

obj-m += rtai_math.o
Expand Down
2 changes: 1 addition & 1 deletion src/math/musl/GNUmakefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BASE_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(BASE_SRCS)))
ALL_OBJS = $(addprefix obj/, $(sort $(BASE_OBJS)))
LIBM_OBJS = $(filter obj/%,$(ALL_OBJS))

CFLAGS = @RTAI_FP_CFLAGS@ -std=c99 -pedantic
CFLAGS = @RTAI_FP_CFLAGS@ -pedantic
CFLAGS += -ffunction-sections -fdata-sections -Iobj/include -I$(srcdir)/include
CFLAGS += -D_XOPEN_SOURCE=700 -Wa,--noexecstack -Wall -Werror
CFLAGS += -Wno-parentheses -Wno-unused-but-set-variable -Wno-maybe-uninitialized
Expand Down

0 comments on commit a649bbb

Please sign in to comment.