Skip to content

Commit

Permalink
[#180] Do not link shared library parts with -pie -fPIE as it breaks LTO
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperpedersen committed Oct 18, 2021
1 parent df9d67a commit 60dfc28
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,11 @@ if (CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif()

if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
check_c_compiler_flag(-fPIE HAS_PIE)
if (HAS_PIE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pie")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
check_c_compiler_flag(-fPIE HAS_PIE)
if (HAS_PIE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
endif()
endif()

Expand Down

0 comments on commit 60dfc28

Please sign in to comment.