MCPcopy Create free account
hub / github.com/numpy/numpy / _link_wrapper_lib

Method _link_wrapper_lib

numpy/distutils/fcompiler/gnu.py:414–474  ·  view source on GitHub ↗

Create a wrapper shared library for the given objects Return an MSVC-compatible lib

(self, objects, output_dir, extra_dll_dir,
                          chained_dlls, is_archive)

Source from the content-addressed store, hash-verified

412 return text.rstrip('=')
413
414 def _link_wrapper_lib(self, objects, output_dir, extra_dll_dir,
415 chained_dlls, is_archive):
416 """Create a wrapper shared library for the given objects
417
418 Return an MSVC-compatible lib
419 """
420
421 c_compiler = self.c_compiler
422 if c_compiler.compiler_type != "msvc":
423 raise ValueError("This method only supports MSVC")
424
425 object_hash = self._hash_files(list(objects) + list(chained_dlls))
426
427 if is_win64():
428 tag = 'win_amd64'
429 else:
430 tag = 'win32'
431
432 basename = 'lib' + os.path.splitext(
433 os.path.basename(objects[0]))[0][:8]
434 root_name = basename + '.' + object_hash + '.gfortran-' + tag
435 dll_name = root_name + '.dll'
436 def_name = root_name + '.def'
437 lib_name = root_name + '.lib'
438 dll_path = os.path.join(extra_dll_dir, dll_name)
439 def_path = os.path.join(output_dir, def_name)
440 lib_path = os.path.join(output_dir, lib_name)
441
442 if os.path.isfile(lib_path):
443 # Nothing to do
444 return lib_path, dll_path
445
446 if is_archive:
447 objects = (["-Wl,--whole-archive"] + list(objects) +
448 ["-Wl,--no-whole-archive"])
449 self.link_shared_object(
450 objects,
451 dll_name,
452 output_dir=extra_dll_dir,
453 extra_postargs=list(chained_dlls) + [
454 '-Wl,--allow-multiple-definition',
455 '-Wl,--output-def,' + def_path,
456 '-Wl,--export-all-symbols',
457 '-Wl,--enable-auto-import',
458 '-static',
459 '-mlong-double-64',
460 ])
461
462 # No PowerPC!
463 if is_win64():
464 specifier = '/MACHINE:X64'
465 else:
466 specifier = '/MACHINE:X86'
467
468 # MSVC specific code
469 lib_args = ['/def:' + def_path, '/OUT:' + lib_path, specifier]
470 if not c_compiler.initialized:
471 c_compiler.initialize()

Callers 1

Calls 4

_hash_filesMethod · 0.95
is_win64Function · 0.85
joinMethod · 0.45
initializeMethod · 0.45

Tested by

no test coverage detected