diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2018-10-01 20:48:34 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-10-20 00:47:27 +0300 |
commit | c453400d597116954b3bb2a9e2c3d60251dc97a2 (patch) | |
tree | 9bfe4e1ad5cf6f0fe05e6ebd4ee34c746ca40eac /mesonbuild/compilers/compilers.py | |
parent | 3ad99d27695c3018cf2449a2478b346a5b069c95 (diff) | |
download | meson-c453400d597116954b3bb2a9e2c3d60251dc97a2.zip meson-c453400d597116954b3bb2a9e2c3d60251dc97a2.tar.gz meson-c453400d597116954b3bb2a9e2c3d60251dc97a2.tar.bz2 |
Add 'b_pie' compiler option
On Android executables must be position independent, many
distributions enable it by default too for security reasons.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r-- | mesonbuild/compilers/compilers.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index 26eec48..50fda5a 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -331,6 +331,9 @@ base_options = {'b_pch': coredata.UserBooleanOption('b_pch', 'Use precompiled he 'b_staticpic': coredata.UserBooleanOption('b_staticpic', 'Build static libraries as position independent', True), + 'b_pie': coredata.UserBooleanOption('b_pie', + 'Build executables as position independent', + False), 'b_bitcode': coredata.UserBooleanOption('b_bitcode', 'Generate and embed bitcode (only macOS and iOS)', False), @@ -1180,6 +1183,18 @@ class Compiler: raise EnvironmentException( 'Language {} does not support function attributes.'.format(self.get_display_language())) + def get_pic_args(self): + m = 'Language {} does not support position-independent code' + raise EnvironmentException(m.format(self.get_display_language())) + + def get_pie_args(self): + m = 'Language {} does not support position-independent executable' + raise EnvironmentException(m.format(self.get_display_language())) + + def get_pie_link_args(self): + m = 'Language {} does not support position-independent executable' + raise EnvironmentException(m.format(self.get_display_language())) + @enum.unique class CompilerType(enum.Enum): @@ -1322,7 +1337,7 @@ class GnuLikeCompiler(abc.ABC): def __init__(self, compiler_type): self.compiler_type = compiler_type self.base_options = ['b_pch', 'b_lto', 'b_pgo', 'b_sanitize', 'b_coverage', - 'b_ndebug', 'b_staticpic'] + 'b_ndebug', 'b_staticpic', 'b_pie'] if not self.compiler_type.is_osx_compiler and not self.compiler_type.is_windows_compiler: self.base_options.append('b_lundef') if not self.compiler_type.is_windows_compiler: @@ -1345,6 +1360,12 @@ class GnuLikeCompiler(abc.ABC): return [] # On Window and OS X, pic is always on. return ['-fPIC'] + def get_pie_args(self): + return ['-fPIE'] + + def get_pie_link_args(self): + return ['-pie'] + def get_buildtype_args(self, buildtype): return gnulike_buildtype_args[buildtype] |