otp icon indicating copy to clipboard operation
otp copied to clipboard

added support for `arm64` and `x64_arm64` in `otp_build`

Open cocoa-xu opened this issue 1 year ago • 6 comments

This PR is one of the smaller PRs separated from the original PR https://github.com/erlang/otp/pull/8142 that attempts to add initial support for ARM64 windows.

I'm open to change x64_arm64 to any alternative value(s) that can tell us we're cross-compiling. I'm also open to add amd64_arm64 as an alias for x64_arm64 if we'd like to make it consistent with Microsoft Visual Studio, please see vcvarsall.

In this PR,

  • echo_env_wsl now accepts a single argument ARCH, which can be one of x64, arm64, x64_arm64 and x86
  • wsl_tools/vc/cc.sh will set LINKCMD="-MACHINE:${MACHINE}" by default, where the value for MACHINE is:
    • x64 when CONFIG_SUBTYPE is win64
    • ARM64 when CONFIG_SUBTYPE is either arm64 or x64_arm64
    • x86 for all other CONFIG_SUBTYPE values
  • wsl_tools/vc/cc.sh will add -D__aarch64__ to COMMON_CFLAGS when (cross-)compiling for the arm64 target
  • wsl_tools/reg_query.sh will set REG_OPT=" /reg:64" when CONFIG_SUBTYPE is either arm64 or x64_arm64

When compile on an arm64 machine natively

  • CONFIG_SUBTYPE will be set to arm64

  • build_type, host_type and target_type are all set to local-aarch64-pc-windows

  • win64-arm64.config.cache.static will be used.

    It uses win64.config.cache.static as the template and all local-x86_64-pc-windows are replaced by local-aarch64-pc-windows

When cross-compiling on an x86_64 host machine

  • CONFIG_SUBTYPE will be set to x64_arm64

  • build_type will be set to local-x86_64-pc-windows while host_type and target_type are all set to local-aarch64-pc-windows

  • win64-x64_arm64.config.cache.static will be used.

    It uses win64.config.cache.static as the template and local-x86_64-pc-windows are replaced by local-aarch64-pc-windows except for ac_cv_build and ac_cv_env_build_alias_value

cocoa-xu avatar Sep 26 '24 19:09 cocoa-xu

CT Test Results

    3 files    141 suites   48m 47s :stopwatch: 1 595 tests 1 546 :white_check_mark: 49 :zzz: 0 :x: 2 303 runs  2 234 :white_check_mark: 69 :zzz: 0 :x:

Results for commit 44f78586.

:recycle: This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

github-actions[bot] avatar Sep 26 '24 19:09 github-actions[bot]

Was going update wsl_tools/vc/emu_cc.sh in the next PR with documentation regarding where to get/download the compiler, but I think we should be fine to add it in this PR because its name, aarch64-w64-mingw32-gcc, should follow the same convention regardless of which implementation we're using.

cocoa-xu avatar Oct 05 '24 13:10 cocoa-xu

Thanks for your pull request.

It seems that it would be better to squash the commits into one. While you are it, you could follow the advice in writing good commit messages and change the commit message to add support for arm64 and x64_arm64 in otp_build.

bjorng avatar Oct 09 '24 03:10 bjorng

Thanks for your pull request.

It seems that it would be better to squash the commits into one. While you are it, you could follow the advice in writing good commit messages and change the commit message to add support for arm64 and x64_arm64 in otp_build.

Hi @bjorng, thank you so much for the review, and I'll be happy to do so!

cocoa-xu avatar Oct 09 '24 16:10 cocoa-xu

Thanks! Added to our daily builds. I expect to merge this pull request within a few days unless any problems show up.

bjorng avatar Oct 22 '24 05:10 bjorng

Thanks @bjorng! And I think we're probably 2 more small PRs away from being able to compile an experimental version for ARM64 Windows.

cocoa-xu avatar Oct 24 '24 01:10 cocoa-xu

Thanks for your pull request.

bjorng avatar Oct 24 '24 08:10 bjorng