Move the ELF linker to elf/

This makes room for the Mach-O linker from
https://github.com/rui314/mold-macho, which will be in macho/. The
root Cargo.toml now only defines the workspace. build.rs looks for .git
in the parent directory, as the crate is no longer at the root of the
source tree.
This commit is contained in:
Rui Ueyama committed 2026-10-07 16:32:34 +09:00
1 parent f56e1e3620
commit 2505c77baa
105 files changed
+48 -47

No files matched your search

+7 -43
View File
@@ -1,22 +1,10 @@
[package]
name = "libmold"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "The internal library of the mold linker, whose API is not stable"
license.workspace = true
repository.workspace = true
# tests/lib.rs belongs to the mold-tests workspace crate.
autotests = false
include = ["/src", "/c", "/build.rs", "/LICENSE", "/README.md"]
# The linker is generic over the target. Instantiating it for all twenty
# targets in one crate keeps the compiler on a single core for minutes, so
# each target is instantiated in a crate of its own under arch/, and the
# executable in cli/ dispatches to them.
# The ELF linker in elf/ is generic over the target. Instantiating it for
# all twenty targets in one crate keeps the compiler on a single core for
# minutes, so each target is instantiated in a crate of its own under
# arch/, and the executable in cli/ dispatches to them.
[workspace]
members = ["cli", "arch/*", "tests"]
default-members = [".", "cli", "arch/*", "tests"]
resolver = "3"
members = ["cli", "elf", "arch/*", "tests"]
[workspace.package]
version = "3.0.0"
@@ -30,7 +18,7 @@ repository = "https://github.com/rui314/mold"
# these versions equal to the workspace version above.
[workspace.dependencies]
libc = "0.2"
libmold = { path = ".", version = "=3.0.0" }
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" }
@@ -52,30 +40,6 @@ 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" }
[dependencies]
blake3 = "1.8.7"
bstr = "1"
cpp_demangle = "0.5.1"
crc32fast = "1"
flate2 = { version = "1", default-features = false, features = ["zlib-rs"] }
getrandom = "0.4.3"
hashbrown = "0.17.1"
libc.workspace = true
libz-rs-sys = "0.6.8"
memchr = "2.8.3"
memmap2 = "0.9"
# std has no 64-bit atomics on hosts such as 32-bit PowerPC.
portable-atomic = "1"
rayon = "1"
rustc-demangle = "0.1"
uuid = { version = "1.27", default-features = false, features = ["v4"] }
xxhash-rust = { version = "0.8", features = ["xxh3"] }
zlib-rs = { version = "0.6.8", default-features = false }
zstd = "0.13"
[build-dependencies]
cc = "1"
[profile.release]
panic = "abort"
# Copying generic and inline functions once per crate instead of once per
+2 -2
View File
@@ -5,7 +5,7 @@ one target architecture. Separate crates let Cargo compile the architectures
in parallel. Instantiating all targets in one crate leaves a long serial
compilation step.
The shared linker implementation lives in [`src/`](../src/), with
target-specific code in [`src/arch/`](../src/arch/). These crates provide
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.
+35
View File
@@ -0,0 +1,35 @@
[package]
name = "libmold"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "The internal library of the mold linker, whose API is not stable"
license.workspace = true
repository.workspace = true
[lib]
path = "lib.rs"
[dependencies]
blake3 = "1.8.7"
bstr = "1"
cpp_demangle = "0.5.1"
crc32fast = "1"
flate2 = { version = "1", default-features = false, features = ["zlib-rs"] }
getrandom = "0.4.3"
hashbrown = "0.17.1"
libc.workspace = true
libz-rs-sys = "0.6.8"
memchr = "2.8.3"
memmap2 = "0.9"
# std has no 64-bit atomics on hosts such as 32-bit PowerPC.
portable-atomic = "1"
rayon = "1"
rustc-demangle = "0.1"
uuid = { version = "1.27", default-features = false, features = ["v4"] }
xxhash-rust = { version = "0.8", features = ["xxh3"] }
zlib-rs = { version = "0.6.8", default-features = false }
zstd = "0.13"
[build-dependencies]
cc = "1"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+4 -2
View File
@@ -65,9 +65,11 @@ fn git_hash(source_dir: &Path) -> Option<String> {
}
fn main() {
let source_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
// This crate is in elf/ of the source tree.
let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap());
let source_dir = manifest_dir.parent().unwrap();
let version = std::env::var("CARGO_PKG_VERSION").unwrap();
let version = match git_hash(&source_dir) {
let version = match git_hash(source_dir) {
Some(hash) => format!("mold {version} ({hash}; compatible with GNU ld)"),
None => format!("mold {version} (compatible with GNU ld)"),
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
Loaded 100 of 105 files, more files were not shown because too many files have changed in this diff. Show more