From b08318b9c03e70f8a3c97f6cd4ba46bcf4ef221d Mon Sep 17 00:00:00 2001 From: Wenyong Huang Date: Thu, 8 Dec 2022 15:39:55 +0800 Subject: [PATCH] Fix link cpp object file error (#1791) Error was reported when building docker image: /usr/bin/ld: libaotclib.a(aot_llvm_extra.cpp.o): relocation R_X86_64_32S against symbol `_ZN4llvm30TargetTransformInfoWrapperPass2IDE' can not be used when making a PIE object; recompile with -fPIC Add `-fPIC` to `CMAKE_CXX_FLAGS` and `CMAKE_SHARED_LIBRARY_LINK_C_FLAGS` to fix it. --- build-scripts/config_common.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 6b7c0cd78..008d7f47c 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -57,7 +57,9 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8) if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows") # Add -fPIC flag if build as 64-bit set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC") + set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -fPIC") endif () else () include(CheckCCompilerFlag)