Add Intel compiler support

This commit is contained in:
goandrei 2022-06-23 09:24:34 +00:00
parent e28a8401fb
commit 06004e8b25
3 changed files with 30 additions and 11 deletions

View File

@ -12,7 +12,14 @@ function(compile_boost)
set(BOOTSTRAP_LIBRARIES "context,filesystem")
set(BOOST_CXX_COMPILER "${CMAKE_CXX_COMPILER}")
if(CLANG)
# Can't build Boost with Intel compiler, use clang instead.
if(ICX)
execute_process (
COMMAND bash -c "which clang++ | tr -d '\n'"
OUTPUT_VARIABLE BOOST_CXX_COMPILER
)
set(BOOST_TOOLSET "clang")
elseif(CLANG)
set(BOOST_TOOLSET "clang")
if(APPLE)
# this is to fix a weird macOS issue -- by default
@ -29,7 +36,7 @@ function(compile_boost)
set(B2_COMMAND "./b2")
set(BOOST_COMPILER_FLAGS -fvisibility=hidden -fPIC -std=c++17 -w)
set(BOOST_LINK_FLAGS "")
if(APPLE OR CLANG OR USE_LIBCXX)
if(APPLE OR CLANG OR ICX OR USE_LIBCXX)
list(APPEND BOOST_COMPILER_FLAGS -stdlib=libc++ -nostdlib++)
list(APPEND BOOST_LINK_FLAGS -static-libgcc -lc++ -lc++abi)
endif()

View File

@ -117,11 +117,12 @@ if(WIN32)
else()
set(GCC NO)
set(CLANG NO)
set(ICC NO)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(ICX NO)
# CMAKE_CXX_COMPILER_ID is set to Clang even if CMAKE_CXX_COMPILER points to ICPX, so we have to check the compiler too.
if (${CMAKE_CXX_COMPILER} MATCHES ".*icpx")
set(ICX YES)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
set(CLANG YES)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(ICC YES)
else()
# This is not a very good test. However, as we do not really support many architectures
# this is good enough for now
@ -276,7 +277,7 @@ else()
# for more information.
#add_compile_options(-fno-builtin-memcpy)
if (CLANG)
if (CLANG OR ICX)
add_compile_options()
if (APPLE OR USE_LIBCXX)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-stdlib=libc++>)
@ -331,9 +332,6 @@ else()
# Otherwise `state [[maybe_unused]] int x;` will issue a warning.
# https://stackoverflow.com/questions/50646334/maybe-unused-on-member-variable-gcc-warns-incorrectly-that-attribute-is
add_compile_options(-Wno-attributes)
elseif(ICC)
add_compile_options(-wd1879 -wd1011)
add_link_options(-static-intel)
endif()
add_compile_options(-Wno-error=format
-Wunused-variable
@ -341,7 +339,7 @@ else()
-fvisibility=hidden
-Wreturn-type
-fPIC)
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^x86" AND NOT CLANG)
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "^x86" AND NOT CLANG AND NOT ICX)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wclass-memaccess>)
endif()
if (GPERFTOOLS_FOUND AND GCC)
@ -351,6 +349,15 @@ else()
-fno-builtin-realloc
-fno-builtin-free)
endif()
if (ICX)
find_library(CXX_LIB NAMES c++ PATHS "/usr/local/lib" REQUIRED)
find_library(CXX_ABI_LIB NAMES c++abi PATHS "/usr/local/lib" REQUIRED)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-ffp-contract=on>)
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-ffp-contract=on>)
# No libc++ and libc++abi in Intel LIBRARY_PATH
link_libraries(${CXX_LIB} ${CXX_ABI_LIB})
endif()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
# Graviton2 or later

View File

@ -358,6 +358,11 @@ if(NOT WIN32)
target_compile_options(fdb_sqlite BEFORE PRIVATE -w) # disable warnings for third party
endif()
# SQLite won't build with -ffast-math
if(ICX)
target_compile_options(fdb_sqlite PRIVATE -fno-fast-math)
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/workloads)
add_flow_target(EXECUTABLE NAME fdbserver SRCS ${FDBSERVER_SRCS})