diff options
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/backend/ninjabackend.py | 2 | ||||
-rw-r--r-- | mesonbuild/build.py | 9 | ||||
-rw-r--r-- | mesonbuild/compilers/compilers.py | 15 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 1 |
4 files changed, 27 insertions, 0 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 913830f..f88c589 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1951,6 +1951,8 @@ rule FORTRAN_DEP_HACK%s # Create an empty commands list, and start adding arguments from # various sources in the order in which they must override each other commands = CompilerArgs(compiler) + # Start with symbol visibility. + commands += compiler.symbol_visibility_args(target.symbol_visibility) # Add compiler args for compiling this target derived from 'base' build # options passed on the command-line, in default_options, etc. # These have the lowest priority. diff --git a/mesonbuild/build.py b/mesonbuild/build.py index a3cd993..3d43c89 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -71,6 +71,7 @@ buildtarget_kwargs = set([ 'objects', 'override_options', 'sources', + 'symbol_visibility', ]) known_build_target_kwargs = ( @@ -817,6 +818,14 @@ This will become a hard error in a future Meson release.''') self.implicit_include_directories = kwargs.get('implicit_include_directories', True) if not isinstance(self.implicit_include_directories, bool): raise InvalidArguments('Implicit_include_directories must be a boolean.') + self.symbol_visibility = kwargs.get('symbol_visibility', '') + if not isinstance(self.symbol_visibility, str): + raise InvalidArguments('Symbol visibility must be a string.') + if self.symbol_visibility != '': + permitted = ['default', 'internal', 'hidden', 'protected', 'inlineshidden'] + if self.symbol_visibility not in permitted: + raise InvalidArguments('Symbol visibility arg %s not one of: %s', + self.symbol_visibility, ', '.join(permitted)) def get_filename(self): return self.filename diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 25835a3..3668a79 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -311,6 +311,14 @@ vs64_instruction_set_args = {'mmx': ['/arch:AVX'], 'neon': None, } +common_symbol_visibility_args = {'': [], + 'default': ['-fvisibility=default'], + 'internal': ['-fvisibility=internal'], + 'hidden': ['-fvisibility=hidden'], + 'protected': ['-fvisibility=protected'], + 'inlineshidden': ['-fvisibility=hidden', '-fvisibility-inlines-hidden'], + } + def sanitizer_compile_args(value): if value == 'none': return [] @@ -1062,6 +1070,9 @@ class Compiler: # building fails with undefined symbols. return [] + def symbol_visibility_args(self, vistype): + return [] + GCC_STANDARD = 0 GCC_OSX = 1 GCC_MINGW = 2 @@ -1277,6 +1288,8 @@ class GnuCompiler: def openmp_flags(self): return ['-fopenmp'] + def symbol_visibility_args(self, vistype): + return common_symbol_visibility_args[vistype] class ElbrusCompiler(GnuCompiler): # Elbrus compiler is nearly like GCC, but does not support @@ -1419,6 +1432,8 @@ class ClangCompiler: # Shouldn't work, but it'll be checked explicitly in the OpenMP dependency. return [] + def symbol_visibility_args(self, vistype): + return common_symbol_visibility_args[vistype] class ArmclangCompiler: def __init__(self): diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index fd0385d..c84ed96 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -3850,6 +3850,7 @@ Try setting b_lundef to false instead.''') @FeatureNewKwargs('build target', '0.42.0', ['rust_crate_type', 'build_rpath', 'implicit_include_directories']) @FeatureNewKwargs('build target', '0.41.0', ['rust_args']) @FeatureNewKwargs('build target', '0.40.0', ['build_by_default']) + @FeatureNewKwargs('build target', '0.48.0', ['symbol_visibility']) def build_target_decorator_caller(self, node, args, kwargs): return True |