From 09cb9dc2b5417a2d45be7bcf430aa10c20974413 Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Thu, 25 Jun 2026 02:27:52 +0900 Subject: [PATCH 1/6] crossdev-stages: add musl rv32 support --- crossdev-stages/src/sandbox.rs | 9 +++++++-- crossdev-stages/src/stage.rs | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/crossdev-stages/src/sandbox.rs b/crossdev-stages/src/sandbox.rs index 0cd223d8..e379967c 100644 --- a/crossdev-stages/src/sandbox.rs +++ b/crossdev-stages/src/sandbox.rs @@ -395,11 +395,16 @@ impl Sandbox { } else { "" }; + // rustc has no upstream target for riscv32-unknown-linux-gnu; skip rust-std on rv32. + let rust_std_ex_pkg = if target_arch == "riscv32" { + "" + } else { + " --ex-pkg sys-devel/rust-std" + }; runner.run(&format!( "crossdev {chost} \ --gcc {gcc_ver} \ - --ex-pkg sys-devel/clang-crossdev-wrappers \ - --ex-pkg sys-devel/rust-std{grub_ex_pkg}" + --ex-pkg sys-devel/clang-crossdev-wrappers{rust_std_ex_pkg}{grub_ex_pkg}" ))?; // Switch cross compiler to the installed slot. diff --git a/crossdev-stages/src/stage.rs b/crossdev-stages/src/stage.rs index 38a0e9a9..5795fe18 100644 --- a/crossdev-stages/src/stage.rs +++ b/crossdev-stages/src/stage.rs @@ -25,9 +25,11 @@ pub fn gentoo_arch(arch: &str) -> Result<&'static str> { /// Return the full CHOST triple for a given arch. /// x86 32-bit uses the "pc" vendor (Gentoo convention); others use "unknown". +/// riscv32 uses musl libc (no Gentoo glibc rv32 stage3 exists). pub fn chost_for_arch(arch: &str) -> Result { let vendor = if is_ix86(arch) { "pc" } else { "unknown" }; - Ok(format!("{arch}-{vendor}-linux-gnu")) + let libc = if arch == "riscv32" { "musl" } else { "gnu" }; + Ok(format!("{arch}-{vendor}-linux-{libc}")) } fn is_ix86(arch: &str) -> bool { @@ -37,6 +39,7 @@ fn is_ix86(arch: &str) -> bool { /// Return the Gentoo profile path for an OS arch string. pub fn gentoo_profile(arch: &str) -> Result<&'static str> { Ok(match arch { + "riscv32" => "default/linux/riscv/23.0/rv32/ilp32/musl", a if a.starts_with("riscv") => "default/linux/riscv/23.0/rv64/lp64d", "x86_64" => "default/linux/amd64/23.0", "aarch64" => "default/linux/arm64/23.0", @@ -70,6 +73,7 @@ pub fn default_cflags(arch: &str) -> &'static str { "x86_64" => "-O3 -march=x86-64 -pipe", "aarch64" => "-O3 -pipe", "riscv64" => "-O3 -march=rv64gc -pipe", + "riscv32" => "-Os -march=rv32ima_zicsr_zifencei -mabi=ilp32 -mcmodel=medlow -pipe", _ => "-O3 -pipe", } } @@ -114,9 +118,12 @@ pub fn llvm_target(arch: &str) -> Option<&'static str> { } /// Return the stage3 variant name for `client.get()`. -/// For riscv64 this is "rv64_lp64d-openrc". +/// For riscv64 this is "rv64_lp64d-openrc"; for riscv32 (soft-float, musl) "rv32_ilp32_musl-openrc". +/// Note: Gentoo autobuilds may not publish an rv32 musl stage3; riscv32 boards bootstrap +/// from scratch and don't rely on `setup`. pub fn stage_variant(arch: &str) -> &'static str { match arch { + "riscv32" => "rv32_ilp32_musl-openrc", a if a.starts_with("riscv") => "rv64_lp64d-openrc", "aarch64" => "arm64-openrc", "x86_64" => "amd64-openrc", From d9c07a285312703a1feab53bce5dc8ec6799821c Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Thu, 25 Jun 2026 11:05:50 +0900 Subject: [PATCH 2/6] target: make musl rv32 stage1 actually work --- crossdev-stages/src/target.rs | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/crossdev-stages/src/target.rs b/crossdev-stages/src/target.rs index 0fbf63aa..b19062b7 100644 --- a/crossdev-stages/src/target.rs +++ b/crossdev-stages/src/target.rs @@ -98,17 +98,31 @@ impl Target { portage.cross_emerge_build(&chost, &["sys-apps/baselayout"])?; tracing::info!("Cross-emerging packages.build…"); - let packages = runner.run_output( + // rv32-musl: sys-apps/net-tools needs linux/rose.h which musl libc + // does not ship, and the rest of packages.build has never been + // cross-emerged for that profile. Drop net-tools (busybox provides + // the same utilities) and let the remaining set report failures + // instead of aborting the bootstrap on the first one. Every other + // arch keeps the strict behaviour: a packages.build failure there is + // a real regression, not an untested profile. + let (extra_filter, keep_going) = if self.arch == "riscv32" { + ("| grep -v 'sys-apps/net-tools'", " --keep-going") + } else { + ("", "") + }; + let packages = runner.run_output(&format!( "grep -v '^#' /var/db/repos/gentoo/profiles/default/linux/packages.build \ - | grep -v '^[[:space:]]*$' | tr '\\n' ' '", - )?; + | grep -v '^[[:space:]]*$' {extra_filter} | tr '\\n' ' '" + ))?; if packages.is_empty() { return Err(crate::error::Error::CommandFailed { code: 1, reason: "packages.build is empty or missing".into(), }); } - runner.run(&format!("ROOT=/target {chost}-emerge -b -k {packages}"))?; + runner.run(&format!( + "ROOT=/target {chost}-emerge -b -k{keep_going} {packages}" + ))?; tracing::info!("Cross-emerging portage…"); portage.cross_emerge_build(&chost, &["sys-apps/portage"])?; @@ -249,12 +263,12 @@ impl Target { } let src_link = src_portage.join("make.profile"); - if src_link.is_symlink() { + let dst_link = portage_dir.join("make.profile"); + // Only copy the profile symlink if the target doesn't already have one. + // The target may need a different profile flavour than the crossdev + // prefix (e.g. merged-usr target vs split-usr prefix on rv32-musl). + if src_link.is_symlink() && !dst_link.is_symlink() && !dst_link.exists() { let link_target = std::fs::read_link(&src_link)?; - let dst_link = portage_dir.join("make.profile"); - if dst_link.exists() || dst_link.is_symlink() { - std::fs::remove_file(&dst_link)?; - } std::os::unix::fs::symlink(&link_target, &dst_link)?; } From f98e44dd7890a6b581c6d74399bc8039546f8392 Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Thu, 25 Jun 2026 11:06:51 +0900 Subject: [PATCH 3/6] cli: respect --arch when resolving fallback target --- crossdev-stages/src/cli/util.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crossdev-stages/src/cli/util.rs b/crossdev-stages/src/cli/util.rs index 3c7c1b05..2b646ac3 100644 --- a/crossdev-stages/src/cli/util.rs +++ b/crossdev-stages/src/cli/util.rs @@ -56,7 +56,15 @@ pub async fn ensure_target( defaults_root: &Utf8Path, mirror: Option<&str>, ) -> Result<(target::Target, sandbox::Sandbox)> { - let (tgt, resolved_arch) = match ws.resolve_target(target_name) { + // If --arch is given, filter targets by that arch so we don't fall back to + // the most-recently-modified target of a foreign arch. This entry point + // seeds a target from a stage3, so the provider it may adopt is Gentoo's. + let gentoo = crate::provider::RootfsProvider::Gentoo.name(); + let resolved = match arch_override { + Some(a) => ws.resolve_target_for_arch(target_name, a, gentoo), + None => ws.resolve_target(target_name), + }; + let (tgt, resolved_arch) = match resolved { Ok(td) => { let tgt = target::Target::open(td)?; let arch = arch_override From bcb942c75c5c8011dfaecaa8f76925e55c1af57c Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Sat, 27 Jun 2026 03:30:19 +0900 Subject: [PATCH 4/6] container: preserve /dev as empty dir in stage3 unpack/pack Co-Authored-By: Claude Opus 4.7 (1M context) --- crossdev-stages/src/container.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crossdev-stages/src/container.rs b/crossdev-stages/src/container.rs index bce590e9..f3be4a3f 100644 --- a/crossdev-stages/src/container.rs +++ b/crossdev-stages/src/container.rs @@ -414,12 +414,20 @@ pub fn unpack_tarball( container.uidmaps(&uid_maps()); container.gidmaps(&gid_maps()); + // Exclude /dev/* (contents) but keep the /dev/ directory itself: + // catalyst-built stage3 tarballs include /dev/console + /dev/null as + // real device nodes, which mknod() can't create inside a user- + // namespace container (CAP_MKNOD isn't granted). We need /dev/ to + // exist as an empty directory so the kernel's devtmpfs auto-mount + // (CONFIG_DEVTMPFS_MOUNT=y) has a mountpoint to attach to — without + // it, VFS mounts root but / has no /dev/console and PID 1 can't open + // stdio. `./dev/*` matches the contents but not the directory. let cmd = format!( "mkdir -p {dest} && \ tar --overwrite -xpf {stage} \ --xattrs-include='*.*' \ --numeric-owner \ - --exclude='./dev' \ + --exclude='./dev/*' \ -C {dest}", stage = stage_in_container, dest = dest_in_container, @@ -462,10 +470,14 @@ pub fn pack_tarball( _ => "-J", // xz }; + // Exclude *contents* of runtime mountpoint dirs but keep the dirs + // themselves — mirrors catalyst stage3 layout (empty /dev /proc /sys + // /run /tmp with the dirs present as mountpoints). See + // unpack_tarball above for why /dev needs to be a real directory. let cmd = format!( "tar -cp{compress} --xattrs --xattrs-include='*.*' --numeric-owner \ - --exclude='./dev' --exclude='./proc' --exclude='./sys' \ - --exclude='./run' --exclude='./tmp' \ + --exclude='./dev/*' --exclude='./proc/*' --exclude='./sys/*' \ + --exclude='./run/*' --exclude='./tmp/*' \ -f {tarball} -C {src} .", compress = compress_flag, tarball = tarball_in_container, From 8ce2c27788535a5d2b96ca208862298be06fa2d9 Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Sat, 27 Jun 2026 03:30:19 +0900 Subject: [PATCH 5/6] portage: shell-quote every emerge atom against bash globbing --- crossdev-stages/src/portage.rs | 19 +++++++++++++++---- crossdev-stages/src/target.rs | 7 +++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/crossdev-stages/src/portage.rs b/crossdev-stages/src/portage.rs index 3688bd17..c635bd93 100644 --- a/crossdev-stages/src/portage.rs +++ b/crossdev-stages/src/portage.rs @@ -4,6 +4,17 @@ use crate::container::SandboxRunner; use crate::error::Result; use crate::stage::{all_llvm_targets, default_cflags, gentoo_arch, llvm_target}; +/// Single-quote each atom so portage-style operators (`>=`, `<`, `=`) and +/// SLOT colons survive bash interpretation when the atom list is spliced +/// into a `format!`'d shell command. Atoms never contain single quotes. +fn shell_quote_atoms(atoms: &[&str]) -> String { + atoms + .iter() + .map(|a| format!("'{a}'")) + .collect::>() + .join(" ") +} + /// Single supported llvm slot; dev-lang/rust-1.95.0 has `LLVM_COMPAT=( 22 )`. pub const LLVM_SLOT: &str = "22"; @@ -297,7 +308,7 @@ impl<'a> Portage<'a> { /// `--changed-use` so a board's `sandbox-packages.use` also applies to /// packages that are already installed with different flags. pub fn emerge(&self, packages: &[&str]) -> Result<()> { - let pkgs = packages.join(" "); + let pkgs = shell_quote_atoms(packages); self.run_emerge(&format!("emerge -b -k --changed-use {pkgs}")) } @@ -332,13 +343,13 @@ impl<'a> Portage<'a> { /// Cross-emerge packages into the target stage (mounted at `/target`). /// Uses `{chost}-emerge` which crossdev installs. pub fn cross_emerge(&self, chost: &str, packages: &[&str]) -> Result<()> { - let pkgs = packages.join(" "); + let pkgs = shell_quote_atoms(packages); self.run_emerge(&format!("ROOT=/target {chost}-emerge -b -k {pkgs}")) } /// Cross-emerge with `USE=build` for bootstrapping (baselayout, portage). pub fn cross_emerge_build(&self, chost: &str, packages: &[&str]) -> Result<()> { - let pkgs = packages.join(" "); + let pkgs = shell_quote_atoms(packages); self.run_emerge(&format!( "USE=build ROOT=/target {chost}-emerge -b -k {pkgs}" )) @@ -348,7 +359,7 @@ impl<'a> Portage<'a> { /// the crossdev prefix (`/usr/{chost}`) rather than `/target`. /// Used for updating the cross-toolchain itself (gcc, binutils-libs, @system). pub fn cross_emerge_crossdev(&self, chost: &str, packages: &[&str]) -> Result<()> { - let pkgs = packages.join(" "); + let pkgs = shell_quote_atoms(packages); self.run_emerge(&format!("{chost}-emerge -b -k {pkgs}")) } } diff --git a/crossdev-stages/src/target.rs b/crossdev-stages/src/target.rs index b19062b7..d60a6a77 100644 --- a/crossdev-stages/src/target.rs +++ b/crossdev-stages/src/target.rs @@ -155,10 +155,9 @@ impl Target { // package.mask/pin-gcc — which intentionally blocks upgrades past the // installed version to prevent bootstrap breakage — does not abort the // run when gcc is already at the requested version. - // Single-quoted: the atom goes through `bash -c` and an unquoted - // `=sys-devel/gcc-15*` is subject to shell glob expansion - // (sandbox.rs quotes the identical atom in setup_crossdev). - let gcc_atom = format!("'=sys-devel/gcc-{gcc_spec}*'"); + // No manual quoting: cross_emerge_crossdev single-quotes every atom + // (shell_quote_atoms), which protects the `*` glob from `bash -c`. + let gcc_atom = format!("=sys-devel/gcc-{gcc_spec}*"); tracing::info!(gcc_atom = %gcc_atom, "Updating crossdev prefix: gcc, binutils-libs, @system…"); portage.cross_emerge_crossdev(&chost, &["--noreplace", &gcc_atom])?; portage.cross_emerge_crossdev(&chost, &["sys-libs/binutils-libs"])?; From f7069ab9da1b97fb8ef7e90b7373154e6d70705a Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Sat, 27 Jun 2026 03:30:35 +0900 Subject: [PATCH 6/6] target,image: merged-usr profile link, board package.provided --- crossdev-stages/src/image.rs | 77 ++++++++++++++++++++++++++-------- crossdev-stages/src/sandbox.rs | 4 +- crossdev-stages/src/target.rs | 70 ++++++++++++++++++++++++++++--- 3 files changed, 127 insertions(+), 24 deletions(-) diff --git a/crossdev-stages/src/image.rs b/crossdev-stages/src/image.rs index ba275466..1a463f31 100644 --- a/crossdev-stages/src/image.rs +++ b/crossdev-stages/src/image.rs @@ -11,6 +11,10 @@ use crate::sandbox::Sandbox; use crate::target::Target; use crate::workspace::Workspace; +/// Where `boards//` is bind-mounted read-only, so config the cross +/// prefix needs can be copied in from inside the container. +const BOARD_DIR_IN_CONTAINER: &str = "/.board-config"; + fn project_root(boards_root: &Utf8Path) -> Utf8PathBuf { boards_root.parent().unwrap_or(boards_root).to_path_buf() } @@ -432,32 +436,71 @@ fn default_deps( defaults_root: &Utf8Path, ) -> Result<()> { let board_dir = boards_root.join(&board.name); + + // Two portage config roots see a board's target packages: the cross + // prefix's, which `{chost}-emerge` reads (PORTAGE_CONFIGROOT=/usr/), + // and the target's, which portage reads once the image boots. Board + // portage config goes into both, so it does not depend on which one is in + // play. The cross prefix is an overlay mount, so its half is written + // through the runner: a host-side write into sandbox/usr/ lands + // under the mount, where nothing in the container can read it. + let cross_portage = format!("/usr/{}/etc/portage", board.chost()); + let target_portage = target.dir.join("etc/portage"); + let target_runner = sandbox + .runner_for_board(ws, &board.arch, board)? + .with_target(&target.dir) + .with_binpkgs(&board_binpkgs_dir(ws, board)?) + .with_extra_ro(&board_dir, BOARD_DIR_IN_CONTAINER); + + let board_patches = board_dir.join("portage-patches"); + if board_patches.is_dir() { + crate::sandbox::copy_tree(&board_patches, &target_portage.join("patches"))?; + target_runner.run(&format!( + "mkdir -p {cross_portage}/patches && \ + cp -a {BOARD_DIR_IN_CONTAINER}/portage-patches/. {cross_portage}/patches/" + ))?; + } + + // package.provided cuts a dep chain off at an atom that does not + // cross-build for the target: virtual/udev pulling in + // sys-apps/systemd-utils on rv32-musl, say. + let board_provided = board_dir.join("package.provided"); + if board_provided.is_file() { + let profile_dir = target_portage.join("profile"); + std::fs::create_dir_all(&profile_dir)?; + std::fs::copy(&board_provided, profile_dir.join("package.provided"))?; + target_runner.run(&format!( + "mkdir -p {cross_portage}/profile && \ + cp {BOARD_DIR_IN_CONTAINER}/package.provided \ + {cross_portage}/profile/package.provided" + ))?; + } + // Target packages: defaults UNION board extras MINUS board `-atom` lines. let target_pkgs = crate::package_list::merge( crate::package_list::read_required(&defaults_root.join("target-packages.txt"))?, crate::package_list::read_optional(&board_dir.join("target-packages.txt"))?, ); if !target_pkgs.is_empty() { + let board_use = board_dir.join("target-packages.use"); + crate::package_list::write_accept_keywords(&target_pkgs, &target_portage)?; + crate::package_list::write_package_use(&board_use, &target_portage)?; // The keyword a line asks for has to be written where the cross emerge - // will look for it: `{chost}-emerge` reads PORTAGE_CONFIGROOT= - // /usr/{chost}, not the sandbox's own /etc/portage. Without this a - // line like `sys-boot/syslinux **` gets its atom emerged and its - // keyword silently dropped, and the emerge fails on a masked package. - let target_runner = sandbox - .runner_for_board(ws, &board.arch, board)? - .with_target(&target.dir) - .with_binpkgs(&board_binpkgs_dir(ws, board)?); - // Written through the runner, not on the host: /usr/ is an - // overlay mount and a host-side write lands under it, where nothing in - // the container can read it. This is where `{chost}-emerge` looks - // (PORTAGE_CONFIGROOT=/usr/), so a line like - // `sys-boot/syslinux **` gets its keyword here or nowhere. - if let Some(script) = crate::package_list::accept_keywords_script( - &target_pkgs, - &format!("/usr/{}/etc/portage", board.chost()), - ) { + // will look for it. Without this a line like `sys-boot/syslinux **` + // gets its atom emerged and its keyword silently dropped, and the + // emerge fails on a masked package. + if let Some(script) = + crate::package_list::accept_keywords_script(&target_pkgs, &cross_portage) + { target_runner.run(&script)?; } + if board_use.is_file() { + target_runner.run(&format!( + "mkdir -p {cross_portage}/package.use && \ + cp {BOARD_DIR_IN_CONTAINER}/target-packages.use \ + {cross_portage}/package.use/board" + ))?; + } let portage = Portage::new(&target_runner); portage.cross_emerge(&board.chost(), &crate::package_list::atoms(&target_pkgs))?; diff --git a/crossdev-stages/src/sandbox.rs b/crossdev-stages/src/sandbox.rs index e379967c..9eeb467a 100644 --- a/crossdev-stages/src/sandbox.rs +++ b/crossdev-stages/src/sandbox.rs @@ -824,7 +824,7 @@ fn install_overlay( /// Recursively copy directory `src` into `dst`, overwriting files. /// Symlinks and other special entries are rejected. -fn copy_tree(src: &Utf8Path, dst: &Utf8Path) -> Result<()> { +pub(crate) fn copy_tree(src: &Utf8Path, dst: &Utf8Path) -> Result<()> { std::fs::create_dir_all(dst)?; for entry in std::fs::read_dir(src)? { let entry = entry?; @@ -841,7 +841,7 @@ fn copy_tree(src: &Utf8Path, dst: &Utf8Path) -> Result<()> { } else { return Err(Error::CommandFailed { code: 1, - reason: format!("unsupported entry in portage overlay (symlink?): {from}"), + reason: format!("unsupported entry in copied tree (symlink?): {from}"), }); } } diff --git a/crossdev-stages/src/target.rs b/crossdev-stages/src/target.rs index d60a6a77..f1653df1 100644 --- a/crossdev-stages/src/target.rs +++ b/crossdev-stages/src/target.rs @@ -263,12 +263,26 @@ impl Target { let src_link = src_portage.join("make.profile"); let dst_link = portage_dir.join("make.profile"); - // Only copy the profile symlink if the target doesn't already have one. - // The target may need a different profile flavour than the crossdev - // prefix (e.g. merged-usr target vs split-usr prefix on rv32-musl). - if src_link.is_symlink() && !dst_link.is_symlink() && !dst_link.exists() { + if src_link.is_symlink() { + // A real (non-symlink) /bin marks a deliberately split-usr + // target: keep whatever profile it has (copy verbatim only if + // none is set). Merged-usr and fresh (pre-baselayout) targets + // get the translated link, overwritten every time — a stale + // symlink in a re-bootstrapped target would silently use the + // wrong profile. + let split_usr_target = std::fs::symlink_metadata(self.dir.join("bin")) + .map(|m| !m.file_type().is_symlink()) + .unwrap_or(false); let link_target = std::fs::read_link(&src_link)?; - std::os::unix::fs::symlink(&link_target, &dst_link)?; + let translated = translate_profile_link(&link_target, split_usr_target); + if split_usr_target { + if !dst_link.is_symlink() && !dst_link.exists() { + std::os::unix::fs::symlink(&translated, &dst_link)?; + } + } else { + let _ = std::fs::remove_file(&dst_link); + std::os::unix::fs::symlink(&translated, &dst_link)?; + } } Ok(()) @@ -293,6 +307,20 @@ fn guard_provider(dir: &camino::Utf8Path, name: &str, provider: &str) -> Result< Ok(()) } +/// Profile symlink to plant in the target, derived from the crossdev +/// prefix's link. Crossdev prefixes use split-usr profiles (the prefix +/// layout mandates it — /usr/{chost}/lib is a sibling of /usr/{chost}/ +/// usr/lib); a merged-usr target must drop the `split-usr` segment or +/// baselayout creates /bin as a real dir and every subsequent emerge +/// collides. A split-usr target keeps the link verbatim. +fn translate_profile_link(link: &std::path::Path, split_usr_target: bool) -> std::path::PathBuf { + if split_usr_target { + link.to_path_buf() + } else { + link.to_string_lossy().replace("/split-usr/", "/").into() + } +} + /// Remove a target directory (via hakoniwa to handle root-owned files). pub fn destroy(ws: &Workspace, name: &str) -> Result<()> { let dir = ws.target(name); @@ -333,3 +361,35 @@ pub struct TargetInfo { pub stage1: bool, pub updated: Option, } + +#[cfg(test)] +mod tests { + use super::translate_profile_link; + use std::path::Path; + + #[test] + fn profile_link_drops_split_usr_for_merged_target() { + let link = Path::new( + "../../var/db/repos/gentoo/profiles/default/linux/riscv/23.0/split-usr/rv32/ilp32/musl", + ); + assert_eq!( + translate_profile_link(link, false), + Path::new("../../var/db/repos/gentoo/profiles/default/linux/riscv/23.0/rv32/ilp32/musl") + ); + } + + #[test] + fn profile_link_kept_verbatim_for_split_usr_target() { + let link = Path::new( + "../../var/db/repos/gentoo/profiles/default/linux/riscv/23.0/split-usr/rv32/ilp32/musl", + ); + assert_eq!(translate_profile_link(link, true), link); + } + + #[test] + fn profile_link_without_split_usr_segment_is_unchanged() { + let link = + Path::new("../../var/db/repos/gentoo/profiles/default/linux/riscv/23.0/rv64/lp64d"); + assert_eq!(translate_profile_link(link, false), link); + } +}