openresty / openresty/luajit2

Cannot compile luajit while using ISO C standards.

Open
#232 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.4k
Forks
252
Avg merge
7d 11h
Merged PRs (30d)
3

Description

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

The code fails to account in the situation in which Linux user would compile with C standards (POSIX disabled).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with 3rd/lua/luajit/src/lj_str_hash.c, especially str_hash_init_random around lines 188-197, and reproduce the reported gcc command using -std=c11. Done means LuaJIT compiles under the ISO C setting without the implicit-declaration errors for srandom and random.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.