@@ -24,9 +24,9 @@ def build_library(output_path, repo_paths): # pragma: no cover
2424 the library already existed and was modified more recently than
2525 any of the source files.
2626 """
27- from ctypes .util import find_library
2827 from distutils .ccompiler import new_compiler
2928 from distutils .sysconfig import customize_compiler
29+ from distutils .unixccompiler import UnixCCompiler
3030 from os import path
3131 from platform import system
3232 from tempfile import TemporaryDirectory
@@ -51,14 +51,9 @@ def build_library(output_path, repo_paths): # pragma: no cover
5151 ]
5252
5353 compiler = new_compiler ()
54- if cpp :
55- if find_library ("stdc++" ):
56- compiler .add_library ("stdc++" )
57- elif find_library ("c++" ):
58- compiler .add_library ("c++" )
59- else :
60- # fallback to assuming libstdc++ exists (#299)
61- compiler .add_library ("stdc++" )
54+ # force `c++` compiler so the appropriate standard library is used
55+ if isinstance (compiler , UnixCCompiler ):
56+ compiler .compiler_cxx [0 ] = "c++"
6257
6358 if max (source_mtimes ) <= output_mtime :
6459 return False
@@ -80,7 +75,11 @@ def build_library(output_path, repo_paths): # pragma: no cover
8075 extra_preargs = flags ,
8176 )[0 ]
8277 )
83- compiler .link_shared_object (object_paths , output_path )
78+ compiler .link_shared_object (
79+ object_paths ,
80+ output_path ,
81+ target_lang = "c++" if cpp else "c" ,
82+ )
8483 return True
8584
8685
0 commit comments