From 8373b835247058c91ece8da657b401f0ed8289c5 Mon Sep 17 00:00:00 2001 From: Yi Xu Date: Mon, 28 Feb 2022 17:03:20 +0800 Subject: [PATCH] [build] Enforce compatibility with manylinux2014 when TI_WITH_VULKAN=OFF (#4406) * [build] Enforce compatibility with manylinux2014 when TI_WITH_VULKAN=OFF * Auto Format Co-authored-by: Taichi Gardener --- cmake/TaichiCore.cmake | 7 ++++- taichi/common/symbol_version.cpp | 46 ++++++++++++++++++++------------ 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/cmake/TaichiCore.cmake b/cmake/TaichiCore.cmake index 0eeb59983..3545dc68b 100644 --- a/cmake/TaichiCore.cmake +++ b/cmake/TaichiCore.cmake @@ -395,7 +395,12 @@ if (NOT WIN32) target_link_libraries(${CORE_LIBRARY_NAME} -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/misc/linker.map) endif () # Avoid glibc dependencies - target_link_libraries(${CORE_LIBRARY_NAME} -Wl,--wrap=log2f) + if (TI_WITH_VULKAN) + target_link_libraries(${CORE_LIBRARY_NAME} -Wl,--wrap=log2f) + else() + # Enforce compatibility with manylinux2014 + target_link_libraries(${CORE_LIBRARY_NAME} -Wl,--wrap=log2f -Wl,--wrap=exp2 -Wl,--wrap=log2 -Wl,--wrap=logf -Wl,--wrap=powf -Wl,--wrap=exp -Wl,--wrap=log -Wl,--wrap=pow) + endif() endif() else() # windows diff --git a/taichi/common/symbol_version.cpp b/taichi/common/symbol_version.cpp index b86a4d359..9f1bfeaff 100644 --- a/taichi/common/symbol_version.cpp +++ b/taichi/common/symbol_version.cpp @@ -26,23 +26,35 @@ float __wrap_log2f(float x) { return log2f(x); } // The following are offending symbols using higher GLIBC versions -// TODO currently commented out due to failing Vulkan tests -//__asm__(".symver log2,log2@GLIBC_2.2.5"); -// float __wrap_log2(float x) { -// return log2(x); -//} -//__asm__(".symver exp,exp@GLIBC_2.2.5"); -// float __wrap_exp(float x) { -// return exp(x); -//} -//__asm__(".symver log,log@GLIBC_2.2.5"); -// float __wrap_log(float x) { -// return log(x); -//} -//__asm__(".symver pow,pow@GLIBC_2.2.5"); -// float __wrap_pow(float x, float y) { -// return pow(x, y); -//} +// They will fail Vulkan tests if wrapping is enabled +__asm__(".symver exp2,exp2@GLIBC_2.2.5"); +float __wrap_exp2(float x) { + return exp2(x); +} +__asm__(".symver log2,log2@GLIBC_2.2.5"); +float __wrap_log2(float x) { + return log2(x); +} +__asm__(".symver logf,logf@GLIBC_2.2.5"); +float __wrap_logf(float x) { + return logf(x); +} +__asm__(".symver powf,powf@GLIBC_2.2.5"); +float __wrap_powf(float x, float y) { + return powf(x, y); +} +__asm__(".symver exp,exp@GLIBC_2.2.5"); +float __wrap_exp(float x) { + return exp(x); +} +__asm__(".symver log,log@GLIBC_2.2.5"); +float __wrap_log(float x) { + return log(x); +} +__asm__(".symver pow,pow@GLIBC_2.2.5"); +float __wrap_pow(float x, float y) { + return pow(x, y); +} #endif }