summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorCharles Brunet <charles.brunet@optelgroup.com>2023-12-01 13:55:09 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2023-12-23 13:32:49 +0200
commit4761e4cad946b42daa8723672957e9c1eaeaa5be (patch)
tree328144b20f11726c407cd60e037c372cb279e32d /mesonbuild
parent360d81e4aa3eb1230997a7a1c74130bca00fd896 (diff)
downloadmeson-4761e4cad946b42daa8723672957e9c1eaeaa5be.tar.gz
Remove `get_buildtype_args` function
This is a first step to make `buildtype` a true alias of `debug` and `optimization` options. See #10808. Relates to: - #11645 - #12096 - #5920 - #5814 - #8220 - #8493 - #9540 - #10487 - #12265 - #8308 - #8214 - #7194 - #11732
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py5
-rw-r--r--mesonbuild/backend/ninjabackend.py6
-rw-r--r--mesonbuild/backend/vs2010backend.py14
-rw-r--r--mesonbuild/compilers/asm.py12
-rw-r--r--mesonbuild/compilers/compilers.py95
-rw-r--r--mesonbuild/compilers/cs.py20
-rw-r--r--mesonbuild/compilers/cuda.py29
-rw-r--r--mesonbuild/compilers/cython.py4
-rw-r--r--mesonbuild/compilers/d.py47
-rw-r--r--mesonbuild/compilers/fortran.py7
-rw-r--r--mesonbuild/compilers/java.py15
-rw-r--r--mesonbuild/compilers/mixins/arm.py24
-rw-r--r--mesonbuild/compilers/mixins/ccrx.py12
-rw-r--r--mesonbuild/compilers/mixins/compcert.py14
-rw-r--r--mesonbuild/compilers/mixins/gnu.py12
-rw-r--r--mesonbuild/compilers/mixins/intel.py28
-rw-r--r--mesonbuild/compilers/mixins/islinker.py2
-rw-r--r--mesonbuild/compilers/mixins/metrowerks.py12
-rw-r--r--mesonbuild/compilers/mixins/pgi.py12
-rw-r--r--mesonbuild/compilers/mixins/ti.py12
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py3
-rw-r--r--mesonbuild/compilers/mixins/xc16.py12
-rw-r--r--mesonbuild/compilers/rust.py5
-rw-r--r--mesonbuild/compilers/swift.py5
-rw-r--r--mesonbuild/compilers/vala.py5
-rw-r--r--mesonbuild/linkers/linkers.py59
26 files changed, 108 insertions, 363 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index ac8fa9020..b28289e86 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -1001,11 +1001,6 @@ class Backend:
# command-line or default_options inside project().
commands += compiler.get_option_compile_args(copt_proxy)
- # Add buildtype args: optimization level, debugging, etc.
- buildtype = target.get_option(OptionKey('buildtype'))
- assert isinstance(buildtype, str), 'for mypy'
- commands += compiler.get_buildtype_args(buildtype)
-
optimization = target.get_option(OptionKey('optimization'))
assert isinstance(optimization, str), 'for mypy'
commands += compiler.get_optimization_args(optimization)
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index b4a312bb2..0fa4cc91f 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1444,7 +1444,6 @@ class NinjaBackend(backends.Backend):
return args, deps
def generate_cs_target(self, target: build.BuildTarget):
- buildtype = target.get_option(OptionKey('buildtype'))
fname = target.get_filename()
outname_rel = os.path.join(self.get_target_dir(target), fname)
src_list = target.get_sources()
@@ -1452,7 +1451,6 @@ class NinjaBackend(backends.Backend):
rel_srcs = [os.path.normpath(s.rel_to_builddir(self.build_to_src)) for s in src_list]
deps = []
commands = compiler.compiler_args(target.extra_args['cs'])
- commands += compiler.get_buildtype_args(buildtype)
commands += compiler.get_optimization_args(target.get_option(OptionKey('optimization')))
commands += compiler.get_debug_args(target.get_option(OptionKey('debug')))
if isinstance(target, build.Executable):
@@ -1495,7 +1493,6 @@ class NinjaBackend(backends.Backend):
def determine_single_java_compile_args(self, target, compiler):
args = []
- args += compiler.get_buildtype_args(target.get_option(OptionKey('buildtype')))
args += self.build.get_global_args(compiler, target.for_machine)
args += self.build.get_project_args(compiler, target.subproject, target.for_machine)
args += target.get_java_args()
@@ -1726,7 +1723,6 @@ class NinjaBackend(backends.Backend):
args: T.List[str] = []
args += cython.get_always_args()
- args += cython.get_buildtype_args(target.get_option(OptionKey('buildtype')))
args += cython.get_debug_args(target.get_option(OptionKey('debug')))
args += cython.get_optimization_args(target.get_option(OptionKey('optimization')))
args += cython.get_option_compile_args(target.get_options())
@@ -3358,7 +3354,7 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
# Add things like /NOLOGO; usually can't be overridden
commands += linker.get_linker_always_args()
# Add buildtype linker args: optimization level, etc.
- commands += linker.get_buildtype_linker_args(target.get_option(OptionKey('buildtype')))
+ commands += linker.get_optimization_link_args(target.get_option(OptionKey('optimization')))
# Add /DEBUG and the pdb filename when using MSVC
if target.get_option(OptionKey('debug')):
commands += self.get_link_debugfile_args(linker, target)
diff --git a/mesonbuild/backend/vs2010backend.py b/mesonbuild/backend/vs2010backend.py
index 30f499149..bcae160bf 100644
--- a/mesonbuild/backend/vs2010backend.py
+++ b/mesonbuild/backend/vs2010backend.py
@@ -1103,9 +1103,8 @@ class Vs2010Backend(backends.Backend):
return (target_args, file_args), (target_defines, file_defines), (target_inc_dirs, file_inc_dirs)
@staticmethod
- def get_build_args(compiler, buildtype: str, optimization_level: str, debug: bool, sanitize: str) -> T.List[str]:
- build_args = compiler.get_buildtype_args(buildtype)
- build_args += compiler.get_optimization_args(optimization_level)
+ def get_build_args(compiler, optimization_level: str, debug: bool, sanitize: str) -> T.List[str]:
+ build_args = compiler.get_optimization_args(optimization_level)
build_args += compiler.get_debug_args(debug)
build_args += compiler.sanitizer_compile_args(sanitize)
@@ -1267,7 +1266,7 @@ class Vs2010Backend(backends.Backend):
file_args
) -> None:
compiler = self._get_cl_compiler(target)
- buildtype_link_args = compiler.get_buildtype_linker_args(self.buildtype)
+ buildtype_link_args = compiler.get_optimization_link_args(self.optimization)
# Prefix to use to access the build root from the vcxproj dir
down = self.target_to_build_root(target)
@@ -1380,10 +1379,7 @@ class Vs2010Backend(backends.Backend):
# Linker options
link = ET.SubElement(compiles, 'Link')
extra_link_args = compiler.compiler_args()
- # FIXME: Can these buildtype linker args be added as tags in the
- # vcxproj file (similar to buildtype compiler args) instead of in
- # AdditionalOptions?
- extra_link_args += compiler.get_buildtype_linker_args(self.buildtype)
+ extra_link_args += compiler.get_optimization_link_args(self.optimization)
# Generate Debug info
if self.debug:
self.generate_debug_information(link)
@@ -1611,7 +1607,7 @@ class Vs2010Backend(backends.Backend):
gen_hdrs += custom_hdrs
compiler = self._get_cl_compiler(target)
- build_args = Vs2010Backend.get_build_args(compiler, self.buildtype, self.optimization, self.debug, self.sanitize)
+ build_args = Vs2010Backend.get_build_args(compiler, self.optimization, self.debug, self.sanitize)
assert isinstance(target, (build.Executable, build.SharedLibrary, build.StaticLibrary, build.SharedModule)), 'for mypy'
# Prefix to use to access the build root from the vcxproj dir
diff --git a/mesonbuild/compilers/asm.py b/mesonbuild/compilers/asm.py
index 09cf9e11e..d04fbd293 100644
--- a/mesonbuild/compilers/asm.py
+++ b/mesonbuild/compilers/asm.py
@@ -98,10 +98,6 @@ class NasmCompiler(Compiler):
if self.info.cpu_family not in {'x86', 'x86_64'}:
raise EnvironmentException(f'ASM compiler {self.id!r} does not support {self.info.cpu_family} CPU family')
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # FIXME: Not implemented
- return []
-
def get_pic_args(self) -> T.List[str]:
return []
@@ -185,10 +181,6 @@ class MasmCompiler(Compiler):
if self.info.cpu_family not in {'x86', 'x86_64'}:
raise EnvironmentException(f'ASM compiler {self.id!r} does not support {self.info.cpu_family} CPU family')
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # FIXME: Not implemented
- return []
-
def get_pic_args(self) -> T.List[str]:
return []
@@ -240,10 +232,6 @@ class MasmARMCompiler(Compiler):
if self.info.cpu_family not in {'arm', 'aarch64'}:
raise EnvironmentException(f'ASM compiler {self.id!r} does not support {self.info.cpu_family} CPU family')
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # FIXME: Not implemented
- return []
-
def get_pic_args(self) -> T.List[str]:
return []
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index cba530fd8..f1a2b7376 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -181,78 +181,6 @@ class CompileCheckMode(enum.Enum):
LINK = 'link'
-cuda_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': ['-g', '-G'],
- 'debugoptimized': ['-g', '-lineinfo'],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
-java_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': ['-g'],
- 'debugoptimized': ['-g'],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
-rust_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
-d_gdc_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': ['-finline-functions'],
- 'release': ['-finline-functions'],
- 'minsize': [],
- 'custom': [],
-}
-
-d_ldc_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': ['-enable-inlining', '-Hkeep-all-bodies'],
- 'release': ['-enable-inlining', '-Hkeep-all-bodies'],
- 'minsize': [],
- 'custom': [],
-}
-
-d_dmd_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': ['-inline'],
- 'release': ['-inline'],
- 'minsize': [],
- 'custom': [],
-}
-
-mono_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': ['-optimize+'],
- 'release': ['-optimize+'],
- 'minsize': [],
- 'custom': [],
-}
-
-swift_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
gnu_winlibs = ['-lkernel32', '-luser32', '-lgdi32', '-lwinspool', '-lshell32',
'-lole32', '-loleaut32', '-luuid', '-lcomdlg32', '-ladvapi32']
@@ -270,26 +198,12 @@ clike_optimization_args: T.Dict[str, T.List[str]] = {
's': ['-Os'],
}
-cuda_optimization_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- '0': [],
- 'g': ['-O0'],
- '1': ['-O1'],
- '2': ['-O2'],
- '3': ['-O3'],
- 's': ['-O3']
-}
-
-cuda_debug_args: T.Dict[bool, T.List[str]] = {
- False: [],
- True: ['-g']
-}
-
clike_debug_args: T.Dict[bool, T.List[str]] = {
False: [],
True: ['-g']
}
+
MSCRT_VALS = ['none', 'md', 'mdd', 'mt', 'mtd']
base_options: 'KeyedOptionDictType' = {
@@ -1070,11 +984,8 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
def bitcode_args(self) -> T.List[str]:
return self.linker.bitcode_args()
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- raise EnvironmentException(f'{self.id} does not implement get_buildtype_args')
-
- def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
- return self.linker.get_buildtype_args(buildtype)
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
+ return self.linker.get_optimization_link_args(optimization_level)
def get_soname_args(self, env: 'Environment', prefix: str, shlib_name: str,
suffix: str, soversion: str,
diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py
index 15672f709..3a6365f42 100644
--- a/mesonbuild/compilers/cs.py
+++ b/mesonbuild/compilers/cs.py
@@ -10,7 +10,7 @@ import typing as T
from ..mesonlib import EnvironmentException
from ..linkers import RSPFileSyntax
-from .compilers import Compiler, mono_buildtype_args
+from .compilers import Compiler
from .mixins.islinker import BasicLinkerIsCompilerMixin
if T.TYPE_CHECKING:
@@ -103,9 +103,6 @@ class CsCompiler(BasicLinkerIsCompilerMixin, Compiler):
def needs_static_linker(self) -> bool:
return False
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return mono_buildtype_args[buildtype]
-
def get_debug_args(self, is_debug: bool) -> T.List[str]:
return ['-debug'] if is_debug else []
@@ -129,16 +126,11 @@ class VisualStudioCsCompiler(CsCompiler):
id = 'csc'
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- res = mono_buildtype_args[buildtype]
- if not self.info.is_windows():
- tmp = []
- for flag in res:
- if flag == '-debug':
- flag = '-debug:portable'
- tmp.append(flag)
- res = tmp
- return res
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
+ if is_debug:
+ return ['-debug'] if self.info.is_windows() else ['-debug:portable']
+ else:
+ return []
def rsp_file_syntax(self) -> 'RSPFileSyntax':
return RSPFileSyntax.MSVC
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py
index 0d79947bb..969040ad9 100644
--- a/mesonbuild/compilers/cuda.py
+++ b/mesonbuild/compilers/cuda.py
@@ -14,8 +14,7 @@ from ..mesonlib import (
EnvironmentException, Popen_safe,
is_windows, LibType, OptionKey, version_compare,
)
-from .compilers import (Compiler, cuda_buildtype_args, cuda_optimization_args,
- cuda_debug_args)
+from .compilers import Compiler
if T.TYPE_CHECKING:
from .compilers import CompileCheckMode
@@ -29,6 +28,22 @@ if T.TYPE_CHECKING:
from ..programs import ExternalProgram
+cuda_optimization_args: T.Dict[str, T.List[str]] = {
+ 'plain': [],
+ '0': ['-G'],
+ 'g': ['-O0'],
+ '1': ['-O1'],
+ '2': ['-O2', '-lineinfo'],
+ '3': ['-O3'],
+ 's': ['-O3']
+}
+
+cuda_debug_args: T.Dict[bool, T.List[str]] = {
+ False: [],
+ True: ['-g']
+}
+
+
class _Phase(enum.Enum):
COMPILER = 'compiler'
@@ -692,12 +707,6 @@ class CudaCompiler(Compiler):
def get_warn_args(self, level: str) -> T.List[str]:
return self.warn_args[level]
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # nvcc doesn't support msvc's "Edit and Continue" PDB format; "downgrade" to
- # a regular PDB to avoid cl's warning to that effect (D9025 : overriding '/ZI' with '/Zi')
- host_args = ['/Zi' if arg == '/ZI' else arg for arg in self.host_compiler.get_buildtype_args(buildtype)]
- return cuda_buildtype_args[buildtype] + self._to_host_flags(host_args)
-
def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
if path == '':
path = '.'
@@ -712,8 +721,8 @@ class CudaCompiler(Compiler):
def get_depfile_suffix(self) -> str:
return 'd'
- def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
- return self._to_host_flags(self.host_compiler.get_buildtype_linker_args(buildtype), _Phase.LINKER)
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
+ return self._to_host_flags(self.host_compiler.get_optimization_link_args(optimization_level), _Phase.LINKER)
def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
rpath_paths: T.Tuple[str, ...], build_rpath: str,
diff --git a/mesonbuild/compilers/cython.py b/mesonbuild/compilers/cython.py
index 9bbfebeb0..a58b3a814 100644
--- a/mesonbuild/compilers/cython.py
+++ b/mesonbuild/compilers/cython.py
@@ -54,10 +54,6 @@ class CythonCompiler(Compiler):
if p.returncode != 0:
raise EnvironmentException(f'Cython compiler {self.id!r} cannot compile programs')
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # Cython doesn't implement this, but Meson requires an implementation
- return []
-
def get_pic_args(self) -> T.List[str]:
# We can lie here, it's fine
return []
diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py
index a44ab5db6..4a4144d45 100644
--- a/mesonbuild/compilers/d.py
+++ b/mesonbuild/compilers/d.py
@@ -18,9 +18,6 @@ from ..mesonlib import (
from . import compilers
from .compilers import (
- d_dmd_buildtype_args,
- d_gdc_buildtype_args,
- d_ldc_buildtype_args,
clike_debug_args,
Compiler,
CompileCheckMode,
@@ -67,8 +64,8 @@ ldc_optimization_args: T.Dict[str, T.List[str]] = {
'0': [],
'g': [],
'1': ['-O1'],
- '2': ['-O2'],
- '3': ['-O3'],
+ '2': ['-O2', '-enable-inlining', '-Hkeep-all-bodies'],
+ '3': ['-O3', '-enable-inlining', '-Hkeep-all-bodies'],
's': ['-Oz'],
}
@@ -77,11 +74,21 @@ dmd_optimization_args: T.Dict[str, T.List[str]] = {
'0': [],
'g': [],
'1': ['-O'],
- '2': ['-O'],
- '3': ['-O'],
+ '2': ['-O', '-inline'],
+ '3': ['-O', '-inline'],
's': ['-O'],
}
+gdc_optimization_args: T.Dict[str, T.List[str]] = {
+ 'plain': [],
+ '0': ['-O0'],
+ 'g': ['-Og'],
+ '1': ['-O1'],
+ '2': ['-O2', '-finline-functions'],
+ '3': ['-O3', '-finline-functions'],
+ 's': ['-Os'],
+}
+
class DmdLikeCompilerMixin(CompilerMixinBase):
@@ -161,8 +168,8 @@ class DmdLikeCompilerMixin(CompilerMixinBase):
return []
return ['-fPIC']
- def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
- if buildtype != 'plain':
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
+ if optimization_level != 'plain':
return self._get_target_arch_args()
return []
@@ -531,8 +538,8 @@ class DCompiler(Compiler):
return res
- def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
- if buildtype != 'plain':
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
+ if optimization_level != 'plain':
return self._get_target_arch_args()
return []
@@ -697,8 +704,8 @@ class GnuDCompiler(GnuCompiler, DCompiler):
def get_warn_args(self, level: str) -> T.List[str]:
return self.warn_args[level]
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return d_gdc_buildtype_args[buildtype]
+ def get_optimization_args(self, optimization_level: str) -> T.List[str]:
+ return gdc_optimization_args[optimization_level]
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str],
build_dir: str) -> T.List[str]:
@@ -764,11 +771,6 @@ class LLVMDCompiler(DmdLikeCompilerMixin, DCompiler):
return ['-wi']
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- if buildtype != 'plain':
- return self._get_target_arch_args() + d_ldc_buildtype_args[buildtype]
- return d_ldc_buildtype_args[buildtype]
-
def get_pic_args(self) -> T.List[str]:
return ['-relocation-model=pic']
@@ -779,6 +781,8 @@ class LLVMDCompiler(DmdLikeCompilerMixin, DCompiler):
return self._unix_args_to_native(args, self.info, self.linker.id)
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
+ if optimization_level != 'plain':
+ return self._get_target_arch_args() + ldc_optimization_args[optimization_level]
return ldc_optimization_args[optimization_level]
@classmethod
@@ -824,11 +828,6 @@ class DmdDCompiler(DmdLikeCompilerMixin, DCompiler):
return ['-color=on']
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- if buildtype != 'plain':
- return self._get_target_arch_args() + d_dmd_buildtype_args[buildtype]
- return d_dmd_buildtype_args[buildtype]
-
def get_std_exe_link_args(self) -> T.List[str]:
if self.info.is_windows():
# DMD links against D runtime only when main symbol is found,
@@ -870,6 +869,8 @@ class DmdDCompiler(DmdLikeCompilerMixin, DCompiler):
return self._unix_args_to_native(args, self.info, self.linker.id)
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
+ if optimization_level != 'plain':
+ return self._get_target_arch_args() + dmd_optimization_args[optimization_level]
return dmd_optimization_args[optimization_level]
def can_linker_accept_rsp(self) -> bool:
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index 4b4136e2f..d68c547e1 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -13,9 +13,7 @@ from .compilers import (
CompileCheckMode,
)
from .mixins.clike import CLikeCompiler
-from .mixins.gnu import (
- GnuCompiler, gnulike_buildtype_args, gnu_optimization_args
-)
+from .mixins.gnu import GnuCompiler, gnu_optimization_args
from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler
from .mixins.clang import ClangCompiler
from .mixins.elbrus import ElbrusCompiler
@@ -66,9 +64,6 @@ class FortranCompiler(CLikeCompiler, Compiler):
code = 'program main; print *, "Fortran compilation is working."; end program\n'
return self._sanity_check_impl(work_dir, environment, source_name, code)
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return gnulike_buildtype_args[buildtype]
-
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return gnu_optimization_args[optimization_level]
diff --git a/mesonbuild/compilers/java.py b/mesonbuild/compilers/java.py
index d063554eb..540e2aa78 100644
--- a/mesonbuild/compilers/java.py
+++ b/mesonbuild/compilers/java.py
@@ -11,7 +11,7 @@ import textwrap
import typing as T
from ..mesonlib import EnvironmentException
-from .compilers import Compiler, java_buildtype_args
+from .compilers import Compiler
from .mixins.islinker import BasicLinkerIsCompilerMixin
if T.TYPE_CHECKING:
@@ -19,6 +19,12 @@ if T.TYPE_CHECKING:
from ..environment import Environment
from ..mesonlib import MachineChoice
+
+java_debug_args: T.Dict[bool, T.List[str]] = {
+ False: ['-g:none'],
+ True: ['-g']
+}
+
class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):
language = 'java'
@@ -56,9 +62,6 @@ class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):
def get_pch_name(self, name: str) -> str:
return ''
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return java_buildtype_args[buildtype]
-
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str],
build_dir: str) -> T.List[str]:
for idx, i in enumerate(parameter_list):
@@ -107,6 +110,4 @@ class JavaCompiler(BasicLinkerIsCompilerMixin, Compiler):
return []
def get_debug_args(self, is_debug: bool) -> T.List[str]:
- if is_debug:
- return ['-g']
- return ['-g:none']
+ return java_debug_args[is_debug]
diff --git a/mesonbuild/compilers/mixins/arm.py b/mesonbuild/compilers/mixins/arm.py
index 06ca8d416..942156fab 100644
--- a/mesonbuild/compilers/mixins/arm.py
+++ b/mesonbuild/compilers/mixins/arm.py
@@ -24,15 +24,6 @@ else:
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
-arm_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
arm_optimization_args: T.Dict[str, T.List[str]] = {
'plain': [],
'0': ['-O0'],
@@ -43,15 +34,6 @@ arm_optimization_args: T.Dict[str, T.List[str]] = {
's': ['-O3'], # Compiler defaults to -Ospace
}
-armclang_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
armclang_optimization_args: T.Dict[str, T.List[str]] = {
'plain': [],
'0': [], # Compiler defaults to -O0
@@ -86,9 +68,6 @@ class ArmCompiler(Compiler):
# FIXME: Add /ropi, /rwpi, /fpic etc. qualifiers to --apcs
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return arm_buildtype_args[buildtype]
-
# Override CCompiler.get_always_args
def get_always_args(self) -> T.List[str]:
return []
@@ -162,9 +141,6 @@ class ArmclangCompiler(Compiler):
def get_colorout_args(self, colortype: str) -> T.List[str]:
return clang_color_args[colortype][:]
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return armclang_buildtype_args[buildtype]
-
def get_pch_suffix(self) -> str:
return 'gch'
diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py
index 45992bf75..63270726b 100644
--- a/mesonbuild/compilers/mixins/ccrx.py
+++ b/mesonbuild/compilers/mixins/ccrx.py
@@ -21,15 +21,6 @@ else:
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
-ccrx_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
ccrx_optimization_args: T.Dict[str, T.List[str]] = {
'0': ['-optimize=0'],
'g': ['-optimize=0'],
@@ -71,9 +62,6 @@ class CcrxCompiler(Compiler):
# if users want to use it, they need to add the required arguments explicitly
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return ccrx_buildtype_args[buildtype]
-
def get_pch_suffix(self) -> str:
return 'pch'
diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py
index 8b2ee1e7c..86d20a0d6 100644
--- a/mesonbuild/compilers/mixins/compcert.py
+++ b/mesonbuild/compilers/mixins/compcert.py
@@ -20,15 +20,6 @@ else:
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
-ccomp_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [''],
- 'debug': ['-O0', '-g'],
- 'debugoptimized': ['-O0', '-g'],
- 'release': ['-O3'],
- 'minsize': ['-Os'],
- 'custom': ['-Obranchless'],
-}
-
ccomp_optimization_args: T.Dict[str, T.List[str]] = {
'plain': [],
'0': ['-O0'],
@@ -41,7 +32,7 @@ ccomp_optimization_args: T.Dict[str, T.List[str]] = {
ccomp_debug_args: T.Dict[bool, T.List[str]] = {
False: [],
- True: ['-g']
+ True: ['-O0', '-g']
}
# As of CompCert 20.04, these arguments should be passed to the underlying gcc linker (via -WUl,<arg>)
@@ -74,9 +65,6 @@ class CompCertCompiler(Compiler):
# As of now, CompCert does not support PIC
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return ccomp_buildtype_args[buildtype]
-
def get_pch_suffix(self) -> str:
return 'pch'
diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py
index 95c6cecb1..9c0c3f290 100644
--- a/mesonbuild/compilers/mixins/gnu.py
+++ b/mesonbuild/compilers/mixins/gnu.py
@@ -37,15 +37,6 @@ clike_debug_args: T.Dict[bool, T.List[str]] = {
True: ['-g'],
}
-gnulike_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
gnu_optimization_args: T.Dict[str, T.List[str]] = {
'plain': [],
'0': ['-O0'],
@@ -390,9 +381,6 @@ class GnuLikeCompiler(Compiler, metaclass=abc.ABCMeta):
def get_pie_args(self) -> T.List[str]:
return ['-fPIE']
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return gnulike_buildtype_args[buildtype]
-
@abc.abstractmethod
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
pass
diff --git a/mesonbuild/compilers/mixins/intel.py b/mesonbuild/compilers/mixins/intel.py
index da0ab2133..d38a42ebb 100644
--- a/mesonbuild/compilers/mixins/intel.py
+++ b/mesonbuild/compilers/mixins/intel.py
@@ -40,13 +40,9 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
minsize: -O2
"""
- BUILD_ARGS: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': ["-g", "-traceback"],
- 'debugoptimized': ["-g", "-traceback"],
- 'release': [],
- 'minsize': [],
- 'custom': [],
+ DEBUG_ARGS: T.Dict[bool, T.List[str]] = {
+ False: [],
+ True: ['-g', '-traceback']
}
OPTIM_ARGS: T.Dict[str, T.List[str]] = {
@@ -105,8 +101,8 @@ class IntelGnuLikeCompiler(GnuLikeCompiler):
def get_profile_use_args(self) -> T.List[str]:
return ['-prof-use']
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return self.BUILD_ARGS[buildtype]
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
+ return self.DEBUG_ARGS[is_debug]
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return self.OPTIM_ARGS[optimization_level]
@@ -119,13 +115,9 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
"""Abstractions for ICL, the Intel compiler on Windows."""
- BUILD_ARGS: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': ["/Zi", "/traceback"],
- 'debugoptimized': ["/Zi", "/traceback"],
- 'release': [],
- 'minsize': [],
- 'custom': [],
+ DEBUG_ARGS: T.Dict[bool, T.List[str]] = {
+ False: [],
+ True: ['/Zi', '/traceback']
}
OPTIM_ARGS: T.Dict[str, T.List[str]] = {
@@ -165,8 +157,8 @@ class IntelVisualStudioLikeCompiler(VisualStudioLikeCompiler):
def openmp_flags(self) -> T.List[str]:
return ['/Qopenmp']
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return self.BUILD_ARGS[buildtype]
+ def get_debug_args(self, is_debug: bool) -> T.List[str]:
+ return self.DEBUG_ARGS[is_debug]
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return self.OPTIM_ARGS[optimization_level]
diff --git a/mesonbuild/compilers/mixins/islinker.py b/mesonbuild/compilers/mixins/islinker.py
index 05a74fab2..8d17a94b2 100644
--- a/mesonbuild/compilers/mixins/islinker.py
+++ b/mesonbuild/compilers/mixins/islinker.py
@@ -107,7 +107,7 @@ class BasicLinkerIsCompilerMixin(Compiler):
def get_asneeded_args(self) -> T.List[str]:
return []
- def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
return []
def get_link_debugfile_name(self, targetfile: str) -> T.Optional[str]:
diff --git a/mesonbuild/compilers/mixins/metrowerks.py b/mesonbuild/compilers/mixins/metrowerks.py
index 1d72afb45..4be27c5da 100644
--- a/mesonbuild/compilers/mixins/metrowerks.py
+++ b/mesonbuild/compilers/mixins/metrowerks.py
@@ -20,15 +20,6 @@ else:
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
-mwcc_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
mwccarm_instruction_set_args: T.Dict[str, T.List[str]] = {
'generic': ['-proc', 'generic'],
'v4': ['-proc', 'v4'],
@@ -203,9 +194,6 @@ class MetrowerksCompiler(Compiler):
def get_always_args(self) -> T.List[str]:
return ['-gccinc']
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return mwcc_buildtype_args[buildtype]
-
def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]:
return []
diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py
index 9f474f117..0d8245a21 100644
--- a/mesonbuild/compilers/mixins/pgi.py
+++ b/mesonbuild/compilers/mixins/pgi.py
@@ -22,15 +22,6 @@ else:
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
-pgi_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
class PGICompiler(Compiler):
@@ -63,9 +54,6 @@ class PGICompiler(Compiler):
def openmp_flags(self) -> T.List[str]:
return ['-mp']
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return pgi_buildtype_args[buildtype]
-
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
return clike_optimization_args[optimization_level]
diff --git a/mesonbuild/compilers/mixins/ti.py b/mesonbuild/compilers/mixins/ti.py
index 6d15b6bd2..93cc31ee8 100644
--- a/mesonbuild/compilers/mixins/ti.py
+++ b/mesonbuild/compilers/mixins/ti.py
@@ -21,15 +21,6 @@ else:
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
-ti_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
ti_optimization_args: T.Dict[str, T.List[str]] = {
'plain': [],
'0': ['-O0'],
@@ -70,9 +61,6 @@ class TICompiler(Compiler):
# if users want to use it, they need to add the required arguments explicitly
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return ti_buildtype_args[buildtype]
-
def get_pch_suffix(self) -> str:
return 'pch'
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index 20af8ceef..5dcebecef 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -178,9 +178,6 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
return ['/Fe' + outputname]
return ['/Fo' + outputname]
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return []
-
def get_debug_args(self, is_debug: bool) -> T.List[str]:
return msvc_debug_args[is_debug]
diff --git a/mesonbuild/compilers/mixins/xc16.py b/mesonbuild/compilers/mixins/xc16.py
index c1b3dba20..d95674e3e 100644
--- a/mesonbuild/compilers/mixins/xc16.py
+++ b/mesonbuild/compilers/mixins/xc16.py
@@ -21,15 +21,6 @@ else:
# do). This gives up DRYer type checking, with no runtime impact
Compiler = object
-xc16_buildtype_args: T.Dict[str, T.List[str]] = {
- 'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
-}
-
xc16_optimization_args: T.Dict[str, T.List[str]] = {
'plain': [],
'0': ['-O0'],
@@ -71,9 +62,6 @@ class Xc16Compiler(Compiler):
# if users want to use it, they need to add the required arguments explicitly
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return xc16_buildtype_args[buildtype]
-
def get_pch_suffix(self) -> str:
return 'pch'
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index f9929088f..e10cb4cf3 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -10,7 +10,7 @@ import typing as T
from .. import coredata
from ..mesonlib import EnvironmentException, MesonException, Popen_safe_logged, OptionKey
-from .compilers import Compiler, rust_buildtype_args, clike_debug_args
+from .compilers import Compiler, clike_debug_args
if T.TYPE_CHECKING:
from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType
@@ -113,9 +113,6 @@ class RustCompiler(Compiler):
def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
return ['--dep-info', outfile]
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return rust_buildtype_args[buildtype]
-
def get_sysroot(self) -> str:
cmd = self.get_exelist(ccache=False) + ['--print', 'sysroot']
p, stdo, stde = Popen_safe_logged(cmd)
diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py
index ccead3123..e200276e2 100644
--- a/mesonbuild/compilers/swift.py
+++ b/mesonbuild/compilers/swift.py
@@ -8,7 +8,7 @@ import typing as T
from ..mesonlib import EnvironmentException
-from .compilers import Compiler, swift_buildtype_args, clike_debug_args
+from .compilers import Compiler, clike_debug_args
if T.TYPE_CHECKING:
from ..envconfig import MachineInfo
@@ -64,9 +64,6 @@ class SwiftCompiler(Compiler):
def get_warn_args(self, level: str) -> T.List[str]:
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return swift_buildtype_args[buildtype]
-
def get_std_exe_link_args(self) -> T.List[str]:
return ['-emit-executable']
diff --git a/mesonbuild/compilers/vala.py b/mesonbuild/compilers/vala.py
index 07f467412..52097c94e 100644
--- a/mesonbuild/compilers/vala.py
+++ b/mesonbuild/compilers/vala.py
@@ -91,11 +91,6 @@ class ValaCompiler(Compiler):
msg = f'Vala compiler {self.name_string()!r} cannot compile programs'
raise EnvironmentException(msg)
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- if buildtype in {'debug', 'debugoptimized', 'minsize'}:
- return ['--debug']
- return []
-
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
if extra_dirs and isinstance(extra_dirs, str):
diff --git a/mesonbuild/linkers/linkers.py b/mesonbuild/linkers/linkers.py
index 0e181299b..e4db0157f 100644
--- a/mesonbuild/linkers/linkers.py
+++ b/mesonbuild/linkers/linkers.py
@@ -45,7 +45,7 @@ class StaticLinker:
def get_std_link_args(self, env: 'Environment', is_thin: bool) -> T.List[str]:
return []
- def get_buildtype_linker_args(self, buildtype: str) -> T.List[str]:
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
return []
def get_output_args(self, target: str) -> T.List[str]:
@@ -103,13 +103,14 @@ class DynamicLinker(metaclass=abc.ABCMeta):
"""Base class for dynamic linkers."""
- _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = {
+ _OPTIMIZATION_ARGS: T.Dict[str, T.List[str]] = {
'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': [],
- 'minsize': [],
- 'custom': [],
+ '0': [],
+ 'g': [],
+ '1': [],
+ '2': [],
+ '3': [],
+ 's': [],
}
@abc.abstractproperty
@@ -189,6 +190,11 @@ class DynamicLinker(metaclass=abc.ABCMeta):
"""
return []
+ def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
+ # We can override these in children by just overriding the
+ # _OPTIMIZATION_ARGS value.
+ return mesonlib.listify([self._apply_prefix(a) for a in self._OPTIMIZATION_ARGS[optimization_level]])
+
def get_std_shared_lib_args(self) -> T.List[str]:
return []
@@ -210,11 +216,6 @@ class DynamicLinker(metaclass=abc.ABCMeta):
def sanitizer_args(self, value: str) -> T.List[str]:
return []
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # We can override these in children by just overriding the
- # _BUILDTYPE_ARGS value.
- return self._BUILDTYPE_ARGS[buildtype]
-
def get_asneeded_args(self) -> T.List[str]:
return []
@@ -580,13 +581,14 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
for_machine = MachineChoice.HOST
def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]: ...
- _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = {
+ _OPTIMIZATION_ARGS: T.Dict[str, T.List[str]] = {
'plain': [],
- 'debug': [],
- 'debugoptimized': [],
- 'release': ['-O1'],
- 'minsize': [],
- 'custom': [],
+ '0': [],
+ 'g': [],
+ '1': [],
+ '2': [],
+ '3': ['-O1'],
+ 's': [],
}
_SUBSYSTEMS: T.Dict[str, str] = {
@@ -601,11 +603,6 @@ class GnuLikeDynamicLinkerMixin(DynamicLinkerBase):
"boot_application": "16",
}
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- # We can override these in children by just overriding the
- # _BUILDTYPE_ARGS value.
- return mesonlib.listify([self._apply_prefix(a) for a in self._BUILDTYPE_ARGS[buildtype]])
-
def get_pie_args(self) -> T.List[str]:
return ['-pie']
@@ -1231,15 +1228,16 @@ class VisualStudioLikeLinkerMixin(DynamicLinkerBase):
for_machine = MachineChoice.HOST
def _apply_prefix(self, arg: T.Union[str, T.List[str]]) -> T.List[str]: ...
- _BUILDTYPE_ARGS: T.Dict[str, T.List[str]] = {
+ _OPTIMIZATION_ARGS: T.Dict[str, T.List[str]] = {
'plain': [],
- 'debug': [],
- 'debugoptimized': [],
+ '0': [],
+ 'g': [],
+ '1': [],
+ '2': [],
# The otherwise implicit REF and ICF linker optimisations are disabled by
# /DEBUG. REF implies ICF.
- 'release': ['/OPT:REF'],
- 'minsize': ['/INCREMENTAL:NO', '/OPT:REF'],
- 'custom': [],
+ '3': ['/OPT:REF'],
+ 's': ['/INCREMENTAL:NO', '/OPT:REF'],
}
def __init__(self, exelist: T.List[str], for_machine: mesonlib.MachineChoice,
@@ -1250,9 +1248,6 @@ class VisualStudioLikeLinkerMixin(DynamicLinkerBase):
self.machine = machine
self.direct = direct
- def get_buildtype_args(self, buildtype: str) -> T.List[str]:
- return mesonlib.listify([self._apply_prefix(a) for a in self._BUILDTYPE_ARGS[buildtype]])
-
def invoked_by_compiler(self) -> bool:
return not self.direct