diff --git a/docs/runtime/ffi.mdx b/docs/runtime/ffi.mdx index d64e3e7dbe..eb96480b99 100644 --- a/docs/runtime/ffi.mdx +++ b/docs/runtime/ffi.mdx @@ -358,7 +358,7 @@ Bun represents [pointers]( diff --git a/src/cli.zig b/src/cli.zig index dc27a8af17..e2a62330cc 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -464,6 +464,7 @@ pub const Command = struct { compile_autoload_bunfig: bool = true, compile_autoload_tsconfig: bool = false, compile_autoload_package_json: bool = false, + compile_executable_path: ?[]const u8 = null, windows: options.WindowsOptions = .{}, }; diff --git a/src/cli/Arguments.zig b/src/cli/Arguments.zig index df210067ae..b8b3033d9e 100644 --- a/src/cli/Arguments.zig +++ b/src/cli/Arguments.zig @@ -158,6 +158,7 @@ pub const build_only_params = [_]ParamType{ clap.parseParam("--no-compile-autoload-tsconfig Disable autoloading of tsconfig.json at runtime in standalone executable") catch unreachable, clap.parseParam("--compile-autoload-package-json Enable autoloading of package.json at runtime in standalone executable (default: false)") catch unreachable, clap.parseParam("--no-compile-autoload-package-json Disable autoloading of package.json at runtime in standalone executable") catch unreachable, + clap.parseParam("--compile-executable-path Path to a Bun executable to use for cross-compilation instead of downloading") catch unreachable, clap.parseParam("--bytecode Use a bytecode cache") catch unreachable, clap.parseParam("--watch Automatically restart the process on file change") catch unreachable, clap.parseParam("--no-clear-screen Disable clearing the terminal screen on reload when --watch is enabled") catch unreachable, @@ -1106,6 +1107,14 @@ pub fn parse(allocator: std.mem.Allocator, ctx: Command.Context, comptime cmd: C } } + if (args.option("--compile-executable-path")) |path| { + if (!ctx.bundler_options.compile) { + Output.errGeneric("--compile-executable-path requires --compile", .{}); + Global.crash(); + } + ctx.bundler_options.compile_executable_path = path; + } + if (args.flag("--windows-hide-console")) { // --windows-hide-console technically doesnt depend on WinAPI, but since since --windows-icon // does, all of these customization options have been gated to windows-only diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig index 91ec5b2e59..73e31338d3 100644 --- a/src/cli/build_command.zig +++ b/src/cli/build_command.zig @@ -468,7 +468,7 @@ pub const BuildCommand = struct { this_transpiler.options.output_format, ctx.bundler_options.windows, ctx.bundler_options.compile_exec_argv orelse "", - null, + ctx.bundler_options.compile_executable_path, .{ .disable_default_env_files = !ctx.bundler_options.compile_autoload_dotenv, .disable_autoload_bunfig = !ctx.bundler_options.compile_autoload_bunfig, diff --git a/src/macho.zig b/src/macho.zig index 9e8060b6e2..50d30abacd 100644 --- a/src/macho.zig +++ b/src/macho.zig @@ -77,8 +77,8 @@ pub const MachoFile = struct { found_bun = true; original_fileoff = sect.offset; original_vmaddr = sect.addr; - original_data_end = original_fileoff + blob_alignment; - original_segsize = sect.size; + original_data_end = command.fileoff + command.filesize; + original_segsize = command.filesize; self.segment = command; self.section = sect.*;