diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2018-10-13 20:00:38 -0700 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2018-11-15 18:42:25 -0800 |
| commit | 9f9cfd21396db5cd5eb1711916c8b0c6e433c702 (patch) | |
| tree | 1d42c21c51f80f5c9ae1bbc9f46b840eee4c6da5 /mesonbuild/compilers | |
| parent | a480de1cb55c9efa88a9a520d0d776743b4e5664 (diff) | |
| download | meson-9f9cfd21396db5cd5eb1711916c8b0c6e433c702.tar.gz | |
compilers: Move get_allow_undefined_link_args to Compiler
This allows each implementation (gnu-like) and msvc to be implemented in
their respective classes rather than through an if tree in the CCompiler
class. This is cleaner abstraction and allows us to clean up the Fortran
compiler, which was calling CCompiler bound methods without an instance.
Diffstat (limited to 'mesonbuild/compilers')
| -rw-r--r-- | mesonbuild/compilers/c.py | 32 | ||||
| -rw-r--r-- | mesonbuild/compilers/compilers.py | 14 | ||||
| -rw-r--r-- | mesonbuild/compilers/fortran.py | 3 |
3 files changed, 20 insertions, 29 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index bc90381d1..9a2d7dbc6 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -157,32 +157,6 @@ class CCompiler(Compiler): ''' return self.get_no_optimization_args() - def get_allow_undefined_link_args(self): - ''' - Get args for allowing undefined symbols when linking to a shared library - ''' - if self.id in ('clang', 'gcc'): - if self.compiler_type.is_osx_compiler: - # Apple ld - return ['-Wl,-undefined,dynamic_lookup'] - elif self.compiler_type.is_windows_compiler: - # For PE/COFF this is impossible - return [] - else: - # GNU ld and LLVM lld - return ['-Wl,--allow-shlib-undefined'] - elif isinstance(self, VisualStudioCCompiler): - # link.exe - return ['/FORCE:UNRESOLVED'] - elif self.id == 'intel': - if self.compiler_type.is_osx_compiler: - # Apple ld - return ['-Wl,-undefined,dynamic_lookup'] - else: - return ['-Wl,--allow-shlib-undefined'] - # FIXME: implement other linkers - return [] - def get_output_args(self, target): return ['-o', target] @@ -1600,11 +1574,17 @@ class VisualStudioCCompiler(CCompiler): def get_argument_syntax(self): return 'msvc' + def get_allow_undefined_link_args(self): + # link.exe + return ['/FORCE:UNRESOLVED'] + + class ClangClCCompiler(VisualStudioCCompiler): def __init__(self, exelist, version, is_cross, exe_wrap, is_64): super().__init__(exelist, version, is_cross, exe_wrap, is_64) self.id = 'clang-cl' + class ArmCCompiler(ArmCompiler, CCompiler): def __init__(self, exelist, version, compiler_type, is_cross, exe_wrapper=None, **kwargs): CCompiler.__init__(self, exelist, version, is_cross, exe_wrapper, **kwargs) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 3d53f27e8..f464ec85f 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -1265,6 +1265,12 @@ class Compiler: raise EnvironmentException( '%s does not support get_profile_use_args ' % self.get_id()) + def get_undefined_link_args(self): + ''' + Get args for allowing undefined symbols when linking to a shared library + ''' + return [] + @enum.unique class CompilerType(enum.Enum): @@ -1511,6 +1517,14 @@ class GnuLikeCompiler(abc.ABC): def get_profile_use_args(self): return ['-fprofile-use', '-fprofile-correction'] + def get_allow_undefined_link_args(self): + if self.compiler_type.is_osx_compiler: + # Apple ld + return ['-Wl,-undefined,dynamic_lookup'] + else: + # GNU ld and LLVM lld + return ['-Wl,--allow-shlib-undefined'] + class GnuCompiler(GnuLikeCompiler): """ diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 8eea4e745..0afdfdf82 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -144,9 +144,6 @@ end program prog def get_compiler_check_args(self): return CCompiler.get_compiler_check_args(self) - def get_allow_undefined_link_args(self): - return CCompiler.get_allow_undefined_link_args(self) - def get_output_args(self, target): return CCompiler.get_output_args(self, target) |
