shakacode / re-formality

Form validation tool for reason-react
https://re-formality.now.sh
MIT License
244 stars 36 forks source link

Native apple arm support #109

Closed maxkorp closed 2 years ago

maxkorp commented 2 years ago

Hi! I'm in the process of trying to get everything on my team moved from rosetta to full native m1 support. Is there anything planned already? I'm happy to dedicate work hours or other resources to this if that is helpful. I've not done much with PPXs or any ocaml native builds of anything, but my primary focus on the team now is our tooling, and we use re-formality ppx heavily so I'm happy to dive in.

alex35mil commented 2 years ago

Hey @maxkorp! TBH I'm pretty much in the same boat in terms of native OCaml experience: it's limited to a couple of PPXes, and that's it. I haven't looked yet into native OCaml + apple silicon. I'd appreciate any help since I'm not sure when I'll be able to look into it. But definitely, not earlier than my new mac arrives. Retailer estimated Jan/Feb next year.

maxkorp commented 2 years ago

Well previously I had to do some silly things to get esy working natively, although that appears to be fixed with the latest release (0.6.12) that came out the other day. Using that, I'm able to get re-formality to build natively, which was much easier than anticipated.

I guess the tricky part here will be publishing, since theres no apple arm64 boxes for github actions that I know of (I've also never used actions so please bear with me here). I'm happy to provide builds, (or hardware we can use), whatever would work.

If I wanted to experiment with this on other machines, I'd want to publish the contents of ./lib to a git repo to target in consuming projects, correct?

happylinks commented 2 years ago

Just because I missed it, for other people who come across this post: this seems already fixed in the latest beta because of https://github.com/shakacode/re-formality/pull/106, just update the package and it should work :)

maxkorp commented 2 years ago

@happylinks so that allows it to work in rosetta (so running the x64 binary on arm via emulation). I'm talking about compiling it natively for arm64.

alex35mil commented 2 years ago

@maxkorp @happylinks I finally got my M1 and I'll look into it sometime next week.

alex35mil commented 2 years ago

@maxkorp Did you have issues compiling OCaml? I'm seeing this error:

$ which gcc
/nix/store/lrzpgjmdfw7m3w3hd2fa6aafwbg9526z-gcc-wrapper-11.2.0/bin/gcc

$ esy
info esy 0.6.12 (using esy.json)
info building ocaml@4.12.0@d41d8cd9
error: build failed with exit code: 1
  build log:
    # esy-build-package: building: ocaml@4.12.0
    # esy-build-package: pwd: /Users/Alex/.esy/3/b/ocaml-4.12.0-3a04ec8f
    # esy-build-package: running: './esy-configure' '--disable-cfi' '--prefix' '/Users/Alex/.esy/3___________________________________________________________________/s/ocaml-4.12.0-3a04ec8f'
    [esy-configure] Detected OSX / Linux environment
    configure: Configuring OCaml version 4.12.0
    checking build system type... aarch64-apple-darwin21.3.0
    checking host system type... aarch64-apple-darwin21.3.0
    checking target system type... aarch64-apple-darwin21.3.0
    checking for ld... ld
    checking how to print strings... printf
    checking for gcc... gcc
    checking whether the C compiler works... no
    configure: error: in `/Users/Alex/.esy/3/b/ocaml-4.12.0-3a04ec8f':
    configure: error: C compiler cannot create executables
    See `config.log' for more details
    error: command failed: './esy-configure' '--disable-cfi' '--prefix' '/Users/Alex/.esy/3___________________________________________________________________/s/ocaml-4.12.0-3a04ec8f' (exited with 77)
    esy-build-package: exiting with errors above...

  building ocaml@4.12.0
esy: exiting due to errors above
config.log ``` This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by OCaml configure 4.12.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ ./configure --disable-cfi --prefix /Users/Alex/.esy/3___________________________________________________________________/s/ocaml-4.12.0-3a04ec8f ## --------- ## ## Platform. ## ## --------- ## hostname = 192.168.0.10 uname -m = arm64 uname -r = 21.3.0 uname -s = Darwin uname -v = Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 /usr/bin/uname -p = arm /bin/uname -X = unknown /bin/arch = unknown /usr/bin/arch -k = unknown /usr/convex/getsysinfo = unknown /usr/bin/hostinfo = Mach kernel version: Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 Kernel configured for up to 10 processors. 10 processors are physically available. 10 processors are logically available. Processor type: arm64e (ARM64E) Processors active: 0 1 2 3 4 5 6 7 8 9 Primary memory available: 64.00 gigabytes Default processor set: 753 tasks, 4724 threads, 10 processors Load average: 1.85, Mach factor: 8.24 /bin/machine = unknown /usr/bin/oslevel = unknown /bin/universe = unknown PATH: /usr/local/bin PATH: /usr/bin PATH: /bin PATH: /usr/sbin PATH: /sbin ## ----------- ## ## Core tests. ## ## ----------- ## configure:2755: Configuring OCaml version 4.12.0 configure:2949: checking build system type configure:2963: result: aarch64-apple-darwin21.3.0 configure:2983: checking host system type configure:2996: result: aarch64-apple-darwin21.3.0 configure:3016: checking target system type configure:3029: result: aarch64-apple-darwin21.3.0 configure:3386: checking for ld configure:3402: found /usr/bin/ld configure:3413: result: ld configure:3492: checking how to print strings configure:3519: result: printf configure:3588: checking for gcc configure:3604: found /usr/bin/gcc configure:3615: result: gcc configure:3844: checking for C compiler version configure:3853: gcc --version >&5 Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin objc[88184]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x103d682c8). One of the two will be used. Which one is undefined. objc[88184]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x103d68318). One of the two will be used. Which one is undefined. gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-epXhXvbX' (errno=Operation not permitted) gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-Pq3FNgsP' (errno=Operation not permitted) Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 objc[88189]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1080942c8). One of the two will be used. Which one is undefined. objc[88189]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108094318). One of the two will be used. Which one is undefined. xcrun: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-tSx93B7v' (errno=Operation not permitted) configure:3864: $? = 0 configure:3853: gcc -v >&5 objc[88195]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10833c2c8). One of the two will be used. Which one is undefined. objc[88195]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10833c318). One of the two will be used. Which one is undefined. gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-qWWzNkEM' (errno=Operation not permitted) gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-0uO6yErN' (errno=Operation not permitted) Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1 objc[88200]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1059942c8). One of the two will be used. Which one is undefined. objc[88200]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105994318). One of the two will be used. Which one is undefined. xcrun: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-DrQTLWIJ' (errno=Operation not permitted) Apple clang version 13.0.0 (clang-1300.0.29.30) Target: arm64-apple-darwin21.3.0 ... rest of stderr output deleted ... configure:3864: $? = 0 configure:3853: gcc -V >&5 objc[88206]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107a702c8). One of the two will be used. Which one is undefined. objc[88206]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107a70318). One of the two will be used. Which one is undefined. gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-i7uuuezP' (errno=Operation not permitted) gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-zbl5oNSQ' (errno=Operation not permitted) objc[88209]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107d842c8). One of the two will be used. Which one is undefined. objc[88209]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x107d84318). One of the two will be used. Which one is undefined. xcrun: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-cvlX1Cf4' (errno=Operation not permitted) clang: error: argument to '-V' is missing (expected 1 value) clang: error: no input files configure:3864: $? = 1 configure:3853: gcc -qversion >&5 objc[88215]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10658c2c8). One of the two will be used. Which one is undefined. objc[88215]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x10658c318). One of the two will be used. Which one is undefined. gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-jpp1uVf8' (errno=Operation not permitted) gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-0LuHpabl' (errno=Operation not permitted) objc[88218]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1080cc2c8). One of the two will be used. Which one is undefined. objc[88218]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1080cc318). One of the two will be used. Which one is undefined. xcrun: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-Kxh6cqxj' (errno=Operation not permitted) clang: error: unknown argument '-qversion'; did you mean '--version'? clang: error: no input files configure:3864: $? = 1 configure:3884: checking whether the C compiler works configure:3906: gcc conftest.c >&5 objc[88229]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105c882c8). One of the two will be used. Which one is undefined. objc[88229]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105c88318). One of the two will be used. Which one is undefined. gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-Ej0XeVlG' (errno=Operation not permitted) gcc: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-7mJHVP8h' (errno=Operation not permitted) objc[88232]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1084fc2c8). One of the two will be used. Which one is undefined. objc[88232]: Class AMSupportURLSession is implemented in both /usr/lib/libamsupport.dylib (0x1fd66b6c8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x1084fc318). One of the two will be used. Which one is undefined. xcrun: error: couldn't create cache file '/var/folders/_m/x4lnn7nj77sdq_0mf90ccr_00000gn/T/xcrun_db-KtEonMka' (errno=Operation not permitted) clang: error: unable to make temporary file: Operation not permitted configure:3910: $? = 1 configure:3948: result: no configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME "OCaml" | #define PACKAGE_TARNAME "ocaml" | #define PACKAGE_VERSION "4.12.0" | #define PACKAGE_STRING "OCaml 4.12.0" | #define PACKAGE_BUGREPORT "caml-list@inria.fr" | #define PACKAGE_URL "http://www.ocaml.org" | /* end confdefs.h. */ | | int | main () | { | | ; | return 0; | } configure:3953: error: in `/Users/Alex/.esy/3/b/ocaml-4.12.0-3a04ec8f': configure:3955: error: C compiler cannot create executables See `config.log' for more details ## ---------------- ## ## Cache variables. ## ## ---------------- ## ac_cv_build=aarch64-apple-darwin21.3.0 ac_cv_env_ASPP_set= ac_cv_env_ASPP_value= ac_cv_env_AS_set= ac_cv_env_AS_value= ac_cv_env_CC_set= ac_cv_env_CC_value= ac_cv_env_CFLAGS_set= ac_cv_env_CFLAGS_value= ac_cv_env_CPPFLAGS_set= ac_cv_env_CPPFLAGS_value= ac_cv_env_CPP_set= ac_cv_env_CPP_value= ac_cv_env_DEFAULT_STRING_set= ac_cv_env_DEFAULT_STRING_value= ac_cv_env_DLLIBS_set= ac_cv_env_DLLIBS_value= ac_cv_env_LDFLAGS_set= ac_cv_env_LDFLAGS_value= ac_cv_env_LIBS_set= ac_cv_env_LIBS_value= ac_cv_env_LT_SYS_LIBRARY_PATH_set= ac_cv_env_LT_SYS_LIBRARY_PATH_value= ac_cv_env_PARTIALLD_set= ac_cv_env_PARTIALLD_value= ac_cv_env_WINDOWS_UNICODE_MODE_set= ac_cv_env_WINDOWS_UNICODE_MODE_value= ac_cv_env_build_alias_set= ac_cv_env_build_alias_value= ac_cv_env_host_alias_set= ac_cv_env_host_alias_value= ac_cv_env_target_alias_set= ac_cv_env_target_alias_value= ac_cv_host=aarch64-apple-darwin21.3.0 ac_cv_prog_ac_ct_CC=gcc ac_cv_prog_ac_ct_LD=ld ac_cv_target=aarch64-apple-darwin21.3.0 ## ----------------- ## ## Output variables. ## ## ----------------- ## AR='' AS='' ASPP='' AWK='' CC='gcc' CFLAGS='' CONFIGURE_ARGS='--disable-cfi --prefix /Users/Alex/.esy/3___________________________________________________________________/s/ocaml-4.12.0-3a04ec8f' CPP='' CPPFLAGS='' DEFAULT_STRING='' DEFS='' DEP_CC='' DIRECT_CPP='' DIRECT_LD='' DLLIBS='' DLLTOOL='' DSYMUTIL='' DUMPBIN='' ECHO_C='\c' ECHO_N='' ECHO_T='' EGREP='' EXEEXT='' FGREP='' GREP='' INSTALL_DATA='' INSTALL_PROGRAM='' INSTALL_SCRIPT='' LD='ld' LDFLAGS='' LIBOBJS='' LIBS='' LIBTOOL='' LIPO='' LN_S='' LTLIBOBJS='' LT_SYS_LIBRARY_PATH='' MANIFEST_TOOL='' NM='' NMEDIT='' OBJDUMP='' OBJEXT='' OTOOL64='' OTOOL='' PACKAGE_BUGREPORT='caml-list@inria.fr' PACKAGE_NAME='OCaml' PACKAGE_STRING='OCaml 4.12.0' PACKAGE_TARNAME='ocaml' PACKAGE_URL='http://www.ocaml.org' PACKAGE_VERSION='4.12.0' PACKLD='' PARTIALLD='' PATH_SEPARATOR=':' PTHREAD_CC='' PTHREAD_CFLAGS='' PTHREAD_LIBS='' RANLIB='' RANLIBCMD='' S='s' SED='' SHELL='/bin/sh' SO='so' STRIP='' SYSTEM_AS='' VERSION='4.12.0' WINDOWS_UNICODE_MODE='' ac_ct_AR='' ac_ct_CC='gcc' ac_ct_DEP_CC='' ac_ct_DUMPBIN='' ac_ct_LD='ld' ac_tool_prefix='' afl='' arch64='' arch='' as_has_debug_prefix_map='' asm_cfi_supported='' ax_pthread_config='' bindir='${exec_prefix}/bin' build='aarch64-apple-darwin21.3.0' build_alias='' build_cpu='aarch64' build_os='darwin21.3.0' build_vendor='apple' bytecclibs='' cc_has_debug_prefix_map='' ccomptype='cc' cmxs='' compute_deps='' datadir='${datarootdir}' datarootdir='${prefix}/share' debug_runtime='' default_safe_string='' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' dvidir='${docdir}' endianness='' exec_prefix='NONE' exeext='' extralibs='' flambda='' flambda_invariants='' flat_float_array='' flexdll_chain='' flexlink_flags='' force_safe_string='' fpic='' frame_pointers='' function_sections='' has_monotonic_clock='' host='aarch64-apple-darwin21.3.0' host_alias='' host_cpu='aarch64' host_os='darwin21.3.0' host_vendor='apple' htmldir='${docdir}' iflexdir='' includedir='${prefix}/include' infodir='${datarootdir}/info' install_bytecode_programs='' install_source_artifacts='' instrumented_runtime='false' libdir='${exec_prefix}/lib' libexecdir='${exec_prefix}/libexec' libext='' libraries_man_section='3' localedir='${datarootdir}/locale' localstatedir='${prefix}/var' long_shebang='' mandir='${datarootdir}/man' mkexe='$(CC) $(OC_CFLAGS) $(CFLAGS) $(OC_LDFLAGS)' mkexedebugflag='-g' mklib='' mkmaindll='' mksharedlib='' mksharedlibrpath='' model='' naked_pointers='' naked_pointers_checker='' natdynlink='' natdynlinkopts='' native_compiler='' nativecclibs='' oc_cflags='' oc_cppflags='' oc_dll_ldflags='' oc_ldflags='' ocamlc_cflags='' ocamlc_cppflags='' ocamldoc='auto' ocamltest='' oldincludedir='/usr/include' otherlibraries='' outputexe='-o $(EMPTY)' outputobj='' pdfdir='${docdir}' prefix='/Users/Alex/.esy/3___________________________________________________________________/s/ocaml-4.12.0-3a04ec8f' profinfo='false' profinfo_width='0' program_transform_name='s,x,x,' programs_man_section='1' psdir='${docdir}' pthread_link='' rlwrap='' rpath='' sbindir='${exec_prefix}/sbin' sharedlib_cflags='' sharedstatedir='${prefix}/com' shebangscripts='' stdlib_manpages='' supports_shared_libraries='' sysconfdir='${prefix}/etc' syslib='-l$(1)' system='' systhread_support='' target='aarch64-apple-darwin21.3.0' target_alias='' target_cpu='aarch64' target_os='darwin21.3.0' target_vendor='apple' toolchain='cc' unix_or_win32='' unixlib='' windows_unicode='' with_camltex='true' with_debugger='' x_includes='NONE' x_libraries='NONE' ## ----------- ## ## confdefs.h. ## ## ----------- ## /* confdefs.h */ #define PACKAGE_NAME "OCaml" #define PACKAGE_TARNAME "ocaml" #define PACKAGE_VERSION "4.12.0" #define PACKAGE_STRING "OCaml 4.12.0" #define PACKAGE_BUGREPORT "caml-list@inria.fr" #define PACKAGE_URL "http://www.ocaml.org" configure: exit 77 ```