Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Misc] [refactor] Move symbol versioning to a new file #3426

Merged
merged 6 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 0 additions & 12 deletions taichi/common/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@

TI_NAMESPACE_BEGIN

extern "C" {
#if defined(TI_PLATFORM_LINUX) && defined(TI_ARCH_x64)
// Avoid dependency on glibc 2.27
// log2f is used by a third party .a file, so we have to define a wrapper.
// https://stackoverflow.com/questions/8823267/linking-against-older-symbol-version-in-a-so-file
__asm__(".symver log2f,log2f@GLIBC_2.2.5");
float __wrap_log2f(float x) {
return log2f(x);
}
#endif
}

std::string python_package_dir;

std::string get_python_package_dir() {
Expand Down
49 changes: 49 additions & 0 deletions taichi/common/symbol_version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*******************************************************************************
Copyright (c) The Taichi Authors (2016- ). All Rights Reserved.
The use of this software is governed by the LICENSE file.
*******************************************************************************/

#include "taichi/common/core.h"

#if defined(TI_PLATFORM_WINDOWS)
#include "taichi/platform/windows/windows.h"
#else
// Mac and Linux
#include <unistd.h>
#endif

TI_NAMESPACE_BEGIN

extern "C" {
#if defined(TI_PLATFORM_LINUX) && defined(TI_ARCH_x64)
// Avoid dependency on higher glibc versions such as 2.27 or 2.29
// Related issue: https://github.com/taichi-dev/taichi/issues/3174
// log2f is used by a third party .a file, so we have to define a wrapper.
// https://stackoverflow.com/questions/8823267/linking-against-older-symbol-version-in-a-so-file
// The wrapper should be linked using target_link_libraries in TaichiCore.cmake
__asm__(".symver log2f,log2f@GLIBC_2.2.5");
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);
//}
#endif
}

TI_NAMESPACE_END