Rename libmold to mold-elf and mold-arch-* to mold-elf-*

The crates.io name libmold is kept for a library for in-process
linking, which has to be a crate above the per-target crates that
instantiate the linker. The internal crates are named after the file
format they handle, so that the Mach-O linker's crates can be
mold-macho and mold-macho-*. Each target crate's directory is named
after the crate, as in arch/elf-x86_64/ for mold-elf-x86_64.
This commit is contained in:
Rui Ueyama committed 2026-10-07 16:32:34 +09:00
1 parent 2505c77baa
commit adff957a3d
84 files changed
+482 -480

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@ jobs:
! grep -q '^unavailable:' "$RUNNER_TEMP/test-inventory.txt"
# All workspace crates were built above. Avoid linking empty test binaries
# for the target crates and command.
- run: cargo test --locked -p libmold -p mold-tests -p mold --lib --test integration
- run: cargo test --locked -p mold-elf -p mold-tests -p mold --lib --test integration
- name: archive test results
uses: actions/upload-artifact@v7
if: failure()
+2 -2
View File
@@ -17,10 +17,10 @@ export MSAN_OPTIONS=halt_on_error=1
export CARGO_PROFILE_DEV_OPT_LEVEL=1
# Use instrumentable implementations instead of BLAKE3/Zstd assembly, and
# select libmold as well as mold so Cargo enables its dependency features.
# select mold-elf as well as mold so Cargo enables its dependency features.
args=(
--locked -Zbuild-std --target x86_64-unknown-linux-gnu
--package libmold --package mold --no-default-features
--package mold-elf --package mold --no-default-features
--features mold/system-allocator,mold/x86_64,blake3/pure,zstd/no_asm
--test integration
)
Generated
+86 -86
View File
@@ -185,31 +185,6 @@ version = "0.2.189"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
[[package]]
name = "libmold"
version = "3.0.0"
dependencies = [
"blake3",
"bstr",
"cc",
"cpp_demangle",
"crc32fast",
"flate2",
"getrandom",
"hashbrown",
"libc",
"libz-rs-sys",
"memchr",
"memmap2",
"portable-atomic",
"rayon",
"rustc-demangle",
"uuid",
"xxhash-rust",
"zlib-rs",
"zstd",
]
[[package]]
name = "libz-rs-sys"
version = "0.6.8"
@@ -238,169 +213,194 @@ dependencies = [
name = "mold"
version = "3.0.0"
dependencies = [
"libmold",
"mold-arch-arm32",
"mold-arch-arm32be",
"mold-arch-arm64",
"mold-arch-arm64be",
"mold-arch-i386",
"mold-arch-loongarch32",
"mold-arch-loongarch64",
"mold-arch-m68k",
"mold-arch-ppc32",
"mold-arch-ppc64v1",
"mold-arch-ppc64v2",
"mold-arch-riscv32",
"mold-arch-riscv32be",
"mold-arch-riscv64",
"mold-arch-riscv64be",
"mold-arch-s390x",
"mold-arch-sh4",
"mold-arch-sh4be",
"mold-arch-sparc64",
"mold-arch-x86_64",
"mold-elf",
"mold-elf-arm32",
"mold-elf-arm32be",
"mold-elf-arm64",
"mold-elf-arm64be",
"mold-elf-i386",
"mold-elf-loongarch32",
"mold-elf-loongarch64",
"mold-elf-m68k",
"mold-elf-ppc32",
"mold-elf-ppc64v1",
"mold-elf-ppc64v2",
"mold-elf-riscv32",
"mold-elf-riscv32be",
"mold-elf-riscv64",
"mold-elf-riscv64be",
"mold-elf-s390x",
"mold-elf-sh4",
"mold-elf-sh4be",
"mold-elf-sparc64",
"mold-elf-x86_64",
"mold-mimalloc",
"mold-tests",
]
[[package]]
name = "mold-arch-arm32"
name = "mold-elf"
version = "3.0.0"
dependencies = [
"libmold",
"blake3",
"bstr",
"cc",
"cpp_demangle",
"crc32fast",
"flate2",
"getrandom",
"hashbrown",
"libc",
"libz-rs-sys",
"memchr",
"memmap2",
"portable-atomic",
"rayon",
"rustc-demangle",
"uuid",
"xxhash-rust",
"zlib-rs",
"zstd",
]
[[package]]
name = "mold-arch-arm32be"
name = "mold-elf-arm32"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-arm64"
name = "mold-elf-arm32be"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-arm64be"
name = "mold-elf-arm64"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-i386"
name = "mold-elf-arm64be"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-loongarch32"
name = "mold-elf-i386"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-loongarch64"
name = "mold-elf-loongarch32"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-m68k"
name = "mold-elf-loongarch64"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-ppc32"
name = "mold-elf-m68k"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-ppc64v1"
name = "mold-elf-ppc32"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-ppc64v2"
name = "mold-elf-ppc64v1"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-riscv32"
name = "mold-elf-ppc64v2"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-riscv32be"
name = "mold-elf-riscv32"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-riscv64"
name = "mold-elf-riscv32be"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-riscv64be"
name = "mold-elf-riscv64"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-s390x"
name = "mold-elf-riscv64be"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-sh4"
name = "mold-elf-s390x"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-sh4be"
name = "mold-elf-sh4"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-sparc64"
name = "mold-elf-sh4be"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-arch-x86_64"
name = "mold-elf-sparc64"
version = "3.0.0"
dependencies = [
"libmold",
"mold-elf",
]
[[package]]
name = "mold-elf-x86_64"
version = "3.0.0"
dependencies = [
"mold-elf",
]
[[package]]
+21 -21
View File
@@ -18,27 +18,27 @@ repository = "https://github.com/rui314/mold"
# these versions equal to the workspace version above.
[workspace.dependencies]
libc = "0.2"
libmold = { path = "elf", version = "=3.0.0" }
mold-arch-x86_64 = { path = "arch/x86_64", version = "=3.0.0" }
mold-arch-i386 = { path = "arch/i386", version = "=3.0.0" }
mold-arch-arm32 = { path = "arch/arm32", version = "=3.0.0" }
mold-arch-arm32be = { path = "arch/arm32be", version = "=3.0.0" }
mold-arch-arm64 = { path = "arch/arm64", version = "=3.0.0" }
mold-arch-arm64be = { path = "arch/arm64be", version = "=3.0.0" }
mold-arch-riscv64 = { path = "arch/riscv64", version = "=3.0.0" }
mold-arch-riscv64be = { path = "arch/riscv64be", version = "=3.0.0" }
mold-arch-riscv32 = { path = "arch/riscv32", version = "=3.0.0" }
mold-arch-riscv32be = { path = "arch/riscv32be", version = "=3.0.0" }
mold-arch-ppc64v2 = { path = "arch/ppc64v2", version = "=3.0.0" }
mold-arch-ppc32 = { path = "arch/ppc32", version = "=3.0.0" }
mold-arch-ppc64v1 = { path = "arch/ppc64v1", version = "=3.0.0" }
mold-arch-s390x = { path = "arch/s390x", version = "=3.0.0" }
mold-arch-sparc64 = { path = "arch/sparc64", version = "=3.0.0" }
mold-arch-m68k = { path = "arch/m68k", version = "=3.0.0" }
mold-arch-sh4 = { path = "arch/sh4", version = "=3.0.0" }
mold-arch-sh4be = { path = "arch/sh4be", version = "=3.0.0" }
mold-arch-loongarch64 = { path = "arch/loongarch64", version = "=3.0.0" }
mold-arch-loongarch32 = { path = "arch/loongarch32", version = "=3.0.0" }
mold-elf = { path = "elf", version = "=3.0.0" }
mold-elf-x86_64 = { path = "arch/elf-x86_64", version = "=3.0.0" }
mold-elf-i386 = { path = "arch/elf-i386", version = "=3.0.0" }
mold-elf-arm32 = { path = "arch/elf-arm32", version = "=3.0.0" }
mold-elf-arm32be = { path = "arch/elf-arm32be", version = "=3.0.0" }
mold-elf-arm64 = { path = "arch/elf-arm64", version = "=3.0.0" }
mold-elf-arm64be = { path = "arch/elf-arm64be", version = "=3.0.0" }
mold-elf-riscv64 = { path = "arch/elf-riscv64", version = "=3.0.0" }
mold-elf-riscv64be = { path = "arch/elf-riscv64be", version = "=3.0.0" }
mold-elf-riscv32 = { path = "arch/elf-riscv32", version = "=3.0.0" }
mold-elf-riscv32be = { path = "arch/elf-riscv32be", version = "=3.0.0" }
mold-elf-ppc64v2 = { path = "arch/elf-ppc64v2", version = "=3.0.0" }
mold-elf-ppc32 = { path = "arch/elf-ppc32", version = "=3.0.0" }
mold-elf-ppc64v1 = { path = "arch/elf-ppc64v1", version = "=3.0.0" }
mold-elf-s390x = { path = "arch/elf-s390x", version = "=3.0.0" }
mold-elf-sparc64 = { path = "arch/elf-sparc64", version = "=3.0.0" }
mold-elf-m68k = { path = "arch/elf-m68k", version = "=3.0.0" }
mold-elf-sh4 = { path = "arch/elf-sh4", version = "=3.0.0" }
mold-elf-sh4be = { path = "arch/elf-sh4be", version = "=3.0.0" }
mold-elf-loongarch64 = { path = "arch/elf-loongarch64", version = "=3.0.0" }
mold-elf-loongarch32 = { path = "arch/elf-loongarch32", version = "=3.0.0" }
[profile.release]
panic = "abort"
+8 -8
View File
@@ -1,11 +1,11 @@
# Architecture crates
Each subdirectory is a small crate that instantiates the generic linker for
one target architecture. Separate crates let Cargo compile the architectures
in parallel. Instantiating all targets in one crate leaves a long serial
compilation step.
Each subdirectory is a small crate that instantiates the generic ELF linker
for one target architecture. Separate crates let Cargo compile the
architectures in parallel. Instantiating all targets in one crate leaves a
long serial compilation step. A directory is named after its crate without
the `mold-` prefix, e.g. `elf-x86_64` holds `mold-elf-x86_64`.
The shared linker implementation lives in [`elf/`](../elf/), with
target-specific code in [`elf/arch/`](../elf/arch/). These crates provide
entry points that the [`cli/`](../cli/) executable selects for the input
files' target.
The ELF linker lives in [`elf/`](../elf/), with target-specific code in
[`elf/arch/`](../elf/arch/). These crates provide entry points that the
[`cli/`](../cli/) executable selects for the input files' target.
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Arm32>(cmdline)
}
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Arm32Be>(cmdline)
}
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Arm64>(cmdline)
}
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Arm64Be>(cmdline)
}
@@ -1,9 +1,9 @@
[package]
name = "mold-arch-arm64be"
name = "mold-elf-arm32"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for arm64be"
description = "An internal crate of the mold linker, which instantiates its ELF linker for arm32"
license.workspace = true
repository.workspace = true
@@ -11,4 +11,4 @@ repository.workspace = true
path = "lib.rs"
[dependencies]
libmold.workspace = true
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Arm32>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-arm32be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for arm32be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Arm32Be>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-arm64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for arm64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Arm64>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-arm64be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for arm64be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Arm64Be>(cmdline)
}
@@ -1,9 +1,9 @@
[package]
name = "mold-arch-arm64"
name = "mold-elf-i386"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for arm64"
description = "An internal crate of the mold linker, which instantiates its ELF linker for i386"
license.workspace = true
repository.workspace = true
@@ -11,4 +11,4 @@ repository.workspace = true
path = "lib.rs"
[dependencies]
libmold.workspace = true
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::I386>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-loongarch32"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for loongarch32"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::LoongArch32>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-loongarch64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for loongarch64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::LoongArch64>(cmdline)
}
@@ -1,9 +1,9 @@
[package]
name = "mold-arch-arm32be"
name = "mold-elf-m68k"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for arm32be"
description = "An internal crate of the mold linker, which instantiates its ELF linker for m68k"
license.workspace = true
repository.workspace = true
@@ -11,4 +11,4 @@ repository.workspace = true
path = "lib.rs"
[dependencies]
libmold.workspace = true
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::M68k>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-ppc32"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for ppc32"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Ppc32>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-ppc64v1"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for ppc64v1"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Ppc64V1>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-ppc64v2"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for ppc64v2"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Ppc64V2>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-riscv32"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for riscv32"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Riscv32>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-riscv32be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for riscv32be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Riscv32Be>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-riscv64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for riscv64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Riscv64>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-riscv64be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for riscv64be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Riscv64Be>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-s390x"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for s390x"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::S390x>(cmdline)
}
@@ -1,9 +1,9 @@
[package]
name = "mold-arch-arm32"
name = "mold-elf-sh4"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for arm32"
description = "An internal crate of the mold linker, which instantiates its ELF linker for sh4"
license.workspace = true
repository.workspace = true
@@ -11,4 +11,4 @@ repository.workspace = true
path = "lib.rs"
[dependencies]
libmold.workspace = true
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Sh4>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-sh4be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for sh4be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Sh4Be>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-sparc64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for sparc64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::Sparc64>(cmdline)
}
+14
View File
@@ -0,0 +1,14 @@
[package]
name = "mold-elf-x86_64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates its ELF linker for x86_64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
mold-elf.workspace = true
+3
View File
@@ -0,0 +1,3 @@
pub fn link(cmdline: mold_elf::driver::Cmdline) -> mold_elf::driver::LinkResult {
mold_elf::driver::link::<mold_elf::arch::X86_64>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-i386"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for i386"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::I386>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-loongarch32"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for loongarch32"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::LoongArch32>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-loongarch64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for loongarch64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::LoongArch64>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-m68k"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for m68k"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::M68k>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-ppc32"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for ppc32"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Ppc32>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-ppc64v1"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for ppc64v1"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Ppc64V1>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-ppc64v2"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for ppc64v2"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Ppc64V2>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-riscv32"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for riscv32"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Riscv32>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-riscv32be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for riscv32be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Riscv32Be>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-riscv64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for riscv64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Riscv64>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-riscv64be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for riscv64be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Riscv64Be>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-s390x"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for s390x"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::S390x>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-sh4"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for sh4"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Sh4>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-sh4be"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for sh4be"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Sh4Be>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-sparc64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for sparc64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::Sparc64>(cmdline)
}
-14
View File
@@ -1,14 +0,0 @@
[package]
name = "mold-arch-x86_64"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "An internal crate of the mold linker, which instantiates it for x86_64"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
libmold.workspace = true
-3
View File
@@ -1,3 +0,0 @@
pub fn link(cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
libmold::driver::link::<libmold::arch::X86_64>(cmdline)
}
+41 -41
View File
@@ -21,27 +21,27 @@ harness = false
[dependencies]
mimalloc = { package = "mold-mimalloc", version = "0.1.52" }
libmold.workspace = true
mold-arch-x86_64 = { workspace = true, optional = true }
mold-arch-i386 = { workspace = true, optional = true }
mold-arch-arm32 = { workspace = true, optional = true }
mold-arch-arm32be = { workspace = true, optional = true }
mold-arch-arm64 = { workspace = true, optional = true }
mold-arch-arm64be = { workspace = true, optional = true }
mold-arch-riscv64 = { workspace = true, optional = true }
mold-arch-riscv64be = { workspace = true, optional = true }
mold-arch-riscv32 = { workspace = true, optional = true }
mold-arch-riscv32be = { workspace = true, optional = true }
mold-arch-ppc64v2 = { workspace = true, optional = true }
mold-arch-ppc32 = { workspace = true, optional = true }
mold-arch-ppc64v1 = { workspace = true, optional = true }
mold-arch-s390x = { workspace = true, optional = true }
mold-arch-sparc64 = { workspace = true, optional = true }
mold-arch-m68k = { workspace = true, optional = true }
mold-arch-sh4 = { workspace = true, optional = true }
mold-arch-sh4be = { workspace = true, optional = true }
mold-arch-loongarch64 = { workspace = true, optional = true }
mold-arch-loongarch32 = { workspace = true, optional = true }
mold-elf.workspace = true
mold-elf-x86_64 = { workspace = true, optional = true }
mold-elf-i386 = { workspace = true, optional = true }
mold-elf-arm32 = { workspace = true, optional = true }
mold-elf-arm32be = { workspace = true, optional = true }
mold-elf-arm64 = { workspace = true, optional = true }
mold-elf-arm64be = { workspace = true, optional = true }
mold-elf-riscv64 = { workspace = true, optional = true }
mold-elf-riscv64be = { workspace = true, optional = true }
mold-elf-riscv32 = { workspace = true, optional = true }
mold-elf-riscv32be = { workspace = true, optional = true }
mold-elf-ppc64v2 = { workspace = true, optional = true }
mold-elf-ppc32 = { workspace = true, optional = true }
mold-elf-ppc64v1 = { workspace = true, optional = true }
mold-elf-s390x = { workspace = true, optional = true }
mold-elf-sparc64 = { workspace = true, optional = true }
mold-elf-m68k = { workspace = true, optional = true }
mold-elf-sh4 = { workspace = true, optional = true }
mold-elf-sh4be = { workspace = true, optional = true }
mold-elf-loongarch64 = { workspace = true, optional = true }
mold-elf-loongarch32 = { workspace = true, optional = true }
[dev-dependencies]
mold-tests = { path = "../tests" }
@@ -54,23 +54,23 @@ default = [
"ppc64v2", "ppc32", "ppc64v1", "s390x", "sparc64", "m68k", "sh4", "sh4be", "loongarch64", "loongarch32",
]
system-allocator = []
x86_64 = ["dep:mold-arch-x86_64"]
i386 = ["dep:mold-arch-i386"]
arm32 = ["dep:mold-arch-arm32"]
arm32be = ["dep:mold-arch-arm32be"]
arm64 = ["dep:mold-arch-arm64"]
arm64be = ["dep:mold-arch-arm64be"]
riscv64 = ["dep:mold-arch-riscv64"]
riscv64be = ["dep:mold-arch-riscv64be"]
riscv32 = ["dep:mold-arch-riscv32"]
riscv32be = ["dep:mold-arch-riscv32be"]
ppc64v2 = ["dep:mold-arch-ppc64v2"]
ppc32 = ["dep:mold-arch-ppc32"]
ppc64v1 = ["dep:mold-arch-ppc64v1"]
s390x = ["dep:mold-arch-s390x"]
sparc64 = ["dep:mold-arch-sparc64"]
m68k = ["dep:mold-arch-m68k"]
sh4 = ["dep:mold-arch-sh4"]
sh4be = ["dep:mold-arch-sh4be"]
loongarch64 = ["dep:mold-arch-loongarch64"]
loongarch32 = ["dep:mold-arch-loongarch32"]
x86_64 = ["dep:mold-elf-x86_64"]
i386 = ["dep:mold-elf-i386"]
arm32 = ["dep:mold-elf-arm32"]
arm32be = ["dep:mold-elf-arm32be"]
arm64 = ["dep:mold-elf-arm64"]
arm64be = ["dep:mold-elf-arm64be"]
riscv64 = ["dep:mold-elf-riscv64"]
riscv64be = ["dep:mold-elf-riscv64be"]
riscv32 = ["dep:mold-elf-riscv32"]
riscv32be = ["dep:mold-elf-riscv32be"]
ppc64v2 = ["dep:mold-elf-ppc64v2"]
ppc32 = ["dep:mold-elf-ppc32"]
ppc64v1 = ["dep:mold-elf-ppc64v1"]
s390x = ["dep:mold-elf-s390x"]
sparc64 = ["dep:mold-elf-sparc64"]
m68k = ["dep:mold-elf-m68k"]
sh4 = ["dep:mold-elf-sh4"]
sh4be = ["dep:mold-elf-sh4be"]
loongarch64 = ["dep:mold-elf-loongarch64"]
loongarch32 = ["dep:mold-elf-loongarch32"]
+25 -23
View File
@@ -3,60 +3,62 @@
//! that the compiler can build them in parallel, and a feature per target
//! decides which of them are built in.
use mold_elf::driver::{Cmdline, LinkResult};
// A Rust executable can define only one global allocator, so select mimalloc
// here rather than in the linker library.
#[cfg(not(feature = "system-allocator"))]
#[global_allocator]
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
type LinkFn = fn(libmold::driver::Cmdline) -> libmold::driver::LinkResult;
type LinkFn = fn(Cmdline) -> LinkResult;
// Each target has its own monomorphized link function. Start with the first
// enabled target and switch to the matching function if the inputs differ.
const TARGETS: &[(&str, LinkFn)] = &[
#[cfg(feature = "x86_64")]
("x86_64", mold_arch_x86_64::link),
("x86_64", mold_elf_x86_64::link),
#[cfg(feature = "i386")]
("i386", mold_arch_i386::link),
("i386", mold_elf_i386::link),
#[cfg(feature = "arm32")]
("arm32", mold_arch_arm32::link),
("arm32", mold_elf_arm32::link),
#[cfg(feature = "arm32be")]
("arm32be", mold_arch_arm32be::link),
("arm32be", mold_elf_arm32be::link),
#[cfg(feature = "arm64")]
("arm64", mold_arch_arm64::link),
("arm64", mold_elf_arm64::link),
#[cfg(feature = "arm64be")]
("arm64be", mold_arch_arm64be::link),
("arm64be", mold_elf_arm64be::link),
#[cfg(feature = "riscv64")]
("riscv64", mold_arch_riscv64::link),
("riscv64", mold_elf_riscv64::link),
#[cfg(feature = "riscv64be")]
("riscv64be", mold_arch_riscv64be::link),
("riscv64be", mold_elf_riscv64be::link),
#[cfg(feature = "riscv32")]
("riscv32", mold_arch_riscv32::link),
("riscv32", mold_elf_riscv32::link),
#[cfg(feature = "riscv32be")]
("riscv32be", mold_arch_riscv32be::link),
("riscv32be", mold_elf_riscv32be::link),
#[cfg(feature = "ppc64v2")]
("ppc64v2", mold_arch_ppc64v2::link),
("ppc64v2", mold_elf_ppc64v2::link),
#[cfg(feature = "ppc32")]
("ppc32", mold_arch_ppc32::link),
("ppc32", mold_elf_ppc32::link),
#[cfg(feature = "ppc64v1")]
("ppc64v1", mold_arch_ppc64v1::link),
("ppc64v1", mold_elf_ppc64v1::link),
#[cfg(feature = "s390x")]
("s390x", mold_arch_s390x::link),
("s390x", mold_elf_s390x::link),
#[cfg(feature = "sparc64")]
("sparc64", mold_arch_sparc64::link),
("sparc64", mold_elf_sparc64::link),
#[cfg(feature = "m68k")]
("m68k", mold_arch_m68k::link),
("m68k", mold_elf_m68k::link),
#[cfg(feature = "sh4")]
("sh4", mold_arch_sh4::link),
("sh4", mold_elf_sh4::link),
#[cfg(feature = "sh4be")]
("sh4be", mold_arch_sh4be::link),
("sh4be", mold_elf_sh4be::link),
#[cfg(feature = "loongarch64")]
("loongarch64", mold_arch_loongarch64::link),
("loongarch64", mold_elf_loongarch64::link),
#[cfg(feature = "loongarch32")]
("loongarch32", mold_arch_loongarch32::link),
("loongarch32", mold_elf_loongarch32::link),
];
fn link_for_target(target: &str, cmdline: libmold::driver::Cmdline) -> libmold::driver::LinkResult {
fn link_for_target(target: &str, cmdline: Cmdline) -> LinkResult {
for &(name, link) in TARGETS {
if name == target {
return link(cmdline);
@@ -74,6 +76,6 @@ fn main() {
std::process::exit(1);
};
let args = std::env::args_os().collect();
let status = libmold::driver::main(args, initial_target, link_for_target);
let status = mold_elf::driver::main(args, initial_target, link_for_target);
std::process::exit(status);
}
+2 -2
View File
@@ -1,9 +1,9 @@
[package]
name = "libmold"
name = "mold-elf"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "The internal library of the mold linker, whose API is not stable"
description = "An internal crate of the mold linker, which implements its ELF linker"
license.workspace = true
repository.workspace = true