Skip to content

Commit

Permalink
Fix SANITIZE=ON for GCC 6
Browse files Browse the repository at this point in the history
GCC on Ubuntu does not switch to the "gold" linker when the fsanitize
switch is used, so add the relevant linker flags manually:
http://stackoverflow.com/questions/37603238/fsanitize-not-using-gold-linker-in-gcc-6-1
  • Loading branch information
nkurz committed Sep 10, 2016
1 parent 3c47edb commit d5a081a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/cmake/FindOptions.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
macro(append var string)
set(${var} "${${var}} ${string}")
endmacro(append)

set(SANITIZE_FLAGS "")
if(SANITIZE)
set(SANITIZE_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined")
if (CMAKE_COMPILER_IS_GNUCC)
# Ubuntu bug for GCC 5.0+ (safe for all versions)
append(CMAKE_EXE_LINKER_FLAGS "-fuse-ld=gold")
append(CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=gold")
endif()
endif()

set(OPT_FLAGS "-march=native")
Expand Down

0 comments on commit d5a081a

Please sign in to comment.