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

luajit-2.1.0-beta3安装失败 #4553

Open
hyt589 opened this issue Jul 3, 2024 · 10 comments
Open

luajit-2.1.0-beta3安装失败 #4553

hyt589 opened this issue Jul 3, 2024 · 10 comments
Labels

Comments

@hyt589
Copy link

hyt589 commented Jul 3, 2024

Xmake 版本

v2.9.3+20240624

操作系统版本和架构

macOS Ventura 13.6, Apple M1

描述问题

安装luajit时出现编译错误,下面是错误日志:

note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
  -> luajit 2.1.0-beta3
please input: y (y/n/m)
y
  => install luajit 2.1.0-beta3 .. failed

[  9%]: cache compiling.release src/host/minilua.c
src/host/minilua.c:1350:8: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if(((n)==(0)))
    ~~~^~~~~
src/host/minilua.c:1350:8: note: remove extraneous parentheses around the comparison to silence this warning
if(((n)==(0)))
   ~   ^    ~
src/host/minilua.c:1350:8: note: use '=' to turn this equality comparison into an assignment
if(((n)==(0)))
       ^~
       =
src/host/minilua.c:1382:16: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if((((key)->tt)==0))return-1;
    ~~~~~~~~~~~^~~
src/host/minilua.c:1382:16: note: remove extraneous parentheses around the comparison to silence this warning
if((((key)->tt)==0))return-1;
   ~           ^  ~
if you want to get more verbose errors, please see:
  -> /Users/huangyutong01/.xmake/cache/packages/2407/l/luajit/2.1.0-beta3/installdir.failed/logs/install.txt
error: install failed!
error: execv(/opt/homebrew/bin/xmake require -j 10 --extra={system=false} "luajit 2.1.0-beta3") failed(255)

期待的结果

可以成功安装luajit 2.1.0-beta3

工程配置

直接使用xrepo命令进行安装:

xrepo install "luajit 2.1.0-beta3"

附加信息和错误日志

verbose的编译日志:

[  9%]: cache compiling.release src/host/minilua.c
src/host/minilua.c:1350:8: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if(((n)==(0)))
    ~~~^~~~~
src/host/minilua.c:1350:8: note: remove extraneous parentheses around the comparison to silence this warning
if(((n)==(0)))
   ~   ^    ~
src/host/minilua.c:1350:8: note: use '=' to turn this equality comparison into an assignment
if(((n)==(0)))
       ^~
       =
src/host/minilua.c:1382:16: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
if((((key)->tt)==0))return-1;
    ~~~~~~~~~~~^~~
src/host/minilua.c:1382:16: note: remove extraneous parentheses around the comparison to silence this warning
if((((key)->tt)==0))return-1;
   ~           ^  ~
[ 13%]: linking.release minilua
[ 31%]: cache compiling.release src/host/buildvm.c
[ 36%]: cache compiling.release src/host/buildvm_peobj.c
[ 40%]: cache compiling.release src/host/buildvm_asm.c
[ 45%]: cache compiling.release src/host/buildvm_lib.c
[ 50%]: cache compiling.release src/host/buildvm_fold.c
error: build_dda21c61/.objs/buildvm/macosx/arm64/release/buildvm_arch.h:5883:33: error: no member named 'J' in 'GG_State'
  dasm_put(Dst, 2504, GG_G2DISP+GG_DISP2J, (unsigned int)(LJ_GCVMASK), (unsigned int)((unsigned long long)(LJ_GCVMASK)>>32), Dt7(->pc), GL_J(L), PC2PROTO(framesize), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->base), (unsigned int)(LJ_GCVMASK), (unsigned int)((unsigned long long)(LJ_GCVMASK)>>32), (unsigned int)(LJ_GCVMASK), (unsigned int)((unsigned long long)(LJ_GCVMASK)>>32));
                                ^~~~~~~~~
src/lj_dispatch.h:113:20: note: expanded from macro 'GG_DISP2J'
#define GG_DISP2J       (GG_OFS(J) - GG_OFS(dispatch))
                         ^      ~
src/lj_dispatch.h:103:29: note: expanded from macro 'GG_OFS'
#define GG_OFS(field)   ((int)offsetof(GG_State, field))
                              ^                  ~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/include/stddef.h:105:24: note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
