Skip to content

[libc] Replace LLVM_COMPILER_IS_GCC_COMPATIBLE with a local check. #119164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
if(NOT DEFINED LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
if(CMAKE_COMPILER_IS_GNUCXX)
set(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE ON)
elseif( MSVC )
set(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE OFF)
elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
set(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE ON)
elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel" )
set(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE ON)
endif()
endif()

function(_get_compile_options_from_flags output_var)
set(compile_options "")

Expand All @@ -8,7 +20,7 @@ function(_get_compile_options_from_flags output_var)
check_flag(ADD_EXPLICIT_SIMD_OPT_FLAG ${EXPLICIT_SIMD_OPT_FLAG} ${ARGN})
check_flag(ADD_MISC_MATH_BASIC_OPS_OPT_FLAG ${MISC_MATH_BASIC_OPS_OPT_FLAG} ${ARGN})

if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
if(ADD_FMA_FLAG)
if(LIBC_TARGET_ARCHITECTURE_IS_X86_64)
list(APPEND compile_options "-mavx2")
Expand Down Expand Up @@ -96,7 +108,7 @@ function(_get_common_compile_options output_var flags)

set(compile_options ${LIBC_COMPILE_OPTIONS_DEFAULT} ${compile_flags} ${config_flags})

if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND compile_options "-fpie")

if(LLVM_LIBC_FULL_BUILD)
Expand Down Expand Up @@ -210,7 +222,7 @@ function(_get_common_test_compile_options output_var c_test flags)
${LIBC_TEST_COMPILE_OPTIONS_DEFAULT}
${compile_flags})

if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
if(LLVM_LIBC_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND compile_options "-fpie")

if(LLVM_LIBC_FULL_BUILD)
Expand Down
Loading