Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile luajit due to -std=c11 #294

Closed
SlawekNowy opened this issue May 27, 2024 · 6 comments · Fixed by #295
Closed

Cannot compile luajit due to -std=c11 #294

SlawekNowy opened this issue May 27, 2024 · 6 comments · Fixed by #295

Comments

@SlawekNowy
Copy link
Contributor


gcc -MMD -MT build/linux-x64/release/obj/lj_str_hash.c/lj_str_hash.obj -MF build/linux-x64/release/obj/lj_str_hash.c/lj_str_hash.obj.d -std=c11 -O2 -Wall -fvisibility=hidden -I3rd/lua/luajit/src -DLUAJIT_UNWIND_EXTERNAL -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -DLUA_MULTILIB="lib" -DLUAJIT_ENABLE_LUA52COMPAT -DLUAJIT_NUMMODE=2 -DNDEBUG -fno-stack-protector -U_FORTIFY_SOURCE -fPIC -msse4.2 -o build/linux-x64/release/obj/lj_str_hash.c/lj_str_hash.obj -c 3rd/lua/luajit/src/lj_str_hash.c
3rd/lua/luajit/src/lj_str_hash.c: In function ‘str_hash_init_random’:
3rd/lua/luajit/src/lj_str_hash.c:188:3: error: implicit declaration of function ‘srandom’; did you mean ‘srand’? [-Wimplicit-function-declaration]
  188 |   srandom(seed);
      |   ^~~~~~~
      |   srand
3rd/lua/luajit/src/lj_str_hash.c:197:24: error: implicit declaration of function ‘random’; did you mean ‘rand’? [-Wimplicit-function-declaration]
  197 |     random_pos[i][0] = random() & POW2_MASK(i+1);
      |                        ^~~~~~
      |                        rand
@SlawekNowy
Copy link
Contributor Author

Both random and srandom are POSIX functions, which is not in C standard.

@actboy168
Copy link
Owner

I don't have a test environment. Maybe need to define the _XOPEN_SOURCE macro.

@SlawekNowy
Copy link
Contributor Author

SlawekNowy commented May 28, 2024

Submitted the issue to submodule with the fix:
openresty/luajit2#232.
The fix is in C file due to luamake not accepting gnu89 as valid value for luamake::c prop.

@actboy168
Copy link
Owner

I've added gnu support to luamake, but I think just define _XOPEN_SOURCE, like lua51/lua52 does.

defines = {
luaver == "lua51" and "_XOPEN_SOURCE=600",
luaver == "lua52" and "_XOPEN_SOURCE=600",
luaver == "lua-latest" and "LUA_VERSION_LATEST",
},

@SlawekNowy
Copy link
Contributor Author

SlawekNowy commented May 31, 2024

I would add this to lj_str_hash target which was convienently sepatared from the rest.

@SlawekNowy
Copy link
Contributor Author

Confirmed that adding _XOPEN_SOURCE=600 for defines is sufficient.

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 a pull request may close this issue.

2 participants