In file included from src/host/buildvm.c:73:
build_dda21c61/.objs/buildvm/macosx/arm64/release/buildvm_arch.h:5883:137: error: no member named 'J' in 'GG_State'
  dasm_put(Dst, 2504, GG_G2DISP+GG_DISP2J, (unsigned int)(LJ_GCVMASK), (unsigned int)((unsigned long long)(LJ_GCVMASK)>>32), Dt7(->pc), GL_J(L), PC2PROTO(framesize), Dt1(->base), Dt1(->top), Dt1(->base), Dt1(->base), (unsigned int)(LJ_GCVMASK), (unsigned int)((unsigned long long)(LJ_GCVMASK)>>32), (unsigned int)(LJ_GCVMASK), (unsigned int)((unsigned long long)(LJ_GCVMASK)>>32));
                                                                                                                                        ^~~~~~~
build_dda21c61/.objs/buildvm/macosx/arm64/release/buildvm_arch.h:5806:22: note: expanded from macro 'GL_J'
  > in src/host/buildvm.c
warning: ./xmake.lua:199: cannot match add_files("src/lib_buffer.c") in target(luajit)
@hyt589 hyt589 added the bug label Jul 3, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: luajit-2.1.0-beta3 installation failed

@waruqi
Copy link
Member

waruqi commented Jul 3, 2024

macos arm64 是后来新加的,之前 ci 上没适配。。可以提个 pr 过来直接修下

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


macos arm64 was added later and was not adapted on ci before. . You can submit a PR and fix it directly.

@hyt589
Copy link
Author

hyt589 commented Jul 3, 2024

macos arm64 是后来新加的,之前 ci 上没适配。。可以提个 pr 过来直接修下

好的,可以指点一下应该看哪里的代码吗?对这个项目还不太熟悉😅

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


macos arm64 was added later and was not adapted on ci before. . You can submit a PR and fix it directly.

Okay, can you give me some pointers on where to look at the code? Not very familiar with this project😅

@waruqi
Copy link
Member

waruqi commented Jul 4, 2024

可以调下这个 port 文件。https://github.com/xmake-io/xmake-repo/blob/dev/packages/l/luajit/port/xmake.lua

然后 clone 这个 repo 后执行 xmake l scripts/test.lua -vD --shallow luajit 来快速测试验证

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


You can adjust this port file. https://github.com/xmake-io/xmake-repo/blob/dev/packages/l/luajit/port/xmake.lua

Then clone this repo and execute xmake l scripts/test.lua -vD --shallow luajit to quickly test and verify

@hyt589
Copy link
Author

hyt589 commented Jul 5, 2024

checkout了luajit 2.1.0-beta3看了一下,似乎是LuaJIT这个节点本身对平台的检测有点问题,在src/lj_arch.h中发现下面的代码:

#define LJ_TARGET_IOS		(LJ_TARGET_OSX && (LUAJIT_TARGET == LUAJIT_ARCH_ARM || LUAJIT_TARGET == LUAJIT_ARCH_ARM64))

这里认为如果系统是OSX且架构是ARM或者ARM64,那么系统就是IOS,也就是说M1也被认定成了IOS。

#if LJ_TARGET_IOS || LJ_TARGET_CONSOLE
/* Runtime code generation is restricted on iOS. Complain to Apple, not me. */
/* Ditto for the consoles. Complain to Sony or MS, not me. */
#ifndef LUAJIT_ENABLE_JIT
#define LJ_OS_NOJIT		1
#endif
#endif

然后IOS不支持JIT,并把LJ_OS_NOJIT定义为1,并且后面据此把LJ_HASJIT定义为0:

/* Disable or enable the JIT compiler. */
#if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT)
#define LJ_HASJIT		0
#else
#define LJ_HASJIT		1
#endif

最后导致了GG_Steate中的J成员没有被定义,在宏展开的时候出现编译错误:

/* Global state, main thread and extra fields are allocated together. */
typedef struct GG_State {
  lua_State L;				/* Main thread. */
  global_State g;			/* Global state. */
#if LJ_TARGET_MIPS
  ASMFunction got[LJ_GOT__MAX];		/* Global offset table. */
#endif
#if LJ_HASJIT
  jit_State J;				/* JIT state. */
  HotCount hotcount[HOTCOUNT_SIZE];	/* Hot counters. */
#endif
  ASMFunction dispatch[GG_LEN_DISP];	/* Instruction dispatch tables. */
  BCIns bcff[GG_NUM_ASMFF];		/* Bytecode for ASM fast functions. */
} GG_State;

我还试了一下直接用LuaJIT本来的Makefile编译,发现这种情况下clangd显示LUAJIT_TARGET是x64,并且编译可以成功,所以现在有一个假设就是LuaJIT在M1上应该编译x64的版本然后在运行时转译?

@waruqi
Copy link
Member

waruqi commented Jul 5, 2024

不清楚,这边也没 m1 测试。。你可以自己看下,如果能修,就提个 pr 过来

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Not sure, there is no m1 test here either. . You can take a look at it yourself, and if you can fix it, submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants