Skip to content

Commit

Permalink
Add -mbmi flag for Fedora with GCC version >14.
Browse files Browse the repository at this point in the history
  • Loading branch information
fruffy committed Apr 30, 2024
1 parent f32cb7c commit 2a6e1db
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmake/Abseil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ macro(p4c_obtain_abseil)
endif()
else()
set(P4C_ABSEIL_VERSION "20240116.1")
message("Fetching Abseil version ${P4C_ABSEIL_VERSION} for P4C...")
message(STATUS "Fetching Abseil version ${P4C_ABSEIL_VERSION} for P4C...")

# Unity builds do not work for Abseil...
set(CMAKE_UNITY_BUILD_PREV ${CMAKE_UNITY_BUILD})
Expand Down Expand Up @@ -53,15 +53,24 @@ macro(p4c_obtain_abseil)
# Do not suppress warnings for Abseil library targets that are aliased.
get_target_property(target_type ${target} TYPE)
if (NOT ${target_type} STREQUAL "INTERFACE_LIBRARY")
set_target_properties(${target} PROPERTIES COMPILE_FLAGS "-Wno-error -w")
# We need this workaround because of https://github.com/abseil/abseil-cpp/issues/1664.
# TODO: Remove once the Abseil compilation issue is fixed.
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
target_compile_options(${target} PUBLIC "-mbmi")
endif()
target_compile_options(${target} PRIVATE "-Wno-error" "-w")
endif()
endif()
endforeach()
# TODO: Remove once the Abseil compilation issue is fixed.
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
message(WARNING "Compiling with GCC>14. Adding -mbmi to Abseil targets.")
endif()

# Reset temporary variable modifications.
set(CMAKE_UNITY_BUILD ${CMAKE_UNITY_BUILD_PREV})
set(FETCHCONTENT_QUIET ${FETCHCONTENT_QUIET_PREV})
endif()

message("Done with setting up Abseil for P4C.")
message(STATUS "Done with setting up Abseil for P4C.")
endmacro(p4c_obtain_abseil)

0 comments on commit 2a6e1db

Please sign in to comment.