1818
1919__version__ = '0.0.2'
2020
21- def build_libtrtorch_pre_cxx11_abi (develop = True , use_dist_dir = True ):
21+ CXX11_ABI = False
22+
23+ if "--use-cxx11-abi" in sys .argv :
24+ sys .argv .remove ("--use-cxx11-abi" )
25+ CXX11_ABI = True
26+
27+ def build_libtrtorch_pre_cxx11_abi (develop = True , use_dist_dir = True , cxx11_abi = False ):
2228 cmd = ["/usr/bin/bazel" , "build" ]
2329 cmd .append ("//cpp/api/lib:libtrtorch.so" )
2430 if develop :
@@ -27,7 +33,10 @@ def build_libtrtorch_pre_cxx11_abi(develop=True, use_dist_dir=True):
2733 cmd .append ("--compilation_mode=opt" )
2834 if use_dist_dir :
2935 cmd .append ("--distdir=third_party/dist_dir/x86_64-linux-gnu" )
30- cmd .append ("--config=python" )
36+ if not cxx11_abi :
37+ cmd .append ("--config=python" )
38+ else :
39+ print ("using CXX11 ABI build" )
3140
3241 print ("building libtrtorch" )
3342 status_code = subprocess .run (cmd ).returncode
@@ -64,7 +73,8 @@ def finalize_options(self):
6473 develop .finalize_options (self )
6574
6675 def run (self ):
67- build_libtrtorch_pre_cxx11_abi (develop = True )
76+ global CXX11_ABI
77+ build_libtrtorch_pre_cxx11_abi (develop = True , cxx11_abi = CXX11_ABI )
6878 gen_version_file ()
6979 copy_libtrtorch ()
7080 develop .run (self )
@@ -80,7 +90,8 @@ def finalize_options(self):
8090 install .finalize_options (self )
8191
8292 def run (self ):
83- build_libtrtorch_pre_cxx11_abi (develop = False )
93+ global CXX11_ABI
94+ build_libtrtorch_pre_cxx11_abi (develop = False , cxx11_abi = CXX11_ABI )
8495 gen_version_file ()
8596 copy_libtrtorch ()
8697 install .run (self )
@@ -95,7 +106,8 @@ def finalize_options(self):
95106 bdist_wheel .finalize_options (self )
96107
97108 def run (self ):
98- build_libtrtorch_pre_cxx11_abi (develop = False )
109+ global CXX11_ABI
110+ build_libtrtorch_pre_cxx11_abi (develop = False , cxx11_abi = CXX11_ABI )
99111 gen_version_file ()
100112 copy_libtrtorch ()
101113 bdist_wheel .run (self )
@@ -138,15 +150,16 @@ def run(self):
138150 dir_path + "/../bazel-TRTorch/external/tensorrt/include" ,
139151 ],
140152 extra_compile_args = [
141- "-D_GLIBCXX_USE_CXX11_ABI=0 " ,
142- "-Wno-deprecated-declaration " ,
143- ],
153+ "-Wno-deprecated " ,
154+ "-Wno-deprecated-declarations " ,
155+ ] + [ "-D_GLIBCXX_USE_CXX11_ABI=1" ] if CXX11_ABI else [ "-D_GLIBCXX_USE_CXX11_ABI=0" ] ,
144156 extra_link_args = [
145- "-D_GLIBCXX_USE_CXX11_ABI=0"
157+ "-Wno-deprecated" ,
158+ "-Wno-deprecated-declarations" ,
146159 "-Wl,--no-as-needed" ,
147160 "-ltrtorch" ,
148161 "-Wl,-rpath,$ORIGIN/lib"
149- ],
162+ ] + [ "-D_GLIBCXX_USE_CXX11_ABI=1" ] if CXX11_ABI else [ "-D_GLIBCXX_USE_CXX11_ABI=0" ] ,
150163 undef_macros = [ "NDEBUG" ]
151164 )
152165]
@@ -178,7 +191,6 @@ def run(self):
178191 zip_safe = False ,
179192 license = "BSD" ,
180193 packages = find_packages (),
181- platform = "Linux" ,
182194 classifiers = [
183195 "Development Status :: 3 - Alpha" ,
184196 "Environment :: GPU :: NVIDIA CUDA" ,
0 commit comments