summaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/rust.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-01-13 17:48:46 +0100
committerEli Schwartz <eschwartz93@gmail.com>2025-03-09 18:06:14 -0400
commitf39637e1648060bddcdd4372983b8d9ca844caf9 (patch)
tree42e13df0b658b156d56f4ade48c38f543aad898e /mesonbuild/compilers/rust.py
parent52dd8815525113371d10413a7253a3f66eec8679 (diff)
downloadmeson-f39637e1648060bddcdd4372983b8d9ca844caf9.tar.gz
compilers/rust: implement has_argument checks
We're about to convert the `b_sanitize` option into a free-form array whose value gets verified via a compiler check. This conversion will also impact the Rust toolchain, which does not yet know to check for multiple arguments at once. Implement both `has_multi_arguments()` and `has_multi_link_arguments()` to prepare the code accordingly.
Diffstat (limited to 'mesonbuild/compilers/rust.py')
-rw-r--r--mesonbuild/compilers/rust.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py
index 475b7a402..011c28f1d 100644
--- a/mesonbuild/compilers/rust.py
+++ b/mesonbuild/compilers/rust.py
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2012-2022 The Meson development team
+# Copyright © 2023-2024 Intel Corporation
from __future__ import annotations
@@ -12,7 +13,7 @@ import typing as T
from .. import options
from ..mesonlib import EnvironmentException, MesonException, Popen_safe_logged
from ..options import OptionKey
-from .compilers import Compiler, clike_debug_args
+from .compilers import Compiler, CompileCheckMode, clike_debug_args
if T.TYPE_CHECKING:
from ..coredata import MutableKeyedOptionDictType
@@ -323,6 +324,12 @@ class RustCompiler(Compiler):
return exelist + args
+ def has_multi_arguments(self, args: T.List[str], env: Environment) -> T.Tuple[bool, bool]:
+ return self.compiles('fn main { std::process::exit(0) };\n', env, extra_args=args, mode=CompileCheckMode.COMPILE)
+
+ def has_multi_link_arguments(self, args: T.List[str], env: Environment) -> T.Tuple[bool, bool]:
+ args = self.linker.fatal_warnings() + args
+ return self.compiles('fn main { std::process::exit(0) };\n', env, extra_args=args, mode=CompileCheckMode.LINK)
class ClippyRustCompiler(RustCompiler):