Skip to content

[Libomptarget] Pass '-Werror=global-constructors' to the libomptarget build #88531

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 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions offload/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ include(LibomptargetGetDependencies)
# Set up testing infrastructure.
include(OpenMPTesting)

check_cxx_compiler_flag(-Werror=global-constructors OFFLOAD_HAVE_WERROR_CTOR)

# LLVM source tree is required at build time for libomptarget
if (NOT LIBOMPTARGET_LLVM_INCLUDE_DIRS)
message(FATAL_ERROR "Missing definition for LIBOMPTARGET_LLVM_INCLUDE_DIRS")
Expand Down Expand Up @@ -207,6 +209,9 @@ set(offload_compile_flags -fno-exceptions)
if(NOT LLVM_ENABLE_RTTI)
set(offload_compile_flags ${offload_compile_flags} -fno-rtti)
endif()
if(OFFLOAD_HAVE_WERROR_CTOR)
list(APPEND offload_compile_flags -Werror=global-constructors)
endif()

# TODO: Consider enabling LTO by default if supported.
# https://cmake.org/cmake/help/latest/module/CheckIPOSupported.html can be used
Expand Down
4 changes: 2 additions & 2 deletions offload/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ foreach(plugin IN LISTS LIBOMPTARGET_PLUGINS_TO_BUILD)
target_link_libraries(omptarget PRIVATE omptarget.rtl.${plugin})
endforeach()

target_compile_options(omptarget PUBLIC ${offload_compile_flags})
target_link_options(omptarget PUBLIC ${offload_link_flags})
target_compile_options(omptarget PRIVATE ${offload_compile_flags})
target_link_options(omptarget PRIVATE ${offload_link_flags})

# libomptarget.so needs to be aware of where the plugins live as they
# are now separated in the build directory.
Expand Down
Loading