Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"build:release:local": "bun scripts/build.ts --profile=release-local --build-dir=build/release-local",
"run:linux": "docker run --rm -v \"$PWD:/root/bun/\" -w /root/bun ghcr.io/oven-sh/bun-development-docker-image",
"uv-posix-stubs": "bun run src/jsc/bindings/libuv/generate_uv_posix_stubs.ts",
"bump": "bun ./scripts/bump.ts",
"orderfile": "bun scripts/orderfile/generate.ts",
"jsc:build": "bun scripts/build.ts --profile=release-local --build-dir=build/release-local --target=WebKit",
"jsc:build:debug": "bun scripts/build.ts --profile=debug-local --build-dir=build/debug-local --target=WebKit",
Expand Down
12 changes: 0 additions & 12 deletions scripts/build/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,3 @@ export function assert(
}
}

/**
* Assert a value is defined (not undefined or null).
*/
export function assertDefined<T>(
value: T | undefined | null,
message: string,
context?: { hint?: string; file?: string },
): asserts value is T {
if (value === undefined || value === null) {
throw new BuildError(message, context);
}
}
38 changes: 1 addition & 37 deletions scripts/build/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface Flag {
when?: (cfg: Config) => boolean;
/** Restrict to one language. Omitted = both C and C++. */
lang?: "c" | "cxx";
/** What this flag does. Used by `--explain-flags`. */
/** What this flag does. */
desc: string;
}

Expand Down Expand Up @@ -1712,39 +1712,3 @@ export function extraFlagsFor(cfg: Config, srcRelPath: string): string[] {
return [];
}

/**
* Produce a human-readable explanation of all active flags for `--explain-flags`.
* Grouped by flag type, shows each flag alongside its description.
*/
export function explainFlags(cfg: Config): string {
const lines: string[] = [];

const explainTable = (title: string, flags: Flag[]) => {
const active = flags.filter(f => !f.when || f.when(cfg));
if (active.length === 0) return;
lines.push(`\n─── ${title} ───`);
for (const f of active) {
const vals = resolveFlagValue(f.flag, cfg);
const langSuffix = f.lang ? ` [${f.lang}]` : "";
lines.push(` ${vals.join(" ")}${langSuffix}`);
lines.push(` ${f.desc}`);
}
};

explainTable("Global compiler flags (bun + deps)", globalFlags);
explainTable("Bun-only compiler flags", bunOnlyFlags);
explainTable("Defines", defines);
explainTable("Linker flags", linkerFlags);
explainTable("Strip flags", stripFlags);

const overrides = fileOverrides.filter(o => !o.when || o.when(cfg));
if (overrides.length > 0) {
lines.push("\n─── Per-file overrides ───");
for (const o of overrides) {
lines.push(` ${o.file}: ${resolveFlagValue(o.extraFlags, cfg).join(" ")}`);
lines.push(` ${o.desc}`);
}
}

return lines.join("\n");
}
8 changes: 0 additions & 8 deletions scripts/build/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,14 +678,6 @@ export function depSourceDir(cfg: Config, name: string): string {
return resolve(cfg.vendorDir, name);
}

/**
* Path to a dep's fetch stamp. Used by rust-only mode to depend on lolhtml's
* source being on disk without resolving the full dep graph.
*/
export function depSourceStamp(cfg: Config, name: string): string {
return resolve(depSourceDir(cfg, name), ".ref");
}

