Skip to content

Commit

Permalink
Enabled position independent executable for generic GCC/Clang
Browse files Browse the repository at this point in the history
This affects mostly Linux (and probably MinGW) as default toolchains for Windows and macOS have the corresponding option turned on by default
  • Loading branch information
alexey-lysiuk committed Dec 29, 2017
1 parent b841519 commit 25d53ec
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Expand Up @@ -234,6 +234,12 @@ else()
if( APPLE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
set( ALL_C_FLAGS "-static-libgcc" )
endif()

if( NOT APPLE )
# Generic GCC/Clang requires position independent executable to be enabled explicitly
set( ALL_C_FLAGS "${ALL_C_FLAGS} -fPIE" )
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie" )
endif()
endif()

set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${REL_LINKER_FLAGS}" )
Expand Down
2 changes: 1 addition & 1 deletion src/m_fixed.h
Expand Up @@ -7,7 +7,7 @@
// Unfortunately, the Scale function still gets badly handled on 32 bit x86 platforms so it's the last remaining piece of inline assembly

// GCC inlines
#if defined(__GNUC__) && defined(__i386__) && !defined(__clang__)
#if defined(__GNUC__) && defined(__i386__) && !defined(__clang__) && !defined(__PIC__)
#ifndef alloca
// MinGW does not seem to come with alloca defined.
#define alloca __builtin_alloca
Expand Down

0 comments on commit 25d53ec

Please sign in to comment.