aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/compilers/__init__.py2
-rw-r--r--mesonbuild/compilers/compilers.py24
-rw-r--r--mesonbuild/compilers/mixins/gnu.py13
-rw-r--r--mesonbuild/modules/gnome.py5
4 files changed, 23 insertions, 21 deletions
diff --git a/mesonbuild/compilers/__init__.py b/mesonbuild/compilers/__init__.py
index 37e0ad1..6d9e814 100644
--- a/mesonbuild/compilers/__init__.py
+++ b/mesonbuild/compilers/__init__.py
@@ -33,7 +33,6 @@ __all__ = [
'is_object',
'is_source',
'lang_suffixes',
- 'sanitizer_compile_args',
'sort_clink',
'ArmCCompiler',
@@ -116,7 +115,6 @@ from .compilers import (
is_object,
is_library,
lang_suffixes,
- sanitizer_compile_args,
sort_clink,
CompilerArgs,
)
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 417e0e9..3b61e61 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -254,20 +254,6 @@ base_options = {'b_pch': coredata.UserBooleanOption('Use precompiled headers', T
'from_buildtype'),
}
-def sanitizer_compile_args(value):
- if value == 'none':
- return []
- args = ['-fsanitize=' + value]
- if 'address' in value: # For -fsanitize=address,undefined
- args.append('-fno-omit-frame-pointer')
- return args
-
-def sanitizer_link_args(value):
- if value == 'none':
- return []
- args = ['-fsanitize=' + value]
- return args
-
def option_enabled(boptions, options, option):
try:
if option not in boptions:
@@ -288,7 +274,7 @@ def get_base_compile_args(options, compiler):
except KeyError:
pass
try:
- args += sanitizer_compile_args(options['b_sanitize'].value)
+ args += compiler.sanitizer_compile_args(options['b_sanitize'].value)
except KeyError:
pass
try:
@@ -333,7 +319,7 @@ def get_base_link_args(options, linker, is_shared_module):
except KeyError:
pass
try:
- args += sanitizer_link_args(options['b_sanitize'].value)
+ args += linker.sanitizer_link_args(options['b_sanitize'].value)
except KeyError:
pass
try:
@@ -1201,6 +1187,12 @@ class Compiler:
def get_lto_link_args(self) -> List[str]:
return []
+ def sanitizer_compile_args(self, value: str) -> List[str]:
+ return []
+
+ def sanitizer_link_args(self, value: str) -> List[str]:
+ return []
+
@enum.unique
class CompilerType(enum.Enum):
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index 5647339..9756604 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -372,6 +372,19 @@ class GnuLikeCompiler(metaclass=abc.ABCMeta):
def get_lto_link_args(self) -> typing.List[str]:
return ['-flto']
+ def sanitizer_compile_args(self, value: str) -> typing.List[str]:
+ if value == 'none':
+ return []
+ args = ['-fsanitize=' + value]
+ if 'address' in value: # for -fsanitize=address,undefined
+ args.append('-fno-omit-frame-pointer')
+ return args
+
+ def sanitizer_link_args(self, value: str) -> typing.List[str]:
+ if value == 'none':
+ return []
+ return ['-fsanitize=' + value]
+
class GnuCompiler(GnuLikeCompiler):
"""
diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
index f67c7c2..1ee98cc 100644
--- a/mesonbuild/modules/gnome.py
+++ b/mesonbuild/modules/gnome.py
@@ -23,7 +23,6 @@ import subprocess
from .. import build
from .. import mlog
from .. import mesonlib
-from .. import compilers
from .. import interpreter
from . import GResourceTarget, GResourceHeaderTarget, GirTarget, TypelibTarget, VapiTarget
from . import get_include_args
@@ -604,7 +603,7 @@ class GnomeModule(ExtensionModule):
cflags += state.project_args[lang]
if 'b_sanitize' in compiler.base_options:
sanitize = state.environment.coredata.base_options['b_sanitize'].value
- cflags += compilers.sanitizer_compile_args(sanitize)
+ cflags += compiler.sanitizer_compile_args(sanitize)
sanitize = sanitize.split(',')
# These must be first in ldflags
if 'address' in sanitize:
@@ -615,7 +614,7 @@ class GnomeModule(ExtensionModule):
internal_ldflags += ['-lubsan']
# FIXME: Linking directly to lib*san is not recommended but g-ir-scanner
# does not understand -f LDFLAGS. https://bugzilla.gnome.org/show_bug.cgi?id=783892
- # ldflags += compilers.sanitizer_link_args(sanitize)
+ # ldflags += compiler.sanitizer_link_args(sanitize)
return cflags, internal_ldflags, external_ldflags