From 1fe662581e39656f706316ad4bd7d7bc43ca0600 Mon Sep 17 00:00:00 2001 From: Evan Li Date: Tue, 21 Jan 2025 16:06:46 -0800 Subject: [PATCH] update bazelrc --- .bazelrc | 7 ++++--- setup.py | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.bazelrc b/.bazelrc index 2680d2f638..04ac0ba143 100644 --- a/.bazelrc +++ b/.bazelrc @@ -30,11 +30,12 @@ build:windows --cxxopt="/GS-" --cxxopt="/std:c++17" --cxxopt="/permissive-" build:windows --cxxopt="/wd4244" --cxxopt="/wd4267" --cxxopt="/wd4819" build:windows --features=windows_export_all_symbols -build:python --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" -build:python --linkopt="-D_GLIBCXX_USE_CXX11_ABI=0" -build:python --define=abi=pre_cxx11_abi build:python --define=target_lang=python +build:cxx11_abi --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=1" +build:cxx11_abi --linkopt="-D_GLIBCXX_USE_CXX11_ABI=1" +build:cxx11_abi --define=abi=cxx11_abi + build:pre_cxx11_abi --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" build:pre_cxx11_abi --linkopt="-D_GLIBCXX_USE_CXX11_ABI=0" build:pre_cxx11_abi --define=abi=pre_cxx11_abi diff --git a/setup.py b/setup.py index 2905e161d6..7964b2979d 100644 --- a/setup.py +++ b/setup.py @@ -181,8 +181,12 @@ def load_dep_info(): sys.exit("Could not find bazel in PATH") -def build_libtorchtrt_pre_cxx11_abi( - develop=True, use_dist_dir=True, pre_cxx11_abi=True, rt_only=False +def build_libtorchtrt_cxx11_abi( + develop=True, + use_dist_dir=True, + pre_cxx11_abi=False, + rt_only=False, + target_python=True, ): cmd = [BAZEL_EXE, "build"] if rt_only: @@ -196,9 +200,15 @@ def build_libtorchtrt_pre_cxx11_abi( cmd.append("--compilation_mode=opt") if use_dist_dir: cmd.append("--distdir=third_party/dist_dir/x86_64-linux-gnu") - if pre_cxx11_abi: + + if target_python: cmd.append("--config=python") + + if pre_cxx11_abi: + cmd.append("--config=pre_cxx11_abi") + print("using PRE CXX11 ABI build") else: + cmd.append("--config=cxx11_abi") print("using CXX11 ABI build") if IS_WINDOWS: @@ -293,7 +303,7 @@ def run(self): if not PY_ONLY: global PRE_CXX11_ABI - build_libtorchtrt_pre_cxx11_abi( + build_libtorchtrt_cxx11_abi( develop=True, pre_cxx11_abi=PRE_CXX11_ABI, rt_only=NO_TS ) copy_libtorchtrt(rt_only=NO_TS) @@ -317,7 +327,7 @@ def run(self): if not PY_ONLY: global PRE_CXX11_ABI - build_libtorchtrt_pre_cxx11_abi( + build_libtorchtrt_cxx11_abi( develop=False, pre_cxx11_abi=PRE_CXX11_ABI, rt_only=NO_TS ) copy_libtorchtrt(rt_only=NO_TS) @@ -340,7 +350,7 @@ def finalize_options(self): def run(self): if not PY_ONLY: global PRE_CXX11_ABI - build_libtorchtrt_pre_cxx11_abi( + build_libtorchtrt_cxx11_abi( develop=False, pre_cxx11_abi=PRE_CXX11_ABI, rt_only=NO_TS ) copy_libtorchtrt(rt_only=NO_TS) @@ -366,7 +376,7 @@ def run(self): editable_wheel.run(self) else: global PRE_CXX11_ABI - build_libtorchtrt_pre_cxx11_abi( + build_libtorchtrt_cxx11_abi( develop=True, pre_cxx11_abi=PRE_CXX11_ABI, rt_only=NO_TS ) gen_version_file()