Skip to content

Commit

Permalink
CMake: Enable PIC on Linux
Browse files Browse the repository at this point in the history
Otherwise ASLR does not work. Also stops LTO builds crashing in the
middle of Qt on Fedora.
  • Loading branch information
stenzek committed Aug 24, 2024
1 parent 72fc81a commit 41fb5d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ detect_cache_line_size()
# Build options. Depends on system attributes.
include(DuckStationBuildOptions)

# Enable PIC on Linux, otherwise the builds do not support ASLR.
if(LINUX OR BSD)
include(CheckPIESupported)
check_pie_supported()
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif()

# Set _DEBUG macro for Debug builds.
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
Expand Down
2 changes: 1 addition & 1 deletion scripts/deps/build-dependencies-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ echo "Building libbacktrace..."
rm -fr "libbacktrace-$LIBBACKTRACE"
unzip "$LIBBACKTRACE.zip"
cd "libbacktrace-$LIBBACKTRACE"
./configure --prefix="$INSTALLDIR"
./configure --prefix="$INSTALLDIR" --with-pic
make
make install
cd ..
Expand Down

0 comments on commit 41fb5d3

Please sign in to comment.