ipmctl: fix build issue undefined reference to main

- `-pie` is only valid when linking executables (PIE), not shared
  libraries. So remove `-pie` from shared libraries linker flag.

Signed-off-by: Yogesh Tyagi <yogesh.tyagi@intel.com>
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
This commit is contained in:
Yogesh Tyagi 2025-09-12 10:48:16 +08:00 committed by Anuj Mittal
parent f7ba543caa
commit 2740652fdb
No known key found for this signature in database
GPG Key ID: B749E1556041E1B2
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,39 @@
From 5b8b59a18f4a54ba912faad861f0af3fdcf127c6 Mon Sep 17 00:00:00 2001
From: Yogesh Tyagi <yogesh.tyagi@intel.com>
Date: Wed, 10 Sep 2025 21:15:53 +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
Upstream-Status: Submitted [https://github.com/intel/ipmctl/pull/221]
Signed-off-by: Yogesh Tyagi <yogesh.tyagi@intel.com>
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c07e682..d7aab78f 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")
--
2.37.3

View File

@ -19,6 +19,7 @@ SRC_URI = "git://github.com/intel/ipmctl.git;protocol=https;branch=master_3_0;na
git://github.com/tianocore/edk2.git;protocol=https;name=edk2;destsuffix=${BB_GIT_DEFAULT_DESTSUFFIX}/edk2;branch=master \
file://0001-Ignore-STATIC_ASSERTs-and-NULL-define-for-os-and-ut-builds.patch;patchdir=edk2 \
file://0001-CMakeLists-disable-Werror.patch \
file://0001-CMakeLists-fix-build-failure-by-removing-pie-from-sh.patch \
"
SRCREV_ipmctl = "a71f2fb1c90dd07f9862b71c789881132193e8f9"