From 6c480085d5c80815a4c514c1406f1289a05acbb1 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 7 Jun 2023 10:11:47 -0400 Subject: rust: PIC is always enabled rustc enables PIC by default and Meson currently has no way to force disabling PIC, it can only force enable or use compiler's default. --- mesonbuild/build.py | 4 ++++ mesonbuild/compilers/rust.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'mesonbuild') diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 7b23a1d..7254f75 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -762,6 +762,10 @@ class BuildTarget(Target): raise MesonException('cannot mix structured sources and unstructured sources') if self.structured_sources and 'rust' not in self.compilers: raise MesonException('structured sources are only supported in Rust targets') + if self.uses_rust(): + # relocation-model=pic is rustc's default and Meson does not + # currently have a way to disable PIC. + self.pic = True def __repr__(self): repr_str = "<{0} {1}: {2}>" diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index 450f657..4fc3a49 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -207,8 +207,8 @@ class RustCompiler(Compiler): return self._WARNING_LEVELS["0"] def get_pic_args(self) -> T.List[str]: - # This defaults to - return ['-C', 'relocation-model=pic'] + # relocation-model=pic is rustc's default already. + return [] def get_pie_args(self) -> T.List[str]: # Rustc currently has no way to toggle this, it's controlled by whether -- cgit v1.1