diff --git a/CMakeLists.txt b/CMakeLists.txt index 345fd480d..5809118d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}" ) diff --git a/src/m_fixed.h b/src/m_fixed.h index b751d6b1f..8bbb2dbf9 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -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