Skip to content

[luajit] lj_prng.c patch for FreeBSD - #226

Open
urly3 wants to merge 2 commits into
natecraddock:mainfrom
urly3:luajit_prng_patch
Open

[luajit] lj_prng.c patch for FreeBSD#226
urly3 wants to merge 2 commits into
natecraddock:mainfrom
urly3:luajit_prng_patch

Conversation

@urly3

@urly3 urly3 commented Aug 23, 2026

Copy link
Copy Markdown

👋 hi;;;

While working on contributions to ly, which depends on this project, switching to FreeBSD meant that I could no longer build the project on ReleaseSafe.

The following error is received:

install
└─ install lua 
   └─ compile lib lua safe native 2 errors 
/usr/include/ssp/unistd.h:81:21: error: static declaration of 'getentropy' follows non-static declaration 
__ssp_redirect(int, getentropy, (void *__buf, size_t __len), (__buf, __len));
                    ^
zig-pkg/N-V-__8AAODpQgCVrpfzE2ze9FA_rOuByh3WKyIyk5iS_o9a/src/lj_prng.c:144:10: note: in file included from zig-pkg/N-V-__8AAODpQgCVrpfzE2ze9FA_rOuByh3WKyIyk5iS_o9a/src/lj_prng.c:144: 
#include <unistd.h>                                                                                                          ^

/usr/include/unistd.h:41:10: note: in file included from /usr/include/unistd.h:41:
#include <ssp/unistd.h> 
         ^
zig-pkg/N-V-__8AAODpQgCVrpfzE2ze9FA_rOuByh3WKyIyk5iS_o9a/src/lj_prng.c:133:12: note: previous declaration is here
extern int getentropy(void *buf, size_t len)

This is because of SSP being enabled by ReleaseSafe, overwriting the getentropy function with a a static declaration in FreeBSD libc, and since Luajit imports the header after defining it as extern, the compiler isn't happy.

This patch moves the import above the extern declaration on FreeBSD to prevent this.

Included is also a fix to have it compile on the latest zig-17dev (linking_lib_c).

@urly3
urly3 force-pushed the luajit_prng_patch branch from d580b4e to 1d4f8df Compare August 23, 2026 21:04
@natecraddock

Copy link
Copy Markdown
Owner
zig-pkg/aro-0.0.0-JSD1QuExNwB42gF8n_po5TPPtl1GQwr9o7XFYxNce_vL/build/generate_def.zig:427:31: error: no field or member function named 'getLast' in 'array_list.Aligned(generate_def.DafsaBuilder.UncheckedNode,null)'
            db.unchecked_nodes.getLast().?.child;
            ~~~~~~~~~~~~~~~~~~^~~~~~~~

Compile failure in aro, so I wonder if this means translate-c needs an update?

@AnErrupTion

Copy link
Copy Markdown
Contributor
zig-pkg/aro-0.0.0-JSD1QuExNwB42gF8n_po5TPPtl1GQwr9o7XFYxNce_vL/build/generate_def.zig:427:31: error: no field or member function named 'getLast' in 'array_list.Aligned(generate_def.DafsaBuilder.UncheckedNode,null)'
            db.unchecked_nodes.getLast().?.child;
            ~~~~~~~~~~~~~~~~~~^~~~~~~~

Compile failure in aro, so I wonder if this means translate-c needs an update?

It does: https://codeberg.org/ziglang/translate-c/commit/32dde9bff199152a6cc4ddc77e0e79cc9a3e57fc

@urly3

urly3 commented Aug 24, 2026

Copy link
Copy Markdown
Author

Ah, I don't get any errors when building with 0.17.0-dev.1857+3c46da14d so didn't catch this, not sure why that is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants