Skip to content

Commit dcdb4a3

Browse files
[libc][cmake] append per obj compile options instead of prepending (llvm#77126)
This allows individual object files to override the common compile commands in their local CMakeLists' add_object_library call. For example, the common compile commands contain -Wall and -Wextra. Before this patch, the per object COMPILE_OPTIONS were prepended to these, so that builds of individual object files could not individually disable specific diagnostics from those groups explicitly. After this patch, the per-object file compile objects are appended to the list of compiler flags, enabling this use case. ARGN is a bit of cmake magic; let's be explicit in the APPEND that we're appending the compile options. Link: llvm#77007
1 parent 365fbbf commit dcdb4a3

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

libc/cmake/modules/LLVMLibCObjectRules.cmake

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function(_get_common_compile_options output_var flags)
2626
set(ADD_PREFER_GENERIC_FLAG TRUE)
2727
endif()
2828

29-
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${ARGN})
29+
set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT})
3030
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
3131
list(APPEND compile_options "-fpie")
3232

@@ -357,11 +357,8 @@ function(create_object_library fq_target_name)
357357
set(internal_target_name ${fq_target_name})
358358
endif()
359359

360-
_get_common_compile_options(
361-
compile_options
362-
"${ADD_OBJECT_FLAGS}"
363-
${ADD_OBJECT_COMPILE_OPTIONS}
364-
)
360+
_get_common_compile_options(compile_options "${ADD_OBJECT_FLAGS}")
361+
list(APPEND compile_options ${ADD_OBJECT_COMPILE_OPTIONS})
365362

366363
# GPU builds require special handling for the objects because we want to
367364
# export several different targets at once, e.g. for both Nvidia and AMD.
@@ -640,11 +637,8 @@ function(create_entrypoint_object fq_target_name)
640637
set(ADD_ENTRYPOINT_OBJ_CXX_STANDARD ${CMAKE_CXX_STANDARD})
641638
endif()
642639

643-
_get_common_compile_options(
644-
common_compile_options
645-
"${ADD_ENTRYPOINT_OBJ_FLAGS}"
646-
${ADD_ENTRYPOINT_OBJ_COMPILE_OPTIONS}
647-
)
640+
_get_common_compile_options(common_compile_options "${ADD_ENTRYPOINT_OBJ_FLAGS}")
641+
list(APPEND common_compile_options ${ADD_ENTRYPOINT_OBJ_COMPILE_OPTIONS})
648642
get_fq_deps_list(fq_deps_list ${ADD_ENTRYPOINT_OBJ_DEPENDS})
649643
set(full_deps_list ${fq_deps_list} libc.src.__support.common)
650644

0 commit comments

Comments
 (0)