diff options
author | Echo J. | 2023-12-21 23:14:16 +0200 |
---|---|---|
committer | Echo J. | 2023-12-21 23:14:16 +0200 |
commit | 75f808e40a77f47536f162d0d50156ad90efecf7 (patch) | |
tree | 74eaa91be043e0203c92ccfced5ee3de9b84e664 | |
parent | 5722834754499b6c28ec5f611c6b57557d30f86d (diff) | |
download | aur-75f808e40a77f47536f162d0d50156ad90efecf7.tar.gz |
Add a rustc recompile patch
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | PKGBUILD | 14 | ||||
-rw-r--r-- | rustc-rebuild.patch | 127 |
3 files changed, 142 insertions, 3 deletions
@@ -1,7 +1,7 @@ pkgbase = meson-rust pkgdesc = High productivity build system (version with improved Rust support) pkgver = 1.3.0 - pkgrel = 1 + pkgrel = 2 url = https://mesonbuild.com/ arch = any license = Apache @@ -21,6 +21,7 @@ pkgbase = meson-rust source = arch-meson source = cross-lib32 source = native-clang + source = rustc-rebuild.patch validpgpkeys = 19E2D6D9B46D8DAA6288F877C24E631BABB1FE70 b2sums = cb9ac8e00fe924df67166938687584a9de35e784e1e52bff281649d787695d37e3044ea3d6d5869181fe1e9676b5136548293dbd5cdbd091a6de0c449b8932f5 b2sums = SKIP @@ -29,5 +30,6 @@ pkgbase = meson-rust b2sums = 211cee61f117fd1d582d7a613a8634f044e9e307791c4154c6da72bccd5f06856801b14bcb26157ee682b5935c48ffd2098a5fabab2232726d7758cf091c07f7 b2sums = 9b16477aa77a706492e26fb3ad42e90674b8f0dfe657dd3bd9ba044f921be12ceabeb0050a50a15caee4d999e1ec33ed857bd3bed9e4444d73bb4a4f06381081 b2sums = 7d88929d5a3b49d91c5c9969f19d9b47f3151706526b889515acaeda0141257d5115875ac84832e9ea46f83a7700d673adcc5db84b331cd798c70ae6e90eac1e + b2sums = 1cf2521f6ebfdbedf1c58c09abfc0f77fcc0d59d903cca6634443d11cb5998cf51c3bfa61c6b17dca98a87f32c12e59558d6da25c57d8b341ae4c266ecd8857a pkgname = meson-rust @@ -6,7 +6,7 @@ _pkgname=meson pkgname=meson-rust pkgver=1.3.0 -pkgrel=1 +pkgrel=2 pkgdesc="High productivity build system (version with improved Rust support)" url="https://mesonbuild.com/" arch=(any) @@ -31,6 +31,7 @@ source=( arch-meson cross-lib32 native-clang + rustc-rebuild.patch ) b2sums=('cb9ac8e00fe924df67166938687584a9de35e784e1e52bff281649d787695d37e3044ea3d6d5869181fe1e9676b5136548293dbd5cdbd091a6de0c449b8932f5' 'SKIP' @@ -38,11 +39,20 @@ b2sums=('cb9ac8e00fe924df67166938687584a9de35e784e1e52bff281649d787695d37e3044ea 'f50c3569c6330e8671c402953247fb456505dd75555c8fbf1487bd43881dcdc766d88348814a6c2bb631c571ad4c4efabb271b5a1e7f01748ae2d9a332b39330' '211cee61f117fd1d582d7a613a8634f044e9e307791c4154c6da72bccd5f06856801b14bcb26157ee682b5935c48ffd2098a5fabab2232726d7758cf091c07f7' '9b16477aa77a706492e26fb3ad42e90674b8f0dfe657dd3bd9ba044f921be12ceabeb0050a50a15caee4d999e1ec33ed857bd3bed9e4444d73bb4a4f06381081' - '7d88929d5a3b49d91c5c9969f19d9b47f3151706526b889515acaeda0141257d5115875ac84832e9ea46f83a7700d673adcc5db84b331cd798c70ae6e90eac1e') + '7d88929d5a3b49d91c5c9969f19d9b47f3151706526b889515acaeda0141257d5115875ac84832e9ea46f83a7700d673adcc5db84b331cd798c70ae6e90eac1e' + '1cf2521f6ebfdbedf1c58c09abfc0f77fcc0d59d903cca6634443d11cb5998cf51c3bfa61c6b17dca98a87f32c12e59558d6da25c57d8b341ae4c266ecd8857a') validpgpkeys=( 19E2D6D9B46D8DAA6288F877C24E631BABB1FE70 # Jussi Pakkanen <jpakkane@gmail.com> ) +prepare() { + cd ${_pkgname}-${pkgver} + + # Rebuild targets after a rustc update (https://github.com/mesonbuild/meson/pull/12536) + # (this should fix Rust project compile issues after a compiler update) + patch -Np1 -i ../rustc-rebuild.patch +} + build() { cd ${_pkgname}-${pkgver} python -m build --wheel --no-isolation diff --git a/rustc-rebuild.patch b/rustc-rebuild.patch new file mode 100644 index 000000000000..e04d32fee135 --- /dev/null +++ b/rustc-rebuild.patch @@ -0,0 +1,127 @@ +From 0bcffa60b550b563818c8178e8fad127c2fe4b56 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Wed, 22 Nov 2023 07:41:59 -0500 +Subject: [PATCH 1/3] rust: Cache sysroot value as it's called multiple times + +--- + mesonbuild/compilers/rust.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py +index 1fb94aa4447a..f8d5e2939bba 100644 +--- a/mesonbuild/compilers/rust.py ++++ b/mesonbuild/compilers/rust.py +@@ -18,6 +18,8 @@ + import re + import typing as T + ++from functools import lru_cache ++ + from .. import coredata + from ..mesonlib import EnvironmentException, MesonException, Popen_safe_logged, OptionKey + from .compilers import Compiler, rust_buildtype_args, clike_debug_args +@@ -126,6 +128,7 @@ def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]: + def get_buildtype_args(self, buildtype: str) -> T.List[str]: + return rust_buildtype_args[buildtype] + ++ @lru_cache(maxsize=None) + def get_sysroot(self) -> str: + cmd = self.get_exelist(ccache=False) + ['--print', 'sysroot'] + p, stdo, stde = Popen_safe_logged(cmd) + +From b2943dee5e88421a74c46cfe67f78fad3552cb10 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Wed, 22 Nov 2023 08:05:04 -0500 +Subject: [PATCH 2/3] compilers: Trigger reconfigure when compiler exe changes + +When the compiler has been updated we need to trigger a reconfigure +because any compiler checks result could have changed. + +In the case the compiler is a wrapper script we cannot detect when the +real compiler changed, but this is better than nothing and we should +reconfigure when the wrapper itself changed as well anyway. +--- + mesonbuild/compilers/compilers.py | 3 +++ + mesonbuild/interpreter/interpreter.py | 1 + + 2 files changed, 4 insertions(+) + +diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py +index a7bb6c417932..afc223b1f4ae 100644 +--- a/mesonbuild/compilers/compilers.py ++++ b/mesonbuild/compilers/compilers.py +@@ -631,6 +631,9 @@ def get_exelist(self, ccache: bool = True) -> T.List[str]: + def get_linker_exelist(self) -> T.List[str]: + return self.linker.get_exelist() if self.linker else self.get_exelist() + ++ def get_exe_file(self) -> str: ++ return os.path.realpath(self.exelist_no_ccache[0]) ++ + @abc.abstractmethod + def get_output_args(self, outputname: str) -> T.List[str]: + pass +diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py +index e885010b23a1..b339c5157711 100644 +--- a/mesonbuild/interpreter/interpreter.py ++++ b/mesonbuild/interpreter/interpreter.py +@@ -1519,6 +1519,7 @@ def add_languages_for(self, args: T.List[str], required: bool, for_machine: Mach + comp = compilers.detect_compiler_for(self.environment, lang, for_machine, skip_sanity_check) + if comp is None: + raise InvalidArguments(f'Tried to use unknown language "{lang}".') ++ self.add_build_def_file(comp.get_exe_file()) + except mesonlib.MesonException: + if not required: + mlog.log('Compiler for language', + +From 73257b0778de67890d9c619be138ab2f8e6c3ec5 Mon Sep 17 00:00:00 2001 +From: Xavier Claessens <xavier.claessens@collabora.com> +Date: Wed, 22 Nov 2023 08:12:05 -0500 +Subject: [PATCH 3/3] rust: Rebuild targets when compiler got updated + +rustc updates are usually incompatible and requires recompiling of all +targets. This adds the compiler exe as dependency of every rust +ninja targets. Also try to resolve the real rustc exe being used when +the toolchain is wrapped by rustup. + +Fixes: #10706 +--- + mesonbuild/backend/ninjabackend.py | 2 +- + mesonbuild/compilers/rust.py | 13 +++++++++++++ + 2 files changed, 14 insertions(+), 1 deletion(-) + +diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py +index 049ae253fe34..92b88f121bf9 100644 +--- a/mesonbuild/backend/ninjabackend.py ++++ b/mesonbuild/backend/ninjabackend.py +@@ -1877,7 +1877,7 @@ def generate_rust_target(self, target: build.BuildTarget) -> None: + self.generate_generator_list_rules(target) + + # dependencies need to cause a relink, they're not just for ordering +- deps: T.List[str] = [] ++ deps: T.List[str] = [rustc.get_exe_file()] + + # Dependencies for rust-project.json + project_deps: T.List[RustDep] = [] +diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py +index f8d5e2939bba..faa340814fb1 100644 +--- a/mesonbuild/compilers/rust.py ++++ b/mesonbuild/compilers/rust.py +@@ -81,6 +81,19 @@ def __init__(self, exelist: T.List[str], version: str, for_machine: MachineChoic + if 'link' in self.linker.id: + self.base_options.add(OptionKey('b_vscrt')) + self.native_static_libs: T.List[str] = [] ++ # Resolve the real rustc executable. When using rustup, "rustc" in PATH ++ # is a wrapper that won't change when updating the toolchain, which ++ # means ninja would not rebuild rust targets after "rustup update". That ++ # can cause build issues because different rustc versions are generally ++ # uncompatible. This also means that once a Meson project has been ++ # configured, changing the default toolchain with e.g. ++ # "rustup default nightly" won't have any effect. ++ sysroot = self.get_sysroot() ++ real_rustc = os.path.join(sysroot, 'bin', 'rustc') ++ if os.path.exists(real_rustc): ++ exelist = [real_rustc] + exelist[1:] ++ self.exelist = exelist ++ self.exelist_no_ccache = exelist + + def needs_static_linker(self) -> bool: + return False |