From 2aec7fc16389a21254611993d24c95d59b4e3507 Mon Sep 17 00:00:00 2001 From: Yogesh Tyagi Date: Wed, 10 Sep 2025 21:33:46 +0800 Subject: [PATCH] CMakeLists: fix build failure by removing -pie from shared library targets With CMake 4.1.0 the build of libipmctl started failing with: error: undefined reference to `main` in *.S - `-pie` is only valid when linking executables (PIE), not shared libraries. - When applied to a shared library, the linker expects a `main` symbol, causing the undefined reference error. - Remove `-pie` from shared libraries linker flag Signed-off-by: Yogesh Tyagi --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fa9358c..ac5cfc5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -156,7 +156,7 @@ endif() if(UNIX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_MSABI_VA_FUNCS -std=c99 -Wformat -Wformat-security -D_XOPEN_SOURCE=500 -Wall -Wfatal-errors -MMD -fPIC -fno-strict-aliasing") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wformat -Wformat-security -D_XOPEN_SOURCE=500 -Drestrict=__restrict__ -Wall -Wfatal-errors -MMD -fPIC -fno-strict-aliasing") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now -pie") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -z noexecstack -z relro -z now") elseif(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS /DynamicBase /sdl") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS /DynamicBase /sdl") @@ -791,4 +791,4 @@ if(ESX_BUILD) include(CMake/esx.cmake) endif() -add_subdirectory(src/os/nvm_api_sample) \ No newline at end of file +add_subdirectory(src/os/nvm_api_sample)