/**
* Path to a dep's cmake build output. Separate from source so multiple
* profiles (debug/release) don't clash.
Expand Down
2 changes: 1 addition & 1 deletion src/ast/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2376,7 +2376,7 @@ impl Default for Source {
}

#[derive(Copy, Clone, Debug)]
pub struct ErrorPosition {
struct ErrorPosition {
pub(crate) line_start: usize,
pub(crate) line_end: usize,
pub(crate) column_count: usize,
Expand Down
1 change: 0 additions & 1 deletion src/ast/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use core::ops::{Deref, DerefMut};
use core::ptr::NonNull;

pub use bun_collections::VecExt as _VecExtReexport;
use bun_collections::{ArrayHashMap, AutoContext, MultiArrayList, StringHashMap};
use bun_core::Output;

Expand Down
2 changes: 1 addition & 1 deletion src/base64/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub const fn url_safe_encode_len(source: &[u8]) -> usize {
// base64-alphabet bit-packing with zero sourcemap-specific deps; bun_sourcemap
// re-exports this for its own consumers.
// ──────────────────────────────────────────────────────────────────────────
pub use vlq::{VLQ, VLQResult};
pub use vlq::VLQ;

/// Variable-length quantity encoding, limited to i32 as per source map spec.
/// https://en.wikipedia.org/wiki/Variable-length_quantity
Expand Down
6 changes: 3 additions & 3 deletions src/boringssl/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub enum Wildcards {
/// Options for [`match_hostname`]. Each defaults to the stricter setting so
/// callers opt in explicitly.
#[derive(Clone, Copy)]
pub struct MatchOpts {
struct MatchOpts {
pub wildcards: Wildcards,
Comment thread
robobun marked this conversation as resolved.
/// A full-label `*` may span multiple host labels
/// (OpenSSL `X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS`).
Expand All @@ -222,7 +222,7 @@ pub struct MatchOpts {
impl MatchOpts {
/// Node.js lib/tls.js `check()` — the matcher behind `tls.connect`,
/// `https`, and undici `fetch`.
pub const TLS_CHECK: Self = Self {
const TLS_CHECK: Self = Self {
wildcards: Wildcards::Anywhere,
multi_label_wildcards: false,
strip_trailing_dot: true,
Expand Down Expand Up @@ -265,7 +265,7 @@ fn openssl_valid_pattern(pattern: &[u8]) -> bool {
/// hostname matcher every native TLS client and `X509Certificate#checkHost`
/// share; [`MatchOpts`] selects between Node.js lib/tls.js `check()` semantics
/// and OpenSSL `X509_check_host` semantics where they differ.
pub fn match_hostname(pattern: &[u8], hostname: &[u8], opts: MatchOpts) -> bool {
fn match_hostname(pattern: &[u8], hostname: &[u8], opts: MatchOpts) -> bool {
let (pattern, hostname) = if opts.strip_trailing_dot {
(unfqdn(pattern), unfqdn(hostname))
} else {
Expand Down
10 changes: 3 additions & 7 deletions src/boringssl_sys/boringssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,6 @@ unsafe extern "C" {
pub safe fn OpenSSL_add_all_algorithms();

// ── ASN1 ──────────────────────────────────────────────────────────────
pub fn ASN1_STRING_get0_data(str: *const ASN1_STRING) -> *const u8;
pub fn ASN1_STRING_length(str: *const ASN1_STRING) -> c_int;
pub fn ASN1_STRING_to_UTF8(out: *mut *mut u8, in_: *const ASN1_STRING) -> c_int;

// ── EVP digest getters (infallible, return static singletons) ────────
Expand Down Expand Up @@ -696,12 +694,12 @@ unsafe extern "C" {
pub fn X509_get_subject_name(x509: *const X509) -> *mut X509_NAME;
pub fn X509_get_ext_by_NID(x: *const X509, nid: c_int, lastpos: c_int) -> c_int;
pub fn X509_get_ext(x: *const X509, loc: c_int) -> *mut X509_EXTENSION;
pub fn X509_NAME_get_index_by_NID(name: *const X509_NAME, nid: c_int, lastpos: c_int) -> c_int;
fn X509_NAME_get_index_by_NID(name: *const X509_NAME, nid: c_int, lastpos: c_int) -> c_int;
pub fn X509_NAME_get_entry(name: *const X509_NAME, loc: c_int) -> *mut X509_NAME_ENTRY;
pub fn X509_NAME_ENTRY_get_data(entry: *const X509_NAME_ENTRY) -> *mut ASN1_STRING;
pub fn X509V3_EXT_d2i(ext: *mut X509_EXTENSION) -> *mut c_void;
pub fn X509V3_EXT_get(ext: *mut X509_EXTENSION) -> *const X509V3_EXT_METHOD;
pub safe fn X509V3_EXT_get_nid(nid: c_int) -> *const X509V3_EXT_METHOD;
fn X509V3_EXT_get(ext: *mut X509_EXTENSION) -> *const X509V3_EXT_METHOD;
safe fn X509V3_EXT_get_nid(nid: c_int) -> *const X509V3_EXT_METHOD;
}

// ═══════════════════════════════════════════════════════════════════════════
Expand Down Expand Up @@ -876,7 +874,6 @@ pub(crate) type pem_password_cb =

unsafe extern "C" {
// ── SSL_METHOD ───────────────────────────────────────────────────────
pub safe fn TLS_with_buffers_method() -> *const SSL_METHOD;

// ── ENGINE ───────────────────────────────────────────────────────────
pub safe fn ENGINE_new() -> *mut ENGINE;
Expand Down Expand Up @@ -985,7 +982,6 @@ unsafe extern "C" {
pub fn BIO_free(bio: *mut BIO) -> c_int;
pub fn BIO_read(bio: *mut BIO, data: *mut c_void, len: c_int) -> c_int;
pub fn BIO_write(bio: *mut BIO, data: *const c_void, len: c_int) -> c_int;
pub fn BIO_ctrl(bio: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long;
pub fn BIO_ctrl_pending(bio: *const BIO) -> usize;
pub safe fn BIO_s_mem() -> *const BIO_METHOD;
pub fn BIO_new_mem_buf(buf: *const c_void, len: ossl_ssize_t) -> *mut BIO;
Expand Down
4 changes: 2 additions & 2 deletions src/brotli/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct DecoderOptions {

/// One `bool` per `BrotliDecoderParameter` variant, default `false`.
#[derive(Default)]
pub struct DecoderParams {
struct DecoderParams {
pub(crate) large_window: bool,
pub(crate) disable_ring_buffer_reallocation: bool,
}
Expand All @@ -42,7 +42,7 @@ impl Default for DecoderOptions {
}
}

pub use bun_core::compress::State as ReaderState;
use bun_core::compress::State as ReaderState;

// ──────────────────────────────────────────────────────────────────────────
// StreamingDecoder
Expand Down
46 changes: 6 additions & 40 deletions src/brotli_sys/brotli_c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use core::ffi::{c_char, c_int, c_uint, c_void};

pub type brotli_alloc_func =
type brotli_alloc_func =
Option<unsafe extern "C" fn(opaque: *mut c_void, size: usize) -> *mut c_void>;
pub type brotli_free_func = Option<unsafe extern "C" fn(opaque: *mut c_void, address: *mut c_void)>;
type brotli_free_func = Option<unsafe extern "C" fn(opaque: *mut c_void, address: *mut c_void)>;

bun_opaque::opaque_ffi! { pub struct struct_BrotliSharedDictionaryStruct; }

pub const BROTLI_SHARED_DICTIONARY_RAW: c_int = 0;
pub type enum_BrotliSharedDictionaryType = c_uint;
type enum_BrotliSharedDictionaryType = c_uint;
pub type BrotliSharedDictionaryType = enum_BrotliSharedDictionaryType;

// Not bound: BrotliSharedDictionaryCreateInstance, BrotliSharedDictionaryDestroyInstance,
Expand All @@ -36,12 +36,6 @@ unsafe extern "C" {
opaque: *mut c_void,
) -> *mut BrotliDecoder;
pub fn BrotliDecoderDestroyInstance(state: *mut BrotliDecoder);
pub fn BrotliDecoderDecompress(
encoded_size: usize,
encoded_buffer: *const u8,
decoded_size: *mut usize,
decoded_buffer: *mut u8,
) -> BrotliDecoderResult;
pub fn BrotliDecoderDecompressStream(
state: *mut BrotliDecoder,
available_in: *mut usize,
Expand All @@ -52,13 +46,10 @@ unsafe extern "C" {
) -> BrotliDecoderResult;
// Query fns: opaque handle by reference + scalars only — `BrotliDecoder` is
// `!Freeze` (UnsafeCell) so internal C mutation through `&` is sound.
pub safe fn BrotliDecoderHasMoreOutput(state: &BrotliDecoder) -> c_int;
pub safe fn BrotliDecoderTakeOutput(state: &mut BrotliDecoder, size: &mut usize) -> *const u8;
pub safe fn BrotliDecoderIsUsed(state: &BrotliDecoder) -> c_int;
pub safe fn BrotliDecoderIsFinished(state: &BrotliDecoder) -> c_int;
safe fn BrotliDecoderIsFinished(state: &BrotliDecoder) -> c_int;
pub safe fn BrotliDecoderGetErrorCode(state: &BrotliDecoder) -> BrotliDecoderErrorCode2;
pub safe fn BrotliDecoderErrorString(c: BrotliDecoderErrorCode) -> *const c_char;
pub safe fn BrotliDecoderVersion() -> u32;
safe fn BrotliDecoderVersion() -> u32;
}

bun_opaque::opaque_ffi! {
Expand Down Expand Up @@ -146,7 +137,7 @@ pub enum BrotliDecoderResult {
// NOTE: the duplicate error-code tables the upstream brotli headers define are
// intentionally collapsed into the single enum below; `BrotliDecoderErrorCode`
// is kept as an alias so FFI signatures keep their upstream names.
pub type BrotliDecoderErrorCode = BrotliDecoderErrorCode2;
type BrotliDecoderErrorCode = BrotliDecoderErrorCode2;

#[repr(i32)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
Expand Down Expand Up @@ -201,22 +192,6 @@ pub enum BrotliEncoderMode {
font = 2,
}

#[repr(u32)]
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum BrotliEncoderParameter {
mode = 0,
quality = 1,
lgwin = 2,
lgblock = 3,
disable_literal_context_modeling = 4,
size_hint = 5,
large_window = 6,
npostfix = 7,
ndirect = 8,
stream_offset = 9,
// update kMaxBrotliParam in src/js/node/zlib.ts if this list changes
}

unsafe extern "C" {
// Opaque handle by reference + scalars only.
pub safe fn BrotliEncoderSetParameter(
Expand Down Expand Up @@ -264,15 +239,6 @@ unsafe extern "C" {
total_out: *mut usize,
) -> c_int;
// Query fns: opaque handle by reference + scalars only.
pub safe fn BrotliEncoderEstimatePeakMemoryUsage(
quality: c_int,
lgwin: c_int,
input_size: usize,
) -> usize;
pub fn BrotliEncoderGetPreparedDictionarySize(
dictionary: *const BrotliEncoderPreparedDictionary,
) -> usize;
pub safe fn BrotliEncoderVersion() -> u32;
}

bun_opaque::opaque_ffi! {
Expand Down
10 changes: 5 additions & 5 deletions src/bun_alloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ const OVERFLOW_GROUP_MAX: usize = 4095;
const OVERFLOW_GROUP_SLOTS: usize = OVERFLOW_GROUP_MAX + 1;
type OverflowUsedSize = u16;

pub struct OverflowGroup<Block> {
struct OverflowGroup<Block> {
// 16 million files should be good enough for anyone
// ...right?
pub(crate) used: OverflowUsedSize,
Expand Down Expand Up @@ -1815,7 +1815,7 @@ impl<Block: OverflowBlock> OverflowGroup<Block> {
// Const-generic arithmetic (deriving COUNT from another const param) requires
// `feature(generic_const_exprs)` on stable Rust, so COUNT is pinned per instantiation site.

pub struct OverflowListBlock<ValueType, const COUNT: usize> {
struct OverflowListBlock<ValueType, const COUNT: usize> {
pub(crate) used: u32,
// Only `[0..used]` is initialized; writes are raw (no drop glue).
pub items: [MaybeUninit<ValueType>; COUNT],
Expand Down Expand Up @@ -1874,7 +1874,7 @@ impl<ValueType, const COUNT: usize> OverflowList<ValueType, COUNT> {
}

#[inline]
pub fn len(&self) -> u32 {
fn len(&self) -> u32 {
self.count
}

Expand Down Expand Up @@ -1960,14 +1960,14 @@ const BSS_LIST_CHUNK_SIZE: usize = 256;

/// The per-store overflow-block size is `count / 4`; this shared constant must
/// be >= the largest store's, i.e. the filename store's `8192 / 4`.
pub const BSS_OVERFLOW_BLOCK_SIZE: usize = 2048;
const BSS_OVERFLOW_BLOCK_SIZE: usize = 2048;

/// `#[repr(C)]` with `prev` before `data` so the inline `BSSList::tail` block's
/// scalar fields cluster at the front of the singleton mapping (see the layout
/// note on [`BSSList`]). Heap-allocated overflow blocks don't care about page
/// locality; the constraint is on the inline-tail instance.
#[repr(C)]
pub struct BSSListOverflowBlock<ValueType> {
struct BSSListOverflowBlock<ValueType> {
pub(crate) used: AtomicU16,
pub(crate) prev: Option<Box<BSSListOverflowBlock<ValueType>>>,
// Only `[0..used]` is initialized.
Expand Down
2 changes: 1 addition & 1 deletion src/bun_core/Global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ pub fn set_thread_name(name: &ZStr) {
// Safe `extern "C" fn()` — every registrant (C++ `Bun__atexit` lambdas, Rust
// `extern "C"` thunks in fs_events / ParentDeathWatchdog) takes no args and has
// no memory-safety preconditions, so the call site needs no `unsafe` block.
pub type ExitFn = extern "C" fn();
type ExitFn = extern "C" fn();

// Registration can happen from any thread (FFI `Bun__atexit`), so this is
// guarded with a Mutex.
Expand Down
6 changes: 2 additions & 4 deletions src/bun_core/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ pub use crate::build_options;

#[repr(u8)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum BuildTarget {
enum BuildTarget {
Native,
Wasm,
Wasi,
}

const BUILD_TARGET: BuildTarget = {
Expand All @@ -19,9 +18,8 @@ const BUILD_TARGET: BuildTarget = {

const IS_WASM: bool = matches!(BUILD_TARGET, BuildTarget::Wasm);
pub const IS_NATIVE: bool = matches!(BUILD_TARGET, BuildTarget::Native);
const IS_WASI: bool = matches!(BUILD_TARGET, BuildTarget::Wasi);
const IS_MAC: bool = IS_NATIVE && cfg!(target_os = "macos");
pub(crate) const IS_BROWSER: bool = !IS_WASI && IS_WASM;
pub(crate) const IS_BROWSER: bool = IS_WASM;
pub const IS_WINDOWS: bool = cfg!(windows);
pub(crate) const IS_POSIX: bool = !IS_WINDOWS && !IS_WASM;
/// `true` only for the `dev` cargo profile (Debug buildtype). Keyed on
Expand Down
Loading
Loading