Skip to content
Open
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
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
},

.translate_c = .{
.url = "git+https://codeberg.org/ziglang/translate-c#d67f0a5821b0c5ad16f60c425ad2af3499e7995f",
.hash = "translate_c-0.0.0-Q_BUWho9BwAx1Nyc_gDzXBjXZg62qETbgze15f50x29Y",
.url = "git+https://codeberg.org/ziglang/translate-c#3da873cacdd7e9190fe1cf40372ddf5387c970ea",
.hash = "translate_c-0.0.0-Q_BUWktLBwBO7VLbmrOKUcAMRtE5fmOxI35189X5XbJs",
},
},
}
24 changes: 24 additions & 0 deletions build/luajit-prng.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- lj_prng.c 2026-08-23 19:02:07.137486000 +0100
+++ lj_prng.c.patch 2026-08-23 19:07:14.481771000 +0100
@@ -128,6 +128,10 @@
#elif (LJ_TARGET_BSD && !defined(__NetBSD__)) || LJ_TARGET_SOLARIS || LJ_TARGET_CYGWIN || LJ_TARGET_QNX || LJ_TARGET_HURD
#define LJ_TARGET_HAS_GETENTROPY 1
#endif
+
+/* For the /dev/urandom fallback. */
+#include <fcntl.h>
+#include <unistd.h>

#if LJ_TARGET_HAS_GETENTROPY
extern int getentropy(void *buf, size_t len)
@@ -139,10 +143,6 @@

#endif

-/* For the /dev/urandom fallback. */
-#include <fcntl.h>
-#include <unistd.h>
-
#endif

#if LUAJIT_SECURITY_PRNG == 0
11 changes: 9 additions & 2 deletions build/luajit.zig
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
dynasm_run.addFileArg(upstream.path("dynasm/dynasm.lua"));
}

// Patch lj_prng.c for FreeBSD SSP
if (b.graph.host.result.os.tag == .freebsd) {
const prng_patch = applyPatchToFile(b, b.graph.host, upstream.path("src/lj_prng.c"), b.path("build/luajit-prng.patch"), "src/lj_prng.c");
prng_patch.run.addFileArg(prng_patch.output);
} else {
lib.addCSourceFile(.{ .file = upstream.path("src/lj_prng.c") });
}

// TODO: Many more flags to figure out
if (target.result.cpu.arch.endian() == .little) {
dynasm_run.addArgs(&.{ "-D", "ENDIAN_LE" });
Expand Down Expand Up @@ -203,7 +211,7 @@ pub fn configure(b: *Build, target: Build.ResolvedTarget, optimize: std.builtin.
library.step.dependOn(&buildvm_folddef.step);
library.step.dependOn(&buildvm_ljvm.step);

library.is_linking_libc = true;
library.root_module.link_libc = true;

lib.addCMacro("LUAJIT_UNWIND_EXTERNAL", "");
lib.linkSystemLibrary("unwind", .{});
Expand Down Expand Up @@ -264,7 +272,6 @@ const luajit_vm = luajit_lib ++ [_][]const u8{
"src/lj_udata.c",
"src/lj_meta.c",
"src/lj_debug.c",
"src/lj_prng.c",
"src/lj_state.c",
"src/lj_dispatch.c",
"src/lj_vmevent.c",
Expand Down