fluent-bit: build: bundled LuaJIT generate invalid .a file on macOS
System information
- macOS 12.3.1
- architecture: arm64 (M1)
Command-line tools
clang --version
Apple clang version 13.1.6 (clang-1316.0.21.2.3)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
note: XCode is not installed, just command line tools
Issue
when trying to compile Fluent Bit, the linker complains about the object .a generated by the bundled LuaJIT:
[100%] Linking C shared library ../lib/libfluent-bit.dylib
ld: warning: ignoring file ../lib/libluajit.a, building for macOS-arm64 but attempting to link with file built for
unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture arm64:
"_luaL_loadfile", referenced from:
_flb_luajit_load_script in libfluent-bit.a(flb_luajit.c.o)
"_luaL_newstate", referenced from:
_flb_luajit_create in libfluent-bit.a(flb_luajit.c.o)
"_luaL_openlibs", referenced from:
_flb_luajit_create in libfluent-bit.a(flb_luajit.c.o)
Inspecting the file generated lib/libluajit.a we can see it has something wrong with it:
» lipo -info lib/libluajit.a
fatal error: /Library/Developer/CommandLineTools/usr/bin/lipo: archive with no architecture specification: lib/libluajit.a (can't determine architecture for it)
there is something wrong with our CMake rules, because if we take the same LuaJIT code and we build it with make (outside of Fluent Bit context), it builds just fine:
~/coding/LuaJIT (v2.1) » make edsiper@monox
==== Building LuaJIT 2.1.0-beta3 ====
/Library/Developer/CommandLineTools/usr/bin/make -C src
HOSTCC host/minilua.o
HOSTLINK host/minilua
DYNASM host/buildvm_arch.h
HOSTCC host/buildvm.o
HOSTCC host/buildvm_asm.o
HOSTCC host/buildvm_peobj.o
HOSTCC host/buildvm_lib.o
HOSTCC host/buildvm_fold.o
HOSTLINK host/buildvm
BUILDVM lj_vm.S
ASM lj_vm.o
CC lj_assert.o
CC lj_gc.o
BUILDVM lj_ffdef.h
CC lj_err.o
CC lj_char.o
BUILDVM lj_bcdef.h
CC lj_bc.o
....
AR libluajit.a
CC luajit.o
BUILDVM jit/vmdef.lua
DYNLINK libluajit.so
LINK luajit
OK Successfully built LuaJIT
==== Successfully built LuaJIT 2.1.0-beta3 ====
--------------------------------------------------------------------------------------------------------------------------------------------------------------
~/coding/LuaJIT (v2.1) » lipo -info src/libluajit.a edsiper@monox
Non-fat file: src/libluajit.a is architecture: arm64
-----------------------------
lipo tool returns the expected file format for the .a file.
Our LuaJIT build rules are in this file:
notes:
- no XCODE here
- no binutils
- using the latest xcode command line tools
- already tried different flags, same issue
any macOS wizard who can assist here ?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 21 (18 by maintainers)
We also moved cmake based LuaJIT compliation on https://github.com/fluent/fluent-bit/pull/6107. Could you check your issue on the current master?
Actually in my corner case they are, it’s failing