From 5456668ae8d9f9f362a3f36302cf0a71f1c2dbae Mon Sep 17 00:00:00 2001 From: Tiago Medicci Serrano Date: Fri, 29 Nov 2024 10:55:48 -0300 Subject: [PATCH] libm/newlib: Add arch-specific source code first to CSRCS Source code under `newlib/newlib/newlib/libm/machine/$(ARCH)/*.c` should be added before common source code from `../../common/*.c`. Take `newlib/newlib/newlib/libm/machine/riscv/s_fma.c` as an example: ``` double fma (double x, double y, double z) { double result; asm ("fmadd.d %0, %1, %2, %3" : "=f" (result) : "f" (x), "f" (y), "f" (z)); return result; } ``` Note that the common `s_fma.c` will be included by the source file directly. The order of adding the files to CSRCS matters here. Although the CMake-based build system does not have the same build problem of including the a source-file with the same in the wrong order, this commit also changes the order of inclusion for CMake too to keep it consistent. --- libs/libm/newlib/CMakeLists.txt | 5 +++-- libs/libm/newlib/Make.defs | 15 +++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libs/libm/newlib/CMakeLists.txt b/libs/libm/newlib/CMakeLists.txt index 2ca2571942caf..f1707ee10f94f 100644 --- a/libs/libm/newlib/CMakeLists.txt +++ b/libs/libm/newlib/CMakeLists.txt @@ -87,11 +87,12 @@ if(CONFIG_LIBM_NEWLIB) set(ARCH_DIR ${CONFIG_ARCH}) endif() - file(GLOB_RECURSE COMMON_CSRCS ${NEWLIB_DIR}/newlib/libm/common/*.c) - file(GLOB_RECURSE COMPLEX_CSRCS ${NEWLIB_DIR}/newlib/libm/complex/*.c) file(GLOB_RECURSE ARCH_CSRCS ${NEWLIB_DIR}/newlib/libm/machine/${ARCH_DIR}/*.c) + file(GLOB_RECURSE COMMON_CSRCS ${NEWLIB_DIR}/newlib/libm/common/*.c) + file(GLOB_RECURSE COMPLEX_CSRCS ${NEWLIB_DIR}/newlib/libm/complex/*.c) + if(CONFIG_ARCH_X86_64) file(GLOB_RECURSE ARCH_CSRCS ${NEWLIB_DIR}/newlib/libm/fenv/*.c) endif() diff --git a/libs/libm/newlib/Make.defs b/libs/libm/newlib/Make.defs index 3ee1fe84e83c0..f025b05b31586 100644 --- a/libs/libm/newlib/Make.defs +++ b/libs/libm/newlib/Make.defs @@ -58,14 +58,6 @@ $(TOPDIR)/include/newlib: newlib/newlib context:: $(TOPDIR)/include/newlib -CSRCS += $(wildcard newlib/newlib/newlib/libm/common/*.c) -CSRCS += $(wildcard newlib/newlib/newlib/libm/complex/*.c) - -VPATH += :newlib/newlib/newlib/libm/common -VPATH += :newlib/newlib/newlib/libm/complex -DEPPATH += --dep-path newlib/newlib/newlib/libm/common -DEPPATH += --dep-path newlib/newlib/newlib/libm/complex - ifeq ($(CONFIG_ARCH_ARM),y) ARCH = arm else ifeq ($(CONFIG_ARCH_ARM64),y) @@ -88,6 +80,13 @@ CSRCS += $(wildcard newlib/newlib/newlib/libm/machine/$(ARCH)/*.c) VPATH += :newlib/newlib/newlib/libm/machine/$(ARCH) DEPPATH += --dep-path newlib/newlib/newlib/libm/machine/$(ARCH) +CSRCS += $(wildcard newlib/newlib/newlib/libm/common/*.c) +CSRCS += $(wildcard newlib/newlib/newlib/libm/complex/*.c) + +VPATH += :newlib/newlib/newlib/libm/common +VPATH += :newlib/newlib/newlib/libm/complex +DEPPATH += --dep-path newlib/newlib/newlib/libm/common +DEPPATH += --dep-path newlib/newlib/newlib/libm/complex ifeq ($(CONFIG_ARCH_X86_64),y) CSRCS += $(wildcard newlib/newlib/newlib/libm/fenv/*.c)