Skip to content

Commit

Permalink
Merge pull request #9935 from dnakamura/fortify_source
Browse files Browse the repository at this point in the history
CMake: update handling of _FORTIFY_SOURCE
  • Loading branch information
keithc-ca committed Jun 19, 2020
2 parents 2e7f7b7 + 6c7d4a3 commit dcc7a68
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions runtime/cmake/platform/toolcfg/gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ if(NOT OMR_OS_OSX)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,defs ${CMAKE_SHARED_LINKER_FLAGS}")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1")
# add -U_FORTIFY_SOURCE and -D_FORTIFY_SOURCE=1
omr_append_flags(CMAKE_C_FLAGS ${OMR_STRNCPY_FORTIFY_OPTIONS})
omr_append_flags(CMAKE_CXX_FLAGS ${OMR_STRNCPY_FORTIFY_OPTIONS})
10 changes: 8 additions & 2 deletions runtime/ddr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ target_include_directories(j9ddr_misc

# remove all optimization options so needed debugging information is not suppressed
omr_remove_flags(CMAKE_CXX_FLAGS -O -O1 -O2 -O3 /Ox)
omr_remove_flags(CMAKE_C_FLAGS -O -O1 -O2 -O3 /Ox)

if((OMR_TOOLCONFIG STREQUAL "gnu") AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang))
target_compile_options(j9ddr_misc PRIVATE -femit-class-debug-always)
if(OMR_TOOLCONFIG STREQUAL "gnu")
# defining _FORTIFY_SOURCE is invalid when optimizations are disabled
omr_remove_flags(CMAKE_C_FLAGS ${OMR_STRNCPY_FORTIFY_OPTIONS})
omr_remove_flags(CMAKE_CXX_FLAGS ${OMR_STRNCPY_FORTIFY_OPTIONS})
if(NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
target_compile_options(j9ddr_misc PRIVATE -femit-class-debug-always)
endif()
endif()


Expand Down

0 comments on commit dcc7a68

Please sign in to comment.