Skip to content

Commit d178340

Browse files
authored
[ARM][Compiler-RT] Add optional exclusion of libc provided ARM AEABI builtins from compiler-rt. (#137952)
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_memcmp __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: - libgcc does not define the __aeabi_* functions that overlap with those provided by the C library. Enabling this option makes compiler-rt behave consistently with libgcc. - This prevents duplicate symbol errors when linking, particularly in bare-metal configurations where compiler-rt is linked first. - This flag is OFF by default, meaning all AEABI memory builtins will still be built unless explicitly excluded. This change is useful for environments where libc provides runtime routines, supporting more minimal, conflict free builds.
1 parent 52b345d commit d178340

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

+21-3
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,7 +453,7 @@ set(thumb1_base_SOURCES
450453
${GENERIC_SOURCES}
451454
)
452455

453-
set(arm_EABI_SOURCES
456+
set(arm_EABI_RT_SOURCES
454457
arm/aeabi_cdcmp.S
455458
arm/aeabi_cdcmpeq_check_nan.c
456459
arm/aeabi_cfcmp.S
@@ -462,14 +465,29 @@ set(arm_EABI_SOURCES
462465
arm/aeabi_frsub.c
463466
arm/aeabi_idivmod.S
464467
arm/aeabi_ldivmod.S
468+
arm/aeabi_uidivmod.S
469+
arm/aeabi_uldivmod.S
470+
)
471+
472+
set(arm_EABI_CLIB_SOURCES
465473
arm/aeabi_memcmp.S
466474
arm/aeabi_memcpy.S
467475
arm/aeabi_memmove.S
468476
arm/aeabi_memset.S
469-
arm/aeabi_uidivmod.S
470-
arm/aeabi_uldivmod.S
471477
)
472478

479+
if(NOT COMPILER_RT_EXCLUDE_LIBC_PROVIDED_ARM_AEABI_BUILTINS)
480+
set(arm_EABI_SOURCES
481+
${arm_EABI_RT_SOURCES}
482+
${arm_EABI_CLIB_SOURCES}
483+
)
484+
else()
485+
message(STATUS "COMPILER_RT_EXCLUDE_LIBC_PROVIDED_ARM_AEABI_BUILTINS is ON, so skipping __aeabi_memcmp, __aeabi_memcpy, __aeabi_memmove and __aeabi_memset Sources")
486+
set(arm_EABI_SOURCES
487+
${arm_EABI_RT_SOURCES}
488+
)
489+
endif()
490+
473491
set(arm_Thumb1_JT_SOURCES
474492
arm/switch16.S
475493
arm/switch32.S

0 commit comments

Comments
 (0)