Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions 1.86.0/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

RUSTC_BOOTSTRAP_VERSION=1.85.1
CARGO_BOOTSTRAP_VERSION=1.85.1
RUST_VERSION=1.86.0

CONFIGURE_CARGO_STATIC_FLAGS="--enable-cargo-native-static"

# Since rust 1.38, OPENSSL_DIR has to be specified.
export OPENSSL_DIR="/usr/local"

# Show backtraces on failures
export RUST_BACKTRACE=1
# Continue linking rustc driver dynamically
export RUSTC_LINK_STD_INTO_RUSTC_DRIVER=0

BASE=`pwd`
DEST=$1
LLVM_ROOT=""

. ../checksums.sh
. ../common.sh

fixup-vendor() {
fixup-vendor-patch openssl-src-111.28.2+1.1.1w src/lib.rs || exit 1
fixup-vendor-patch notify-8.0.0 Cargo.toml || exit 1
}

RUN info clean extract prepatch fixup-vendor config xbuild xdist inst 2>&1
13 changes: 13 additions & 0 deletions 1.86.0/patches/patch-compiler_rustc_codegen_ssa_src_back_link.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- compiler/rustc_codegen_ssa/src/back/link.rs 2025-03-16 00:27:19.000000000 +0800
+++ compiler/rustc_codegen_ssa/src/back/link.rs 2026-06-11 14:48:41.552289000 +0800
@@ -1743,7 +1743,9 @@

#[cfg(unix)]
fn command_line_too_big(err: &io::Error) -> bool {
- err.raw_os_error() == Some(::libc::E2BIG)
+ let raw_os_error = err.raw_os_error();
+ raw_os_error == Some(::libc::E2BIG)
+ || (cfg!(target_os = "dragonfly") && raw_os_error == Some(::libc::EFAULT))
}

#[cfg(windows)]
37 changes: 37 additions & 0 deletions 1.86.0/patches/patch-compiler_rustc_codegen_ssa_src_back_linker.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
--- compiler/rustc_codegen_ssa/src/back/linker.rs 2025-03-16 00:27:19.000000000 +0800
+++ compiler/rustc_codegen_ssa/src/back/linker.rs 2026-06-11 14:28:13.682043000 +0800
@@ -816,11 +816,21 @@
let res: io::Result<()> = try {
let mut f = File::create_buffered(&path)?;
writeln!(f, "{{")?;
- if !symbols.is_empty() {
+ let preserve_dragonfly_startup_symbols = crate_type == CrateType::Executable
+ && self.sess.target.os == "dragonfly";
+ if !symbols.is_empty() || preserve_dragonfly_startup_symbols {
writeln!(f, " global:")?;
for sym in symbols {
debug!(" {sym};");
writeln!(f, " {sym};")?;
+ }
+ if preserve_dragonfly_startup_symbols {
+ // DragonFly startup objects define process globals for DSOs; hiding
+ // them with local: * makes ld.bfd reject PIE executable links.
+ for sym in ["__progname", "environ"] {
+ debug!(" {sym};");
+ writeln!(f, " {sym};")?;
+ }
}
}
writeln!(f, "\n local:\n *;\n}};")?;
@@ -840,7 +848,10 @@
} else {
let mut arg = OsString::from("--version-script=");
arg.push(path);
- self.link_arg(arg).link_arg("--no-undefined-version");
+ self.link_arg(arg);
+ if self.sess.target.os != "dragonfly" {
+ self.link_arg("--no-undefined-version");
+ }
}
}

