Force Unreal toolchain to use Unreal sysroot

Not doing this can lead to the Unreal toolchain examining the host system,
which can cause it to attempt to use glibc features newer than the Unreal
target of 2.17 provides (specifically, rpclib can accidentaly pick up the
symbol pthread_cond_clockwait, which is provided by Ubuntu 20.04 glibc 2.31
but *not* by Unreal glibc 2.17, which then causes a missing symbol linker
error when trying to build CARLA. The reason is that libc++ attempts to
detect glibc version in its headers and conditionally uses that symbol.)
This commit is contained in:
anrp 2023-06-02 05:53:05 -04:00 committed by bernat
parent c78f8eb45a
commit ba497e62f2
1 changed files with 6 additions and 5 deletions

View File

@ -57,6 +57,7 @@ pushd ${CARLA_BUILD_FOLDER} >/dev/null
LLVM_INCLUDE="$UE4_ROOT/Engine/Source/ThirdParty/Linux/LibCxx/include/c++/v1"
LLVM_LIBPATH="$UE4_ROOT/Engine/Source/ThirdParty/Linux/LibCxx/lib/Linux/x86_64-unknown-linux-gnu"
UNREAL_HOSTED_CFLAGS="--sysroot=$UE4_ROOT/Engine/Extras/ThirdPartyNotUE/SDKs/HostLinux/Linux_x64/v17_clang-10.0.1-centos7/x86_64-unknown-linux-gnu/"
# ==============================================================================
# -- Get boost includes --------------------------------------------------------
@ -173,7 +174,7 @@ else
pushd ${RPCLIB_BASENAME}-libcxx-build >/dev/null
cmake -G "Ninja" \
-DCMAKE_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++ -I${LLVM_INCLUDE} -Wl,-L${LLVM_LIBPATH} -DBOOST_NO_EXCEPTIONS -DASIO_NO_EXCEPTIONS" \
-DCMAKE_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++ -I${LLVM_INCLUDE} -Wl,-L${LLVM_LIBPATH} -DBOOST_NO_EXCEPTIONS -DASIO_NO_EXCEPTIONS ${UNREAL_HOSTED_CFLAGS}" \
-DCMAKE_INSTALL_PREFIX="../${RPCLIB_BASENAME}-libcxx-install" \
../${RPCLIB_BASENAME}-source
@ -237,7 +238,7 @@ else
pushd ${GTEST_BASENAME}-libcxx-build >/dev/null
cmake -G "Ninja" \
-DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++ -I${LLVM_INCLUDE} -Wl,-L${LLVM_LIBPATH} -DBOOST_NO_EXCEPTIONS -fno-exceptions" \
-DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++ -I${LLVM_INCLUDE} -Wl,-L${LLVM_LIBPATH} -DBOOST_NO_EXCEPTIONS -fno-exceptions ${UNREAL_HOSTED_CFLAGS}" \
-DCMAKE_INSTALL_PREFIX="../${GTEST_BASENAME}-libcxx-install" \
../${GTEST_BASENAME}-source
@ -530,7 +531,7 @@ if ${USE_CHRONO} ; then
pushd ${CHRONO_SRC_DIR}/build >/dev/null
cmake -G "Ninja" \
-DCMAKE_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++ -I${LLVM_INCLUDE} -L${LLVM_LIBPATH} -Wno-unused-command-line-argument" \
-DCMAKE_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++ -I${LLVM_INCLUDE} -L${LLVM_LIBPATH} -Wno-unused-command-line-argument ${UNREAL_HOSTED_CFLAGS}" \
-DEIGEN3_INCLUDE_DIR="../../${EIGEN_INCLUDE}" \
-DCMAKE_INSTALL_PREFIX="../../${CHRONO_INSTALL_DIR}" \
-DCMAKE_BUILD_TYPE=Release \
@ -840,9 +841,9 @@ cp ${LIBSTDCPP_TOOLCHAIN_FILE}.gen ${LIBCPP_TOOLCHAIN_FILE}.gen
cat >>${LIBCPP_TOOLCHAIN_FILE}.gen <<EOL
set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -stdlib=libc++" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -isystem ${LLVM_INCLUDE}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -isystem ${LLVM_INCLUDE} ${UNREAL_HOSTED_CFLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "\${CMAKE_CXX_FLAGS} -fno-exceptions" CACHE STRING "" FORCE)
set(CMAKE_CXX_LINK_FLAGS "\${CMAKE_CXX_LINK_FLAGS} -L${LLVM_LIBPATH}" CACHE STRING "" FORCE)
set(CMAKE_CXX_LINK_FLAGS "\${CMAKE_CXX_LINK_FLAGS} -L${LLVM_LIBPATH} ${UNREAL_HOSTED_CFLAGS}" CACHE STRING "" FORCE)
set(CMAKE_CXX_LINK_FLAGS "\${CMAKE_CXX_LINK_FLAGS} -lc++ -lc++abi" CACHE STRING "" FORCE)
EOL