Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: doesn't support aarch64-windows-gnu #9046

Closed
jeremyd2019 opened this issue Feb 16, 2021 · 11 comments · Fixed by #13513
Closed

rust: doesn't support aarch64-windows-gnu #9046

jeremyd2019 opened this issue Feb 16, 2021 · 11 comments · Fixed by #13513

Comments

@jeremyd2019
Copy link
Member

No description provided.

jeremyd2019 referenced this issue in jeremyd2019/MINGW-packages Feb 16, 2021
rust doesn't support aarch64-pc-windows-gnu (msys2/CLANG-packages#28)
and it apparently hardcodes libgcc (msys2/CLANG-packages#29), so disable
it in all clang prefixes
jeremyd2019 referenced this issue in jeremyd2019/MINGW-packages Feb 16, 2021
rust doesn't support aarch64-pc-windows-gnu (msys2/CLANG-packages#28)
and it apparently hardcodes libgcc (msys2/CLANG-packages#29), so disable
it in all clang prefixes
mingwandroid referenced this issue in mingwandroid/MINGW-packages Apr 8, 2021
rust doesn't support aarch64-pc-windows-gnu (msys2/CLANG-packages#28)
and it apparently hardcodes libgcc (msys2/CLANG-packages#29), so disable
it in all clang prefixes
@jeremyd2019 jeremyd2019 transferred this issue from msys2/CLANG-packages Jul 3, 2021
@dennisameling
Copy link
Contributor

dennisameling commented Dec 21, 2021

I'd like to look a bit into this as I need Rust for librsvg:

"${MINGW_PACKAGE_PREFIX}-rust"

Luckily, @mati865 already did an amazing job at patching Rust to be built using Clang. I have a feeling that clangarm64 shouldn't be too far out for this, but am mainly worried about the GCC requirement, as that's not available for Windows arm64. But that might only be needed for the x86_64 bootstrap compiler (fingers crossed).

Based on your knowledge and experience, would you say it's possible to:

If I understand things correctly, this will allow us to create a Stage 0 compiler for aarch64-pc-windows-gnu on a x86_64 host. Rust already did this before, where they built both x86_64-pc-windows-msvc and aarch64-pc-windows-msvc from the same host.

Just for the record, trying to build this on an arm64 device currently fails with RuntimeError: src/stage0.json doesn't contain a checksum for dist/2021-11-01/rust-std-1.56.1-aarch64-pc-windows-gnu.tar.xz. I guess this will only be problematic until we're able to build a Stage 0 compiler for aarch64-pc-windows-gnu from a x86_64 device, correct?

==> Starting build()...
configure: processing command line
configure:
configure: install.prefix       := /clangarm64
configure: install.sysconfdir   := /clangarm64/etc
configure: install.localstatedir := /clangarm64/var/lib
configure: build.build          := aarch64-pc-windows-gnu
configure: build.host           := ['aarch64-pc-windows-gnu']
configure: build.target         := ['aarch64-pc-windows-gnu']
configure: rust.channel         := stable
configure: llvm.ninja           := True
configure: build.extended       := True
configure: rust.codegen-tests   := False
configure: target.aarch64-pc-windows-gnu.llvm-config := C:/msys64/clangarm64/bin/ ...
configure: build.python         := C:/msys64/clangarm64/bin/python
configure: build.configure-args := ['--prefix=/clangarm64', '--sysconfdir=/clanga ...
warning: localstatedir will be ignored
configure:
configure: writing `config.toml` in current directory
configure:
configure: run `python C:/msys64/usr/src/mingw-packages-2/mingw-w64-rust/src/rustc-1.57.0-src/x.py --help`
configure:
removing C:/Users/denni/AppData/Local/Temp/tmpdd3j8oxj
Traceback (most recent call last):
  File "C:\msys64\usr\src\mingw-packages-2\mingw-w64-rust\src\rustc-1.57.0-src\x.py", line 27, in <module>
    bootstrap.main()
  File "C:/msys64/usr/src/mingw-packages-2/mingw-w64-rust/src/rustc-1.57.0-src/src/bootstrap/bootstrap.py", line 1237, in main
    bootstrap(help_triggered)
  File "C:/msys64/usr/src/mingw-packages-2/mingw-w64-rust/src/rustc-1.57.0-src/src/bootstrap/bootstrap.py", line 1203, in bootstrap
    build.download_toolchain()
  File "C:/msys64/usr/src/mingw-packages-2/mingw-w64-rust/src/rustc-1.57.0-src/src/bootstrap/bootstrap.py", line 412, in download_toolchain
    self._download_component_helper(filename, pattern, tarball_suffix, stage0)
  File "C:/msys64/usr/src/mingw-packages-2/mingw-w64-rust/src/rustc-1.57.0-src/src/bootstrap/bootstrap.py", line 538, in _download_component_helper
    get(
  File "C:/msys64/usr/src/mingw-packages-2/mingw-w64-rust/src/rustc-1.57.0-src/src/bootstrap/bootstrap.py", line 35, in get
    raise RuntimeError("src/stage0.json doesn't contain a checksum for {}".format(url))
RuntimeError: src/stage0.json doesn't contain a checksum for dist/2021-11-01/rust-std-1.56.1-aarch64-pc-windows-gnu.tar.xz
==> ERROR: A failure occurred in build().
    Aborting...

Thanks in advance!

@mati865
Copy link
Collaborator

mati865 commented Dec 21, 2021

If I understand things correctly, this will allow us to create a Stage 0 compiler for aarch64-pc-windows-gnu on a x86_64 host.

I guess more things will require patching, like exceptions handling.

I guess this will only be problematic until we're able to build a Stage 0 compiler for aarch64-pc-windows-gnu from a x86_64 device, correct?

We will always have to use local compiler for bootstrapping but that should be fine.

@Biswa96
Copy link
Member

Biswa96 commented Dec 27, 2021

I'd like to look a bit into this as I need Rust for librsvg

FYI, there is an older version of librsvg without Rust-ification https://packages.msys2.org/base/mingw-w64-librsvg-2.40

@jeremyd2019
Copy link
Member Author

Keep in mind this is an older, unsupported version so may not be the best from a security standpoint.

@dennisameling
Copy link
Contributor

dennisameling commented Dec 30, 2021

Have been making some progress in dennisameling/rust#1 - will follow up there

@dennisameling
Copy link
Contributor

dennisameling commented Jan 3, 2022

As mentioned here, it'll probably be easiest if we can first get Rust to bootstrap from a Clang toolchain instead of a GCC based one.

I've been working on getting a Rust upstream build to work using clang64 over the weekend - artifacts can be downloaded here. Once the stage0 compiler/toolchain will use Clang, it should also become much easier to create clangarm64 builds as it no longer will try to link against x86_64-w64-mingw32-gcc for the stage0 compiler, but use x86_64-w64-mingw32-clang instead. Massive thanks to the MSYS2 team for creating the necessary patches a while ago already 🙏🏼

PR: rust-lang/rust#92502

@mati865
Copy link
Collaborator

mati865 commented Mar 8, 2022

I've hacked together and cross compiled from Linux toolchain that might work on AArch64 but I couldn't setup usable AArch64 VM on my x86_64 system. Therefore I'm looking for brave tester willing to run my binary (native or VM AArch64 Windows) and share the results.

Steps to test it:

  1. Prepare MSYS2 or llvm-mingw toolchain (I have used 20220209 with LLVM 14.0.0 RC1 for the cross-compilation) and have AArch64 DLLs (libunwind and libc++) in PATH.
  2. Download and extract https://1drv.ms/u/s!AgMYIlqTF8b9guht4mhJOcWOjIFXwg?e=42zVoh. Then add bin/ from that archive to PATH.
  3. Run rustc -vV
  4. Run rustc -Z unstable-options --print target-spec-json
  5. Build and run hello world with and without optimisations, example how to do it:
# Create hello world file
$ cat hello.rs
fn main() {
    println!("Hello, World!");
}

# Debug build
$ rustc hello.rs

$ ./hello.exe
# Should say `Hello, World!`

# Opt build
$ rustc -O hello.rs

$ ./hello.exe
# Should say `Hello, World!`
  1. Share the results of steps 3, 4 and 5

@mstorsjo
Copy link
Contributor

mstorsjo commented Mar 8, 2022

  1. Run rustc -vV
rustc 1.61.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: aarch64-pc-windows-gnullvm
release: 1.61.0-dev
LLVM version: 14.0.0
  1. Run rustc -Z unstable-options --print target-spec-json
{
  "abi": "llvm",
  "abi-return-struct-as-int": true,
  "allows-weak-linkage": false,
  "arch": "aarch64",
  "data-layout": "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128",
  "dll-prefix": "",
  "dll-suffix": ".dll",
  "dynamic-linking": true,
  "eh-frame-header": false,
  "emit-debug-gdb-scripts": false,
  "env": "gnu",
  "exe-suffix": ".exe",
  "executables": true,
  "features": "+neon,+fp-armv8",
  "is-builtin": true,
  "is-like-windows": true,
  "late-link-args": {
    "gcc": [
      "-lmingw32",
      "-lmingwex",
      "-lmsvcrt",
      "-lkernel32",
      "-luser32"
    ],
    "ld.lld": [
      "-lmingw32",
      "-lmingwex",
      "-lmsvcrt",
      "-lkernel32",
      "-luser32"
    ]
  },
  "late-link-args-dynamic": {
    "gcc": [
      "-lunwind"
    ],
    "ld.lld": [
      "-lunwind"
    ]
  },
  "late-link-args-static": {
    "gcc": [
      "-l:libunwind.a"
    ],
    "ld.lld": [
      "-l:libunwind.a"
    ]
  },
  "linker": "aarch64-w64-mingw32-clang",
  "llvm-target": "aarch64-pc-windows-gnu",
  "max-atomic-width": 64,
  "no-default-libraries": false,
  "os": "windows",
  "pre-link-args": {
    "gcc": [
      "-nolibc",
      "--unwindlib=none"
    ],
    "ld.lld": [
      "-m",
      "arm64pe"
    ]
  },
  "requires-uwtable": true,
  "target-family": [
    "windows"
  ],
  "target-pointer-width": "64",
  "vendor": "pc"
}
  1. Build and run hello world with and without optimisations, example how to do it:

These steps work and behave just as expected.

@lazka
Copy link
Member

lazka commented Mar 12, 2022

The fwpuclnt fixes are now in the repo.

@mati865
Copy link
Collaborator

mati865 commented Mar 12, 2022

Thanks but I haven't yet found a way to bootstrap it on AArch64 Windows. I have ideas for few more hacks but I need to finish rust-lang/rust#94872 first and I want to test upgrading our LLVM toolchain to version 14 since RC4 has been just released with fix for building from tarballs.

@mati865
Copy link
Collaborator

mati865 commented Mar 12, 2022

Update: LLVM still seems to have broken tarballs: llvm/llvm-project#53281 (comment)
More time for Rust I guess 🤷🏻‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants