Skip to content

Commit adfdb1b

Browse files
authored
Do not pass C++-only flag to C compiler [NFC] (#7382)
And some minor drive-by fixes: gitignore Ninja in-tree build file, update mimalloc to latest stable release. This gets rid of warnings in the mimalloc cmake/make step. See microsoft/mimalloc#1031 (comment) and microsoft/mimalloc#1038.
1 parent 087c613 commit adfdb1b

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CMakeFiles
1919
/*.ninja
2020
/.ninja_deps
2121
/.ninja_log
22+
/.ninja_log.last_upload
2223
/bin/
2324
/lib/
2425
/_deps/

CMakeLists.txt

+9-4
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,14 @@ find_package(Threads REQUIRED)
114114

115115
function(add_compile_flag value)
116116
message(STATUS "Building with ${value}")
117-
foreach(variable CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
118-
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
119-
endforeach(variable)
117+
# You can use the optional second argument to suppress passing C++-only flags to the C compiler.
118+
if(ARGV1 STREQUAL "CXX_ONLY")
119+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${value}" PARENT_SCOPE)
120+
else()
121+
foreach(variable CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
122+
set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
123+
endforeach(variable)
124+
endif()
120125
endfunction()
121126

122127
function(add_debug_compile_flag value)
@@ -269,7 +274,7 @@ else() # MSVC
269274
add_compile_flag("-fno-omit-frame-pointer")
270275
if(NOT BUILD_FUZZTEST)
271276
# fuzztest depends on RTTIs.
272-
add_compile_flag("-fno-rtti")
277+
add_compile_flag("-fno-rtti" "CXX_ONLY")
273278
endif()
274279
if(WIN32)
275280
add_compile_flag("-D_GNU_SOURCE")

third_party/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ if(BUILD_LLVM_DWARF)
1717
endif()
1818

1919
if(MIMALLOC_STATIC)
20-
# Using a C++ compiler avoids warnings about -fno-rtti with a C compiler.
21-
set(MI_USE_CXX ON)
2220
# We only need the static library, nothing else.
2321
set(MI_BUILD_STATIC ON)
2422
set(MI_BUILD_SHARED OFF)

third_party/mimalloc

Submodule mimalloc updated 1 file

0 commit comments

Comments
 (0)