|
1 | 1 | from functools import partial |
2 | 2 | from hashlib import sha1 |
| 3 | +from itertools import repeat, filterfalse |
3 | 4 | from os import environ, path, makedirs |
4 | 5 | from packaging.version import Version |
5 | 6 | from subprocess import (DEVNULL, PIPE, CalledProcessError, check_output, |
@@ -666,6 +667,30 @@ def __lookup_cmds__(self): |
666 | 667 | self.MPICC = 'mpic++' |
667 | 668 | self.MPICXX = 'mpicxx' |
668 | 669 |
|
| 670 | + def add_libraries(self, libs): |
| 671 | + # Urgh... |
| 672 | + # PGIComiler inherits from Compiler inherits from GCCToolchain in codepy |
| 673 | + # GCC supports linking versioned shared objects with the syntax |
| 674 | + # `gcc -L/path/to/versioned/lib -l:libfoo.so.2.0 ...` |
| 675 | + # But this syntax is not supported by the Portland (or Nvidia) compiler. |
| 676 | + # Nor does codepy.GCCToolchain understand that linking to versioned objects |
| 677 | + # is a thing that someone might want to do |
| 678 | + # |
| 679 | + # Since this is just linking information, we can just tell the linker |
| 680 | + # (which we invoke using the compiler and the `-Wl,-options` syntax) to |
| 681 | + # go and look in all of the directories we have provided thus far and |
| 682 | + # the linker supports the syntax: |
| 683 | + # `ld -L/path/to/versioned/lib -l:libfoo.so.2.0 ...` |
| 684 | + # Note: It would be nicer to just look in the one _relevant_ lib dir! |
| 685 | + new = as_list(libs) |
| 686 | + versioned = filter(lambda s: s.startswith(':'), new) |
| 687 | + versioned = map(lambda s: s.removeprefix(':'), versioned) |
| 688 | + self.add_ldflags([ |
| 689 | + f'-Wl,-L{",-L".join(map(str, self.library_dirs))},-l:{soname}' |
| 690 | + for soname in versioned |
| 691 | + ]) |
| 692 | + super().add_libraries(filterfalse(lambda s: s.startswith(':'), new)) |
| 693 | + |
669 | 694 |
|
670 | 695 | class NvidiaCompiler(PGICompiler): |
671 | 696 |
|
|
0 commit comments