Skip to content
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

Fix warnings on CXX/linker flags #211

Open
wants to merge 1 commit into
base: amd-staging
Choose a base branch
from
Open
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
16 changes: 11 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ set(CMAKE_CXX_FLAGS

# Clang does not set the build-id
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--build-id=sha1")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--build-id=sha1")
endif()

# Use this instead of above for 32 bit
Expand Down Expand Up @@ -129,10 +129,16 @@ else ()
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -DFORTIFY_SOURCE=2 -fstack-protector-all -Wcast-align")
## More security breach mitigation flags
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wl,-z,noexecstack -Wl,-znoexecheap -Wl,-z,relro ")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wtrampolines -Wl,-z,now")
set(HARDENING_LDFLAGS
"${HARDENING_LDFLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${HARDENING_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${HARDENING_LDFLAGS}")

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Wtrampolines" CXX_SUPPORTS_WTRAMPOLINES)
if (CXX_SUPPORTS_WTRAMPOLINES)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wtrampolines")
endif ()
endif ()

set(COMMON_SRC_DIR "${PROJECT_SOURCE_DIR}/src")
Expand Down
Loading