18 changes: 18 additions & 0 deletions 1.86.0/patches/patch-library_backtrace_src_symbolize_gimli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- library/backtrace/src/symbolize/gimli.rs 2025-03-16 00:27:19.000000000 +0800
+++ library/backtrace/src/symbolize/gimli.rs 2026-06-11 14:26:09.092017000 +0800
@@ -35,6 +35,7 @@
} else if #[cfg(any(
target_os = "android",
target_os = "freebsd",
+ target_os = "dragonfly",
target_os = "fuchsia",
target_os = "haiku",
target_os = "hurd",
@@ -220,6 +221,7 @@
target_os = "linux",
target_os = "fuchsia",
target_os = "freebsd",
+ target_os = "dragonfly",
target_os = "hurd",
target_os = "openbsd",
target_os = "netbsd",
29 changes: 29 additions & 0 deletions 1.86.0/patches/patch-library_std_src_sys_pal_unix_futex.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--- library/std/src/sys/pal/unix/futex.rs.orig 2025-03-16 00:38:21 UTC
+++ library/std/src/sys/pal/unix/futex.rs
@@ -193,19 +193,22 @@ pub fn futex_wake_all(futex: &AtomicU32) {

#[cfg(target_os = "dragonfly")]
pub fn futex_wait(futex: &AtomicU32, expected: u32, timeout: Option<Duration>) -> bool {
- // A timeout of 0 means infinite.
- // We round smaller timeouts up to 1 millisecond.
+ let has_timeout = timeout.is_some();
+
+ // DragonFly umtx_sleep takes a timeout in microseconds.
+ // A timeout of 0 means infinite.
+ // We round smaller timeouts up to 1 microsecond.
// Overflows are rounded up to an infinite timeout.
- let timeout_ms =
- timeout.and_then(|d| Some(i32::try_from(d.as_millis()).ok()?.max(1))).unwrap_or(0);
+ let timeout_us =
+ timeout.and_then(|d| Some(i32::try_from(d.as_micros()).ok()?.max(1))).unwrap_or(0);

let r = unsafe {
- libc::umtx_sleep(futex as *const AtomicU32 as *const i32, expected as i32, timeout_ms)
+ libc::umtx_sleep(futex as *const AtomicU32 as *const i32, expected as i32, timeout_us)
};

- r == 0 || super::os::errno() != libc::ETIMEDOUT
+ r == 0 || !has_timeout || super::os::errno() != libc::EWOULDBLOCK
}

// DragonflyBSD doesn't tell us how many threads are woken up, so this always returns false.
100 changes: 100 additions & 0 deletions 1.86.0/patches/patch-library_std_src_sys_pal_unix_stack_overflow.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
--- library/std/src/sys/pal/unix/stack_overflow.rs 2025-03-16 00:27:19.000000000 +0800
+++ library/std/src/sys/pal/unix/stack_overflow.rs 2026-06-11 14:01:27.661720000 +0800
@@ -28,6 +28,7 @@
#[cfg(any(
target_os = "linux",
target_os = "freebsd",
+ target_os = "dragonfly",
target_os = "hurd",
target_os = "macos",
target_os = "netbsd",
@@ -311,6 +312,7 @@
#[cfg(any(
target_os = "android",
target_os = "freebsd",
+ target_os = "dragonfly",
target_os = "netbsd",
target_os = "hurd",
target_os = "linux",
@@ -319,11 +321,11 @@
unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
let mut ret = None;
let mut attr: libc::pthread_attr_t = crate::mem::zeroed();
- #[cfg(target_os = "freebsd")]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
- #[cfg(target_os = "freebsd")]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
- #[cfg(not(target_os = "freebsd"))]
+ #[cfg(not(any(target_os = "freebsd", target_os = "dragonfly")))]
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
if e == 0 {
let mut stackaddr = crate::ptr::null_mut();
@@ -331,7 +333,7 @@
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0);
ret = Some(stackaddr);
}
- if e == 0 || cfg!(target_os = "freebsd") {
+ if e == 0 || cfg!(any(target_os = "freebsd", target_os = "dragonfly")) {
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
}
ret
@@ -367,7 +369,7 @@
install_main_guard_linux_musl(page_size)
} else if cfg!(target_os = "freebsd") {
install_main_guard_freebsd(page_size)
- } else if cfg!(any(target_os = "netbsd", target_os = "openbsd")) {
+ } else if cfg!(any(target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd")) {
install_main_guard_bsds(page_size)
} else {
install_main_guard_default(page_size)
@@ -500,6 +502,7 @@
#[cfg(any(
target_os = "android",
target_os = "freebsd",
+ target_os = "dragonfly",
target_os = "hurd",
target_os = "linux",
target_os = "netbsd",
@@ -509,11 +512,11 @@
unsafe fn current_guard() -> Option<Range<usize>> {
let mut ret = None;
let mut attr: libc::pthread_attr_t = crate::mem::zeroed();
- #[cfg(target_os = "freebsd")]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
- #[cfg(target_os = "freebsd")]
+ #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
- #[cfg(not(target_os = "freebsd"))]
+ #[cfg(not(any(target_os = "freebsd", target_os = "dragonfly")))]
let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
if e == 0 {
let mut guardsize = 0;
@@ -533,7 +536,7 @@
assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackptr, &mut size), 0);

let stackaddr = stackptr.addr();
- ret = if cfg!(any(target_os = "freebsd", target_os = "netbsd", target_os = "hurd")) {
+ ret = if cfg!(any(target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "hurd")) {
Some(stackaddr - guardsize..stackaddr)
} else if cfg!(all(target_os = "linux", target_env = "musl")) {
Some(stackaddr - guardsize..stackaddr)
@@ -550,7 +553,7 @@
Some(stackaddr..stackaddr + guardsize)
};
}
- if e == 0 || cfg!(target_os = "freebsd") {
+ if e == 0 || cfg!(any(target_os = "freebsd", target_os = "dragonfly")) {
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
}
ret
@@ -568,6 +571,7 @@
#[cfg(not(any(
target_os = "linux",
target_os = "freebsd",
+ target_os = "dragonfly",
target_os = "hurd",
target_os = "macos",
target_os = "netbsd",
22 changes: 22 additions & 0 deletions 1.86.0/patches/patch-library_std_src_sys_thread_local_key_racy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- library/std/src/sys/thread_local/key/racy.rs 2025-03-16 00:27:19.000000000 +0800
+++ library/std/src/sys/thread_local/key/racy.rs 2026-06-11 13:39:50.341460000 +0800
@@ -21,13 +21,18 @@

// Define a sentinel value that is likely not to be returned
// as a TLS key.
-#[cfg(not(target_os = "nto"))]
+#[cfg(not(any(target_os = "nto", target_os = "dragonfly")))]
const KEY_SENTVAL: usize = 0;
// On QNX Neutrino, 0 is always returned when currently not in use.
// Using 0 would mean to always create two keys and remote the first
// one (with value of 0) immediately afterwards.
#[cfg(target_os = "nto")]
const KEY_SENTVAL: usize = libc::PTHREAD_KEYS_MAX + 1;
+// DragonFly may hand out key 0 in lean statically-linked/LTO executables.
+// Use a value outside pthread_key_t successful non-negative range instead of
+// relying on the double-create workaround for a zero sentinel.
+#[cfg(target_os = "dragonfly")]
+const KEY_SENTVAL: usize = usize::MAX;

impl LazyKey {
pub const fn new(dtor: Option<unsafe extern "C" fn(*mut u8)>) -> LazyKey {
12 changes: 12 additions & 0 deletions 1.86.0/patches/patch-library_std_src_sys_thread_local_mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- library/std/src/sys/thread_local/mod.rs 2025-03-16 00:27:19.000000000 +0800
+++ library/std/src/sys/thread_local/mod.rs 2026-06-11 13:39:16.841453000 +0800
@@ -59,8 +59,7 @@
target_os = "fuchsia",
target_os = "redox",
target_os = "hurd",
- target_os = "netbsd",
- target_os = "dragonfly"
+ target_os = "netbsd"
))] {
mod linux_like;
mod list;
88 changes: 88 additions & 0 deletions 1.86.0/patches/patch-src_bootstrap_src_core_build_steps_dist.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
--- src/bootstrap/src/core/build_steps/dist.rs.orig
+++ src/bootstrap/src/core/build_steps/dist.rs
@@ -27,7 +27,7 @@
use crate::utils::channel::{self, Info};
use crate::utils::exec::{BootstrapCommand, command};
use crate::utils::helpers::{
- exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit,
+ exe, hex_encode, is_dylib, move_file, t, target_supports_cranelift_backend, timeit,
};
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
use crate::{Compiler, DependencyType, LLVM_TOOLS, Mode};
@@ -44,6 +44,68 @@
builder.out.join("tmp/dist")
}

+
+fn update_dragonfly_vendor_checksum(builder: &Builder<'_>, crate_dir: &Path, file: &str, contents: &[u8]) {
+ use sha2::Digest;
+
+ let mut hasher = sha2::Sha256::new();
+ hasher.update(contents);
+ let checksum = hex_encode(hasher.finalize().as_slice());
+
+ let checksum_path = crate_dir.join(".cargo-checksum.json");
+ let mut checksum_json: serde_json::Value =
+ t!(serde_json::from_slice(&t!(fs::read(&checksum_path))));
+ let files = checksum_json
+ .get_mut("files")
+ .and_then(|files| files.as_object_mut())
+ .expect("vendor checksum file should contain a files object");
+ files.insert(file.to_string(), serde_json::Value::String(checksum));
+ builder.create(&checksum_path, &t!(serde_json::to_string(&checksum_json)));
+}
+
+fn patch_dragonfly_vendor_openssl_src(builder: &Builder<'_>, plain_dst_src: &Path) {
+ let crate_dir = plain_dst_src.join("vendor/openssl-src-111.28.2+1.1.1w");
+ if !crate_dir.exists() {
+ return;
+ }
+
+ let lib_rs = crate_dir.join("src/lib.rs");
+ let mut contents = t!(fs::read_to_string(&lib_rs));
+ if !contents.contains("no-devcryptoeng") {
+ let needle = " if target.contains(\"musl\") {\n // MUSL doesn't implement some of the libc functions that the async\n // stuff depends on, and we don't bind to any of that in any case.\n configure.arg(\"no-async\");\n }\n";
+ let replacement = " if target.contains(\"dragonfly\") {\n configure.arg(\"no-devcryptoeng\");\n }\n\n if target.contains(\"musl\") {\n // MUSL doesn't implement some of the libc functions that the async\n // stuff depends on, and we don't bind to any of that in any case.\n configure.arg(\"no-async\");\n }\n";
+
+ if !contents.contains(needle) {
+ panic!("openssl-src crate layout changed; cannot patch DragonFly devcrypto config");
+ }
+ contents = contents.replacen(needle, replacement, 1);
+ builder.create(&lib_rs, &contents);
+ }
+
+ update_dragonfly_vendor_checksum(builder, &crate_dir, "src/lib.rs", contents.as_bytes());
+}
+
+fn patch_dragonfly_vendor_notify(builder: &Builder<'_>, plain_dst_src: &Path) {
+ let crate_dir = plain_dst_src.join("vendor/notify-8.0.0");
+ if !crate_dir.exists() {
+ return;
+ }
+
+ let cargo_toml = crate_dir.join("Cargo.toml");
+ let mut contents = t!(fs::read_to_string(&cargo_toml));
+ if contents.contains("dragonflybsd") {
+ contents = contents.replace("target_os = \"dragonflybsd\"", "target_os = \"dragonfly\"");
+ builder.create(&cargo_toml, &contents);
+ }
+
+ update_dragonfly_vendor_checksum(builder, &crate_dir, "Cargo.toml", contents.as_bytes());
+}
+
+fn patch_dragonfly_vendor_crates(builder: &Builder<'_>, plain_dst_src: &Path) {
+ patch_dragonfly_vendor_openssl_src(builder, plain_dst_src);
+ patch_dragonfly_vendor_notify(builder, plain_dst_src);
+}
+
fn should_build_extended_tool(builder: &Builder<'_>, tool: &str) -> bool {
if !builder.config.extended {
return false;
@@ -1073,6 +1135,7 @@
let cargo_config_dir = plain_dst_src.join(".cargo");
builder.create_dir(&cargo_config_dir);
builder.create(&cargo_config_dir.join("config.toml"), &vendor.config);
+ patch_dragonfly_vendor_crates(builder, plain_dst_src);
}

// Delete extraneous directories
Loading