HaxeFoundation/hashlink

Can't run any .hl file on Mac M1 - Segmentation Fault

RedRoosterMobile opened this issue · 2 comments

Hello from a returning noob (last time I build sth. with haxe was in 2012)

I'm on a Mac M1 Pro. (Sonoma 14.1.2)

I have the following basic haxe file: HelloWorld.hx

class HelloWorld {
	static public function main() {
		trace("Hello World!");
	}
}

I can build it for a number of targets:

# js
haxe -main HelloWorld --js HelloWorld.js
# internal interpreter
haxe -main HelloWorld --interp
# hashlink / hl
haxe -main HelloWorld -hl HelloWorld.hl

I can also run them all EXCEPT HelloWorld.hl
This happens with any hl file that I try to run with hashlink

hl HelloWorld.hl
zsh: segmentation fault  hl HelloWorld.hl

some further info:

lldb hl HelloWorld.hl
(lldb) target create "hl"
Current executable set to '/usr/local/bin/hl' (arm64).
(lldb) settings set -- target.run-args  "HelloWorld.hl"
(lldb) run
Process 11879 launched: '/usr/local/bin/hl' (arm64)
Process 11879 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffff)
    frame #0: 0x000000018d44369c libsystem_platform.dylib`_platform_memmove + 76
libsystem_platform.dylib`:
->  0x18d44369c <+76>: stnp   q2, q3, [x0]
    0x18d4436a0 <+80>: subs   x2, x2, #0x40
    0x18d4436a4 <+84>: b.ls   0x18d4436c0               ; <+112>
    0x18d4436a8 <+88>: stnp   q0, q1, [x3]
Target 0: (hl) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xffffffffffffffff)
  * frame #0: 0x000000018d44369c libsystem_platform.dylib`_platform_memmove + 76
    frame #1: 0x0000000100017a20 hl`hl_jit_code + 120
    frame #2: 0x000000010001b510 hl`hl_module_init + 444
    frame #3: 0x000000010001a844 hl`main + 628
    frame #4: 0x000000018d0990e0 dyld`start + 2360
(lldb) bt

HL/JIT 1.14.0 (c)2015-2023 Haxe Foundation
  Usage : hl [--debug <port>] [--debug-wait] <file>

I compiled hl by checking out the this repo, runnning the homebrew commands, signing it and, make install and so on as the README states. No errors here.

Here is the output for the make command

make
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -o libhl.dylib -m64  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib  -install_name @rpath/libhl.dylib -shared include/pcre/pcre2_auto_possess.o include/pcre/pcre2_chartables.o include/pcre/pcre2_compile.o include/pcre/pcre2_config.o include/pcre/pcre2_context.o include/pcre/pcre2_convert.o include/pcre/pcre2_dfa_match.o include/pcre/pcre2_error.o include/pcre/pcre2_extuni.o include/pcre/pcre2_find_bracket.o include/pcre/pcre2_jit_compile.o include/pcre/pcre2_maketables.o include/pcre/pcre2_match_data.o include/pcre/pcre2_match.o include/pcre/pcre2_newline.o include/pcre/pcre2_ord2utf.o include/pcre/pcre2_pattern_info.o include/pcre/pcre2_script_run.o include/pcre/pcre2_serialize.o include/pcre/pcre2_string_utils.o include/pcre/pcre2_study.o include/pcre/pcre2_substitute.o include/pcre/pcre2_substring.o include/pcre/pcre2_tables.o include/pcre/pcre2_ucd.o include/pcre/pcre2_valid_utf.o include/pcre/pcre2_xclass.o src/gc.o src/std/array.o src/std/buffer.o src/std/bytes.o src/std/cast.o src/std/date.o src/std/error.o src/std/debug.o src/std/file.o src/std/fun.o src/std/maps.o src/std/math.o src/std/obj.o src/std/random.o src/std/regexp.o src/std/socket.o src/std/string.o src/std/sys.o src/std/types.o src/std/ucs2.o src/std/thread.o src/std/process.o src/std/track.o -lpthread -lm
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -o hl src/code.o src/jit.o src/main.o src/module.o src/debugger.o src/profile.o -L. -lhl -Wl,-export_dynamic  -Wl,-export_dynamic -L/usr/local/lib -arch arm64 -rpath @executable_path -rpath /usr/local/lib  -ldl
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o fmt.hdll libs/fmt/fmt.o libs/fmt/sha1.o include/mikktspace/mikktspace.o libs/fmt/mikkt.o libs/fmt/dxt.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl -lpng -lturbojpeg -lz -lvorbisfile
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o sdl.hdll libs/sdl/sdl.o libs/sdl/gl.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl -lSDL2 -framework OpenGL
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o ssl.hdll libs/ssl/ssl.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl -lmbedtls -lmbedx509 -lmbedcrypto -framework Security -framework CoreFoundation
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o openal.hdll libs/openal/openal.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl -lopenal
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o ui.hdll libs/ui/ui_stub.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o uv.hdll libs/uv/uv.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl -luv
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o mysql.hdll libs/mysql/socket.o libs/mysql/sha1.o libs/mysql/my_proto.o libs/mysql/my_api.o libs/mysql/mysql.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl
cc -Wall -O3 -I src -std=c11 -D LIBHL_EXPORTS -m64 -I include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/jpeg-turbo/include -I /opt/homebrew/opt/sdl2/include -I /opt/homebrew/opt/libvorbis/include -I /opt/homebrew/opt/mbedtls/include -I /opt/homebrew/opt/libpng/include -I /opt/homebrew/opt/libogg/include -I /opt/homebrew/opt/libuv/include -I /opt/homebrew/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -m64 -I include -I /usr/local/include -I /usr/local/opt/libjpeg-turbo/include -I /usr/local/opt/jpeg-turbo/include -I /usr/local/opt/sdl2/include -I /usr/local/opt/libvorbis/include -I /usr/local/opt/openal-soft/include -Dopenal_soft  -DGL_SILENCE_DEPRECATION -arch arm64 -shared -o sqlite.hdll libs/sqlite/sqlite.o  -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/sdl2/lib -L/opt/homebrew/opt/jpeg-turbo/lib -L/opt/homebrew/opt/libvorbis/lib -L/opt/homebrew/opt/openal-soft/lib -L/opt/homebrew/opt/mbedtls/lib -L/opt/homebrew/opt/libpng/lib -L/opt/homebrew/opt/libogg/lib -L/opt/homebrew/opt/libuv/lib -rpath @executable_path -rpath /usr/local/lib -L. -lhl -lsqlite3

Any hints here?

Mac core dump:
hl-2024-03-25-194326.ips.txt

HL/JIT does not support ARM, you need to build and run it via Rosetta.

Does that mean I need to get the libs and everything build in x86 , then build the hl and all of that in rosetta?

One hell of a task, haha.

Thanks for the info, I was banging my head against this