nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32

Home Page:https://nodemcu.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ziglang build broken on macOS

tomsci opened this issue · comments

commented

Trying to build dev-esp32 branch @ 32d03a2 on macOS 13.3.1 on Apple Silicon appears to be hitting a bug in ziglang while compiling luac.cross (output trimmed to only include relevant stuff):

$ make
/nodemcu-firmware/sdk/esp32-esp-idf/tools/idf.py  "all"
Executing action: all (aliases: build)
Running make in directory /nodemcu-firmware/build
Executing "make -j 12 all"...
-- Building ESP-IDF components for target esp32
-- Project sdkconfig file /nodemcu-firmware/sdkconfig
Loading defaults file /nodemcu-firmware/sdkconfig.defaults...
-- App "nodemcu" version: 1.4.0-master_20151229-880-g4e9b
[  1%] Performing build step for 'luac_cross_build'
[hostcc] luac.o
<snip>
[hostcc] lundump.o
MachO Flush... [hostcc] lutf8lib.o
[hostcc] lvm.o
MachO Flush... [hostcc] lzio.o
[hostcc] linit.o
[hostcc] lpanic.o
MachO Flush... MachO Flush... [hostcc] uzlib_deflate.o
[hostcc] crc32.o
[ link] luac.cross
MachO Flush... error(link): undefined reference to symbol 'dyld_stub_binder'
error: UndefinedSymbolReference
make[4]: *** [/nodemcu-firmware/build/luac_cross/luac.cross] Error 1
make[3]: *** [luac_cross/src/luac_cross_build-stamp/luac_cross_build-build] Error 2
make[2]: *** [esp-idf/lua/CMakeFiles/luac_cross_build.dir/all] Error 2
make[2]: *** Waiting for unfinished jobs....

This appears to be the same issue as ziglang/zig#11896 which has been open for a while and maaaaybe will be fixed in the next version 0.11 (it's on their milestones but not yet fixed, so who knows if it gets pushed out or not).

Looking at how zig is used here, it seems to be a wrapper around clang? At least for me, this patch to just not use it at all fixed the issue:

diff --git a/components/lua/lua-5.3/host/idf.mk b/components/lua/lua-5.3/host/idf.mk
index 8dfba397..b1ccfe94 100644
--- a/components/lua/lua-5.3/host/idf.mk
+++ b/components/lua/lua-5.3/host/idf.mk
@@ -1,6 +1,6 @@
 all: build
 
-HOSTCC?=$(PYTHON) -m ziglang cc
+HOSTCC?=cc
 
 ifeq ($V,)
   Q:=@

I found this comment referencing zig #1661 (comment) so I guess it's here for the cases where you don't have a host C compiler? Maybe we can make it configurable for the cases where hostcc is available and works, but zig doesn't? Just a thought, for now I've just added the above patch to my branch, but I figured I should raise this if only for other people hitting the same issue to search for!