Skip to content

Commit d8bcd04

Browse files
chromium: Depend on libstd-rs instead of rust (#809)
chromium: Depend on libstd-rs instead of rust Fixes #792. Build and patch changes: ------------------------ In #782, we decided to depend on rust instead of libstd-rs, because the latter didn't include libprofiler_builtins and also used a naming scheme that trips up Chromium. However, in #791 we decided to patch Chromium so that it doesn't need libprofiler_builtins any more, because the master version of the rust recipe also doesn't include it. Finally, while investigating #792 it turned out that our approach breaks as soon as we have something that depends on libstd-rs in our dependency graph. In that scenario, both libstd-rs and rust (the latter due to our bbappend file) install Rust libraries to /usr/lib/rustlib. This first leads to Chromium build system errors (due to libstd-rs's naming scheme), and after fixing these to Rust compiler errors due to multiple versions being present. The conclusion is now that we can depend on libstd-rs we should do so. This only requires a small change to Chromium's Rust build scripts to adapt them to the slightly different naming scheme. Also, while we're already reworking our Rust setup, we can remove the remaining part of our bbappend for the rust recipe and instead inherit the `rust-common` class, thereby inheriting `rust-target-config` (which needs stuff from `rust-common`). This means we get the `target.json` files the Rust compiler needs installed in the directory pointed to by the `RUST_TARGET_PATH` environment variable. License changes: ---------------- Added licenses: none. Removed licenses: none. Updated licenses: none. Test-built: ----------- * chromium-wayland: - nanbield, clang, MACHINE=qemuarm64 * chromium-x11: - master, clang, MACHINE=qemuarm Signed-off-by: Max Ihlenfeldt <[email protected]>
1 parent 24b4cdf commit d8bcd04

File tree

3 files changed

+26
-35
lines changed

3 files changed

+26
-35
lines changed

meta-chromium/recipes-browser/chromium/chromium-gn.inc

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ require gn-utils.inc
44

55
GTKIC_VERSION = "${@bb.utils.contains('PACKAGECONFIG', 'gtk4', '4', '3',d)}"
66

7-
inherit features_check gtk-icon-cache qemu
7+
inherit features_check gtk-icon-cache qemu rust-common
88

99
# The actual directory name in out/ is irrelevant for GN.
1010
OUTPUT_DIR = "out/Release"
@@ -73,6 +73,7 @@ DEPENDS += " \
7373
jpeg \
7474
libdrm \
7575
libffi \
76+
libstd-rs \
7677
libwebp \
7778
libxkbcommon \
7879
libxslt \
@@ -87,7 +88,6 @@ DEPENDS += " \
8788
pkgconfig-native \
8889
${@bb.utils.contains('DISTRO_FEATURES', 'pulseaudio', 'pulseaudio', '', d)} \
8990
qemu-native \
90-
rust \
9191
rust-native \
9292
virtual/libgl \
9393
"

meta-chromium/recipes-browser/chromium/files/0009-Adjust-the-Rust-build-to-our-needs.patch

+24-7
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Signed-off-by: Max Ihlenfeldt <[email protected]>
1919
build/config/rust.gni | 24 +++++++++++++++++------
2020
build/rust/rustc_wrapper.py | 1 +
2121
build/rust/std/BUILD.gn | 33 ++++++++++++++++++++++++--------
22-
build/rust/std/find_std_rlibs.py | 13 ++++++++++---
23-
4 files changed, 54 insertions(+), 17 deletions(-)
22+
build/rust/std/find_std_rlibs.py | 16 +++++++++++-----
23+
4 files changed, 55 insertions(+), 19 deletions(-)
2424

2525
diff --git a/build/config/rust.gni b/build/config/rust.gni
2626
index e98d913..6213b72 100644
@@ -166,9 +166,18 @@ index 77f4b8c..8a25798 100644
166166
# The host builds tools toolchain supports Rust only and does not use
167167
# the allocator remapping to point it to PartitionAlloc.
168168
diff --git a/build/rust/std/find_std_rlibs.py b/build/rust/std/find_std_rlibs.py
169-
index 386258f..25fdedc 100755
169+
index 386258f..3bb6a41 100755
170170
--- a/build/rust/std/find_std_rlibs.py
171171
+++ b/build/rust/std/find_std_rlibs.py
172+
@@ -17,7 +17,7 @@ import re
173+
from collections import defaultdict
174+
175+
EXPECTED_STDLIB_INPUT_REGEX = re.compile(r"([0-9a-z_]+)(?:-([0-9]+))?$")
176+
-RLIB_NAME_REGEX = re.compile(r"lib([0-9a-z_]+)-([0-9a-f]+)\.rlib$")
177+
+RLIB_NAME_REGEX = re.compile(r"lib([0-9a-z_]+)(-([0-9a-f]+))?\.rlib$")
178+
179+
180+
def main():
172181
@@ -52,6 +52,8 @@ def main():
173182
rustc_args.extend(["--target", args.target])
174183
rustlib_dir = subprocess.check_output(rustc_args).rstrip().decode()
@@ -187,7 +196,16 @@ index 386258f..25fdedc 100755
187196

188197
def copy_file(infile, outfile):
189198
depfile.write(f" {infile}")
190-
@@ -117,14 +119,19 @@ def main():
199+
@@ -99,7 +101,7 @@ def main():
200+
# the correct file path to our linker invocations, we don't need
201+
# that, and it would prevent us having the predictable filenames
202+
# which we need for statically computable gn dependency rules.
203+
- (crate_name, metadata) = RLIB_NAME_REGEX.match(f).group(1, 2)
204+
+ (crate_name, metadata) = RLIB_NAME_REGEX.match(f).group(1, 3)
205+
206+
# Use the number of times we've seen this name to disambiguate the output
207+
# filenames. Since we sort the input filenames including the metadata,
208+
@@ -117,14 +119,18 @@ def main():
191209
output_filename = f"lib{concise_name}.rlib"
192210

193211
infile = os.path.join(rustlib_dir, f)
@@ -201,9 +219,8 @@ index 386258f..25fdedc 100755
201219
+ outfile = os.path.join(lib_output_dir, f)
202220
copy_file(infile, outfile)
203221

204-
+ f = 'target.json'
205-
+ infile = os.path.join(rustlib_dir, '..', f)
206-
+ outfile = os.path.join(args.output, f)
222+
+ infile = os.path.join(os.environ['RUST_TARGET_PATH'], f'{args.target}.json')
223+
+ outfile = os.path.join(args.output, 'target.json')
207224
+ copy_file(infile, outfile)
208225
+
209226
depfile.write("\n")

meta-chromium/recipes-browser/chromium/rust_%.bbappend

-26
This file was deleted.

0 commit comments

Comments
 (0)