Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions build_tools/setup_helpers/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ def _get_libraries():
]


def _get_cxx11_abi():
try:
import torch
value = int(torch._C._GLIBCXX_USE_CXX11_ABI)
except ImportError:
value = 0
return '-D_GLIBCXX_USE_CXX11_ABI=' + str(value)


def _build_third_party(debug):
build_dir = _TP_BASE_DIR / 'build'
build_dir.mkdir(exist_ok=True)
Expand All @@ -96,7 +105,7 @@ def _build_third_party(debug):
build_env.setdefault('CC', 'cl')
build_env.setdefault('CXX', 'cl')
else:
extra_args = ['-DCMAKE_CXX_FLAGS=-fPIC']
extra_args = ['-DCMAKE_CXX_FLAGS=-fPIC ' + _get_cxx11_abi()]
subprocess.run(
args=[
'cmake',
Expand All @@ -113,7 +122,7 @@ def _build_third_party(debug):
print('*** Command list Thirdparty ***')
with open(build_dir / 'compile_commands.json', 'r') as fileobj:
print(fileobj.read())
print(f'running cmake --build', flush=True)
print('running cmake --build', flush=True)
subprocess.run(
args=['cmake', '--build', '.', '--target', 'install', '--config', config],
cwd=str(build_dir),
Expand All @@ -134,7 +143,8 @@ def _build_sentence_piece(debug):
else:
extra_args = []
subprocess.run(
args=['cmake', f'-DSPM_ENABLE_SHARED=OFF', f'-DCMAKE_INSTALL_PREFIX={_TP_INSTALL_DIR}',
args=['cmake', '-DSPM_ENABLE_SHARED=OFF', f'-DCMAKE_INSTALL_PREFIX={_TP_INSTALL_DIR}',
'-DCMAKE_CXX_FLAGS=' + _get_cxx11_abi(),
f'-DCMAKE_BUILD_TYPE={config}'] + extra_args + ['..'],
cwd=str(build_dir),
check=True,
Expand Down