From 5a9184fdd52e39f87a6d8fe62eaa2ffe47c5dedb Mon Sep 17 00:00:00 2001 From: Trung Nguyen <57174311+trungnt2910@users.noreply.github.com> Date: Mon, 27 Apr 2026 12:06:32 +1000 Subject: [PATCH] Haiku: Remove redundant PIC/PIE flags Haiku toolchains already pass `-pic` and link everything as shared objects (`-shared`). `-pic` is therefore redundant. `-pie` may also cause additional problems when passed to the linker along with `-shared`. --- eng/native/configureplatform.cmake | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/eng/native/configureplatform.cmake b/eng/native/configureplatform.cmake index db3a2a2f065ee5..1bb79051d5b448 100644 --- a/eng/native/configureplatform.cmake +++ b/eng/native/configureplatform.cmake @@ -492,13 +492,10 @@ endif() if(NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) # The default linker on Solaris also does not support PIE. - if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_APPLE AND NOT MSVC) + # Haiku toolchains already set -pic and link everything as shared objects (-shared). -pie will clash with -shared. + if(NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_SUNOS AND NOT CLR_CMAKE_TARGET_HAIKU AND NOT CLR_CMAKE_TARGET_APPLE AND NOT MSVC) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie") - if(CLR_CMAKE_TARGET_HAIKU) - add_compile_options($<$,EXECUTABLE>:-fPIC>) - else() - add_compile_options($<$,EXECUTABLE>:-fPIE>) - endif() + add_compile_options($<$,EXECUTABLE>:-fPIE>) add_compile_options($<$,SHARED_LIBRARY>:-fPIC>) endif()