@@ -180,6 +180,7 @@ def __init__(self):
180180 """
181181
182182 fields = {'cc' , 'ld' }
183+ linker_opt = '-Wl,'
183184 _default_cpp = False
184185 _cxxstd = 'c++14'
185186 _cstd = 'c99'
@@ -290,6 +291,22 @@ def load(self, soname):
290291 """
291292 return npct .load_library (str (self .get_jit_dir ().joinpath (soname )), '.' )
292293
294+ def save_header (self , filename , code ):
295+ """
296+ Store some source code into a header file within the same temporary directory
297+ used for JIT compilation.
298+
299+ Parameters
300+ ----------
301+ filename : str
302+ The name of the header file (w/o the suffix).
303+ code : str
304+ The source code to be stored.
305+ """
306+ hfile = self .get_jit_dir ().joinpath (filename ).with_suffix ('.h' )
307+ with open (str (hfile ), 'w' ) as f :
308+ f .write (code )
309+
293310 def save (self , soname , binary ):
294311 """
295312 Store a binary into a file within a temporary directory.
@@ -425,7 +442,7 @@ def add_library_dirs(self, dirs, rpath=False):
425442 if rpath :
426443 # Add rpath flag to embed library dir
427444 for d in as_list (dirs ):
428- self .ldflags .append (f'-Wl, -rpath,{ d } ' )
445+ self .ldflags .append (f'{ self . linker_opt } -rpath,{ d } ' )
429446
430447 def add_libraries (self , libs ):
431448 self .libraries = filter_ordered (self .libraries + as_list (libs ))
@@ -662,6 +679,7 @@ def __lookup_cmds__(self):
662679class CudaCompiler (Compiler ):
663680
664681 _default_cpp = True
682+ linker_opt = "--linker-options="
665683
666684 def __init_finalize__ (self , ** kwargs ):
667685
0 commit comments