neko icon indicating copy to clipboard operation
neko copied to clipboard

OS/X ARM (M1 cpu) support?

Open mitchblank opened this issue 4 years ago • 2 comments

Right near the top of the main CMakeLists.txt:

set(CMAKE_OSX_ARCHITECTURES x86_64)

This causes the build to fail when building against ARM libraries before we even get to the point of having a binary to test. From https://github.com/Homebrew/homebrew-core/runs/1948673682?check_suite_focus=true :

: && /opt/homebrew/Library/Homebrew/shims/mac/super/clang -DNDEBUG -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 2.0.0 -current_version 2.3.0 -o bin/libneko.2.3.0.dylib -install_name libneko.2.dylib CMakeFiles/libneko.dir/vm/alloc.c.o CMakeFiles/libneko.dir/vm/builtins.c.o CMakeFiles/libneko.dir/vm/callback.c.o CMakeFiles/libneko.dir/vm/elf.c.o CMakeFiles/libneko.dir/vm/interp.c.o CMakeFiles/libneko.dir/vm/load.c.o CMakeFiles/libneko.dir/vm/objtable.c.o CMakeFiles/libneko.dir/vm/others.c.o CMakeFiles/libneko.dir/vm/hash.c.o CMakeFiles/libneko.dir/vm/module.c.o CMakeFiles/libneko.dir/vm/jit_x86.c.o CMakeFiles/libneko.dir/vm/threads.c.o  /opt/homebrew/lib/libgc.dylib  -ldl  -lm && :
ld: warning: ignoring file /opt/homebrew/lib/libgc.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_GC_all_interior_pointers", referenced from:
      _neko_gc_init in alloc.c.o

I don't have an M1 mac in my possession at the moment so I can't test this directly, but it looks like that hard-coding of x86_64 has been there since @andyli first added the cmake support https://github.com/HaxeFoundation/neko/commit/5334e62a6e8f3eae8af2d50cd456c2bda3c3b739

Does anyone know if other things are likely to break the architecture was not hardcoded? Obviously the JIT would be busted but I think that's disabled on OS/X anyway(?)

mitchblank avatar Feb 22 '21 04:02 mitchblank

Can confirm that this majorly breaks it.

[22/89] Building C object libs/std/CMakeFiles/std.ndll.dir/math.c.o
[23/89] Building C object libs/std/CMakeFiles/std.ndll.dir/string.c.o
[24/89] Building C object libs/std/CMakeFiles/std.ndll.dir/random.c.o
[25/89] Linking C shared library bin/libneko.2.3.0.dylib
FAILED: bin/libneko.2.3.0.dylib
: && /opt/homebrew/Library/Homebrew/shims/mac/super/clang -DNDEBUG -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -dynamiclib -Wl,-headerpad_max_install_names -compatibility_version 2.0.0 -current_version 2.3.0 -o bin/libneko.2.3.0.dylib -install_name libneko.2.dylib CMakeFiles/libneko.dir/vm/alloc.c.o CMakeFiles/libneko.dir/vm/builtins.c.o CMakeFiles/libneko.dir/vm/callback.c.o CMakeFiles/libneko.dir/vm/elf.c.o CMakeFiles/libneko.dir/vm/interp.c.o CMakeFiles/libneko.dir/vm/load.c.o CMakeFiles/libneko.dir/vm/objtable.c.o CMakeFiles/libneko.dir/vm/others.c.o CMakeFiles/libneko.dir/vm/hash.c.o CMakeFiles/libneko.dir/vm/module.c.o CMakeFiles/libneko.dir/vm/jit_x86.c.o CMakeFiles/libneko.dir/vm/threads.c.o  /opt/homebrew/lib/libgc.dylib  -ldl  -lm && :
ld: warning: ignoring file /opt/homebrew/lib/libgc.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
Undefined symbols for architecture x86_64:
  "_GC_all_interior_pointers", referenced from:
      _neko_gc_init in alloc.c.o
  "_GC_clear_roots", referenced from:
      _neko_gc_init in alloc.c.o
  "_GC_collect_a_little", referenced from:
      _neko_gc_loop in alloc.c.o
  "_GC_free", referenced from:
      _neko_free_root in alloc.c.o
  "_GC_gcollect", referenced from:
      _neko_gc_major in alloc.c.o
  "_GC_get_free_bytes", referenced from:
      _neko_gc_stats in alloc.c.o
  "_GC_get_heap_size", referenced from:
      _neko_gc_stats in alloc.c.o
  "_GC_init", referenced from:
      _neko_gc_init in alloc.c.o
  "_GC_java_finalization", referenced from:
      _neko_gc_init in alloc.c.o
  "_GC_malloc", referenced from:
      _neko_alloc in alloc.c.o
      _neko_alloc_array in alloc.c.o
      _neko_alloc_abstract in alloc.c.o
      _neko_alloc_function in alloc.c.o
      _neko_alloc_module_function in alloc.c.o
      _neko_alloc_apply in alloc.c.o
      _neko_alloc_object in alloc.c.o
      ...
  "_GC_malloc_atomic", referenced from:
      _neko_alloc_private in alloc.c.o
      _neko_alloc_empty_string in alloc.c.o
      _neko_alloc_float in alloc.c.o
      _neko_alloc_int32 in alloc.c.o
  "_GC_malloc_atomic_ignore_off_page", referenced from:
      _neko_alloc_private in alloc.c.o
      _neko_alloc_empty_string in alloc.c.o
  "_GC_malloc_ignore_off_page", referenced from:
      _neko_alloc in alloc.c.o
      _neko_alloc_array in alloc.c.o
  "_GC_malloc_uncollectable", referenced from:
      _neko_alloc_root in alloc.c.o
  "_GC_no_dls", referenced from:
      _neko_gc_init in alloc.c.o
  "_GC_pthread_create", referenced from:
      _neko_thread_create in threads.c.o
  "_GC_register_finalizer_no_order", referenced from:
      _neko_val_gc in alloc.c.o
  "_GC_set_warn_proc", referenced from:
      _neko_gc_init in alloc.c.o
ld: symbol(s) not found for architecture x86_64

foxt avatar Apr 12 '21 09:04 foxt

I believe this is being addressed on #224.

Uzume avatar Nov 01 '21 00:11 Uzume