Skip to content

Commit 72ce8a9

Browse files
committed
[ARM][Compiler-RT] Add optional exclusion of libc provided ARM AEABI builtins from compiler-rt.
This patch introduces a new optional CMake flag: COMPILER_RT_EXCLUDE_LIBC_PROVIDED_ARM_AEABI_BUILTINS When enabled, this flag excludes the following ARM AEABI memory function implementations from the compiler-rt build: __aeabi_memset __aeabi_memcpy __aeabi_memmove These functions are already provided by standard C libraries like glibc, newlib, and picolibc, so excluding them avoids duplicate symbol definitions and reduces unnecessary code duplication. Note: __aeabi_memcmp and other AEABI functions are not excluded, as they are not defined in all standard libraries. This change is useful for environments where libc provides runtime routines, supporting more minimal, conflict free builds.
1 parent 6951d5d commit 72ce8a9

File tree

1 file changed

+42
-19
lines changed

1 file changed

+42
-19
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ set(GENERIC_TF_SOURCES
230230
option(COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
231231
"Skip the atomic builtin (these should normally be provided by a shared library)"
232232
On)
233+
option(COMPILER_RT_EXCLUDE_LIBC_PROVIDED_ARM_AEABI_BUILTINS
234+
"Skip the standard C library provided arm aeabi builtins from compiler-rt)"
235+
Off)
233236

234237
if(NOT FUCHSIA AND NOT COMPILER_RT_BAREMETAL_BUILD AND NOT COMPILER_RT_GPU_BUILD)
235238
set(GENERIC_SOURCES
@@ -450,25 +453,45 @@ set(thumb1_base_SOURCES
450453
${GENERIC_SOURCES}
451454
)
452455

453-
set(arm_EABI_SOURCES
454-
arm/aeabi_cdcmp.S
455-
arm/aeabi_cdcmpeq_check_nan.c
456-
arm/aeabi_cfcmp.S
457-
arm/aeabi_cfcmpeq_check_nan.c
458-
arm/aeabi_dcmp.S
459-
arm/aeabi_div0.c
460-
arm/aeabi_drsub.c
461-
arm/aeabi_fcmp.S
462-
arm/aeabi_frsub.c
463-
arm/aeabi_idivmod.S
464-
arm/aeabi_ldivmod.S
465-
arm/aeabi_memcmp.S
466-
arm/aeabi_memcpy.S
467-
arm/aeabi_memmove.S
468-
arm/aeabi_memset.S
469-
arm/aeabi_uidivmod.S
470-
arm/aeabi_uldivmod.S
471-
)
456+
if(NOT COMPILER_RT_EXCLUDE_LIBC_PROVIDED_ARM_AEABI_BUILTINS)
457+
set(arm_EABI_SOURCES
458+
arm/aeabi_cdcmp.S
459+
arm/aeabi_cdcmpeq_check_nan.c
460+
arm/aeabi_cfcmp.S
461+
arm/aeabi_cfcmpeq_check_nan.c
462+
arm/aeabi_dcmp.S
463+
arm/aeabi_div0.c
464+
arm/aeabi_drsub.c
465+
arm/aeabi_fcmp.S
466+
arm/aeabi_frsub.c
467+
arm/aeabi_idivmod.S
468+
arm/aeabi_ldivmod.S
469+
arm/aeabi_memcmp.S
470+
arm/aeabi_memcpy.S
471+
arm/aeabi_memmove.S
472+
arm/aeabi_memset.S
473+
arm/aeabi_uidivmod.S
474+
arm/aeabi_uldivmod.S
475+
)
476+
else()
477+
message(STATUS "COMPILER_RT_EXCLUDE_LIBC_PROVIDED_ARM_AEABI_BUILTINS is ON, so skipping __aeabi_memcpy, __aeabi_memmove and __aeabi_memset Sources")
478+
set(arm_EABI_SOURCES
479+
arm/aeabi_cdcmp.S
480+
arm/aeabi_cdcmpeq_check_nan.c
481+
arm/aeabi_cfcmp.S
482+
arm/aeabi_cfcmpeq_check_nan.c
483+
arm/aeabi_dcmp.S
484+
arm/aeabi_div0.c
485+
arm/aeabi_drsub.c
486+
arm/aeabi_fcmp.S
487+
arm/aeabi_frsub.c
488+
arm/aeabi_idivmod.S
489+
arm/aeabi_ldivmod.S
490+
arm/aeabi_memcmp.S
491+
arm/aeabi_uidivmod.S
492+
arm/aeabi_uldivmod.S
493+
)
494+
endif()
472495

473496
set(arm_Thumb1_JT_SOURCES
474497
arm/switch16.S

0 commit comments

Comments
 (0)