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

Add aarch64-pc-windows-gnullvm and x86_64-pc-windows-gnullvm targets #1883

Merged
merged 14 commits into from
Aug 5, 2022

Conversation

mati865
Copy link
Contributor

@mati865 mati865 commented Jul 10, 2022

Creating new target as told to do so in #1846 (review)

Fixes #1881

@kennykerr kennykerr requested a review from riverar July 10, 2022 15:11
@mati865
Copy link
Contributor Author

mati865 commented Jul 10, 2022

I don't know what is wrong but git keeps interpreting crates/targets/aarch64_gnullvm/lib/libwindows.a as a text file.

@kennykerr
Copy link
Collaborator

I don't know what is wrong but git keeps interpreting crates/targets/aarch64_gnullvm/lib/libwindows.a as a text file.

That's odd, the .gitattributes includes *.a so it shouldn't.

*.a -text

@kennykerr
Copy link
Collaborator

image

It is suspiciously small.

@mati865
Copy link
Contributor Author

mati865 commented Jul 10, 2022

image

It is suspiciously small.

Yeah, noticed it as well before opening the PR but I had compared outputs of llvm-nm crates/targets/aarch64_gnullvm/lib/libwindows.a and llvm-nm crates/targets/aarch64_msvc/lib/windows.lib and they were mostly the same.
At least when it comes to symbols count they are the same:

$ llvm-readobj --coff-exports crates/targets/aarch64_gnullvm/lib/libwindows.a | grep Symbol | wc -l
34210

$ llvm-readobj --coff-exports crates/targets/aarch64_msvc/lib/windows.lib | grep Symbol | wc -l
34210

crates/tools/gnullvm/src/main.rs Outdated Show resolved Hide resolved
crates/tools/gnullvm/readme.md Outdated Show resolved Hide resolved
@riverar
Copy link
Collaborator

riverar commented Jul 10, 2022

Any general pointers/tips on building your toolchain locally for testing? I'm going through the steps of compiling rustc now, which I assume is the starting point.

@mati865
Copy link
Contributor Author

mati865 commented Jul 10, 2022

You could try first if unstable -Z build-std feature will suffice your needs, it's the easiest way to play with this target right now.
For an example you can even run tool_gnullvm using x86_64-pc-windows-gnullvm target with these steps:

  1. Open MSYS2 CLANG64 environment
  2. Run pacman --needed -S mingw-w64-clang-x86_64-toolchain
  3. Run PATH=$(cygpath -u $USERPROFILE)/.cargo/bin:$PATH cargo r --target x86_64-pc-windows-gnullvm -Z build-std -p tool_gnullvm -- all

It requires nightly Rust though.

If you want full toolchain I'll provide you the exact steps on how to build it today/tomorrow evening CEST.

@riverar
Copy link
Collaborator

riverar commented Jul 11, 2022

Ah cool, I didn't realize this made it into nightly. 👍 No full toolchain steps needed for our purposes at this time, although it might be handy to add to the docs at some point.

Compiling tool_gnullvm (targeting *-gnullvm) results in libunwind failures. I see clang was invoked with --unwindlib=none so not sure what's going on there yet.

Full output:
$ PATH=$(cygpath -u $USERPROFILE)/.cargo/bin:$PATH cargo +nightly r --target x86_64-pc-windows-gnullvm -Z build-std -p tool_gnullvm -- all
   Compiling tool_gnullvm v0.0.0 (C:\Sources\windows-rs\crates\tools\gnullvm)
error: linking with `C:\msys64\mingw64\bin\clang.exe` failed: exit code: 1
  |
  = note: "C:\\msys64\\mingw64\\bin\\clang.exe" "-nolibc" "--unwindlib=none" "-m64" "C:\\Users\\Rafael\\AppData\\Local\\Temp\\rustcC65uNT\\symbols.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.12ezno69lpmyuu43.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.182fhvj1u3z7iewp.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.18libnrriw98oxa5.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.19coswx6llvdnn7o.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.19u62jculx1rys4c.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.19zyo4y10v97pxyc.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1c7w2c0kmw4vax41.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1fhaabranfwg26qr.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1kb989b60cwsp40k.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1lmdnorj2y13sjqj.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1lufaybp8bgbxryf.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1rscad6yb11zdupb.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1v0oocqexrv9smmf.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.1zmgck2so313w7wv.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.23fsy0jzoccnj3gw.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.25so6al963q2emyd.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.26bn02cwg0enjfjp.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2awck9hsuryladm7.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2carsqilgwqywkd8.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2e7djchnlh0ww7o7.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2hhaykeo7gz5yd5y.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2s7xba4l2cafbheb.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2utj8qikjdawum8r.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2wotsgfes5l9gc8u.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.2xb3pn7who3lfhvs.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.31tcqypfx8sy7tho.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.34jalpnpzia2w46x.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3c62t39ncatq5vlz.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3chyhombgrxzrnat.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3dsup3ekjghugufa.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3iju24uwbpdjkow4.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3jgisacdr7dgejlt.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3kdd597cu0ixmadb.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3lumt0z74ue70uuy.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3nnqtye7nfbh53f7.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3obygl2afdjpl1s6.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3s6g8dpesmhs2c6g.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3sbotzh55gfflxdt.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3sjwyk8dpeo5642h.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.3zf7avs5a1a4m75u.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.44yyo97bgsjpxa5x.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.46b1ysswldryyxb.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4e3f01fox28igrwd.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4e9imsxiyinfp08x.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4fdvsv6s7yjfgy6g.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4itxrucu3etl472e.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4j7jlutq26n8b89l.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4jryu1iwa0j2t8r9.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4mvkjw2fjzfehgr8.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4n8a5elnbwh0ktbb.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.4xkn8ckyjulx8bds.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.523rtzupxsdg8d54.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.56hrao22h6eux2f7.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.5b6w1bx5ttxo18kz.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.5ecxczoc7p2fv2qq.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.9oe63endkav5e41.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.ay7j6ko52ije6fb.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.iy05wnmkx473440.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.wkvi2cqd3pce0sv.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.z34xp5dqywgslxi.rcgu.o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.ge5v7etyc1jxeve.rcgu.o" "-L" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps" "-L" "C:\\Sources\\windows-rs\\target\\debug\\deps" "-L" "C:\\Users\\Rafael\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-gnullvm\\lib" "-Wl,-Bstatic" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libwindows_metadata-c91907ac2b553472.rlib" "-Wl,--start-group" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libstd-e9f2efaad10a3b98.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libpanic_unwind-5a5bf608ddb8ed39.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libobject-e23b7a7cfbdf5916.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libmemchr-96c6a8deb0ac1412.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libaddr2line-1667495d10f7223f.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libgimli-e31847701079c437.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\librustc_demangle-00c752d0d065974d.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libstd_detect-ad54cec87987c4a2.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libhashbrown-56e9dd1d6fe90939.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libminiz_oxide-2633874641d74771.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libadler-0e1435af86fb862f.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\librustc_std_workspace_alloc-dcaf45f9a093f678.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libunwind-c43da1cf3a899fc0.rlib" "-lunwind" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libcfg_if-e4d4a9cbb956fd9a.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\liblibc-69d6255466bb7ddf.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\liballoc-c5571d2b88345384.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\librustc_std_workspace_core-ad0baf2b5b0e44ce.rlib" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libcore-6a89cba04688d323.rlib" "-Wl,--end-group" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\libcompiler_builtins-94ce661bcd27ab31.rlib" "-Wl,-Bdynamic" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lmingw32" "-lmingwex" "-lmsvcrt" "-lkernel32" "-luser32" "-Wl,--nxcompat" "-L" "C:\\Users\\Rafael\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-gnullvm\\lib" "-o" "C:\\Sources\\windows-rs\\target\\x86_64-pc-windows-gnullvm\\debug\\deps\\tool_gnullvm-e1caceb089630d49.exe" "-Wl,--gc-sections" "-no-pie"
  = note: clang: warning: argument unused during compilation: '-nolibc' [-Wunused-command-line-argument]
          clang: warning: argument unused during compilation: '--unwindlib=none' [-Wunused-command-line-argument]
          clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
          C:/msys64/mingw64/bin/ld: cannot find -lunwind: No such file or directory
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

@kennykerr
Copy link
Collaborator

Is there no 32-bit target for gnullvm?

@mati865
Copy link
Contributor Author

mati865 commented Jul 11, 2022

Is there no 32-bit target for gnullvm?

ARM and i686 might be added in the future, right now I skipped them because Rust breaks their exception handling (the "glue" code is very specific to libgcc and doesn't work with LLVM's libunwind). 64-bit targets use SEH and are free of this issue.

@mati865
Copy link
Contributor Author

mati865 commented Jul 11, 2022

C:/msys64/mingw64/bin/ld

@riverar could you try using CLANG64 subsystem instead of MINGW64?

@riverar
Copy link
Collaborator

riverar commented Jul 11, 2022

@mati865 Yep, that works great. I'll add a review comment to the README then.

crates/tools/gnullvm/readme.md Outdated Show resolved Hide resolved
crates/tools/gnullvm/readme.md Outdated Show resolved Hide resolved
crates/tools/gnullvm/readme.md Outdated Show resolved Hide resolved
@riverar
Copy link
Collaborator

riverar commented Jul 11, 2022

Data point: My x86_64/aarch64 libwindows.a files are ~3,237,186 bytes (3.08MiB) which seems more aligned with expectations. (libs.zip)

@mati865
Copy link
Contributor Author

mati865 commented Jul 12, 2022

Ran tool_yml and updated readme with instructions on using gnullvm target on nightly.

I can squash commits manually and force-push once you are satisfied with this PR.

@kennykerr
Copy link
Collaborator

I can squash commits manually and force-push once you are satisfied with this PR.

Not to worry, we always "squash and merge" when completing.

@riverar
Copy link
Collaborator

riverar commented Jul 12, 2022

Looking pretty good!

@mati865 Can you update our rudimentary cross-compile CI tests here to test this new target? https://github.com/microsoft/windows-rs/blob/master/.github/workflows/cross-compile.yml

One possible matrix strategy could look like:

matrix:
  image: [macos-latest, ubuntu-latest]
  version: [stable, nightly]
  target: [x86_64-pc-windows-gnu, xxxxxx_gnullvm]
  exclude:
  - target: xxxxxx_gnullvm
    version: stable

If you don't feel comfortable with that, need help, etc. just let us know.

@mati865
Copy link
Contributor Author

mati865 commented Jul 12, 2022

@riverar linking the executable will fail without manually installing mingw-w64+LLVM toolchain like this one: https://github.com/mstorsjo/llvm-mingw
Should I do it?

@riverar
Copy link
Collaborator

riverar commented Jul 12, 2022

@riverar linking the executable will fail without manually installing mingw-w64+LLVM toolchain like this one: https://github.com/mstorsjo/llvm-mingw
Should I do it?

Yup, add a step for it, with a conditional for gnullvm.

@riverar
Copy link
Collaborator

riverar commented Jul 13, 2022

🎉 Passing the smoke tests, sweet!

I don't think this is specific to your gnullvm target but I'm wondering if the LLVM/mingw-w64 toolchain can be tweaked to leverage Hybrid CRT semantics to eliminate the dynamic CRT external dependency. I don't think this is a blocker for adoption but that's not my call.

Also, can you help me understand the differences between mstorsjo/llvm-mingw and me installing mingw-w64-clang-...-toolchain on Windows? Apologies in advance if that's obvious.

@mati865
Copy link
Contributor Author

mati865 commented Jul 13, 2022

I don't think this is specific to your gnullvm target but I'm wondering if the LLVM/mingw-w64 toolchain can be tweaked to leverage Hybrid CRT semantics to eliminate the dynamic CRT external dependency.

I don't think so, mingw-w64 doesn't support linking static CRT at all because it doesn't have access to Microsoft's source codes nor static libraries. So I'd expect this Hybrid thing to have the same problem.

Also, can you help me understand the differences between mstorsjo/llvm-mingw and me installing mingw-w64-clang-...-toolchain on Windows? Apologies in advance if that's obvious.

MSYS2 (the tool that provides mingw-w64-clang-...-toolchain) works only on Windows and provides package manager with toolchain, tools and libraries so it's similar to developing on Linux.
llvm-mingw is just a compressed toolchain so mingw-w64 + LLVM.

MSYS2's CLANG* subsystems are almost the same as llvm-mingw so both are fully compatible.
MINGW* and UCRT* subsystems however carry few patches making Clang/LLVM more compatible with GCC but incompatible with unpatched Clang/LLVM (like one in CLANG* subsystems or llvm-mingw).
This is especially visible when using TLS or exceptions inside executable.

So TL;DR llvm-mingw supports all major systems as the host but provides toolchain only, MSYS2 supports only Windows as the host but provides more complete Linux-like environment. You can use either of them and cargo b --target x86_64-pc-windows-gnullvm -Z build-std will work.

@kennykerr
Copy link
Collaborator

Thanks for your efforts on this - its looks good. @riverar is away for a few days but should be able to help you get this completed and signed off as soon as he returns.

.github/workflows/cross-compile.yml Outdated Show resolved Hide resolved
@riverar
Copy link
Collaborator

riverar commented Jul 27, 2022

Looks good to me, just a nit on the caching that should be easy to resolve. Thanks for your patience while I was out!

@mati865
Copy link
Contributor Author

mati865 commented Jul 27, 2022

Thanks, I'm out until Sunday/Monday. I'll address feedback then.

@mati865
Copy link
Contributor Author

mati865 commented Aug 5, 2022

Sorry, was busier than anticipated.
Rebased branch (because of CI errors) and added cache:
obraz

@riverar
Copy link
Collaborator

riverar commented Aug 5, 2022

Opened #1949 to address build failures here.

Copy link
Collaborator

@riverar riverar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebase once more (fix went in to master), should build cleanly now.

@mati865
Copy link
Contributor Author

mati865 commented Aug 5, 2022

@riverar should be ready.

@riverar riverar merged commit c55af26 into microsoft:master Aug 5, 2022
@riverar
Copy link
Collaborator

riverar commented Aug 5, 2022

@mati865 🥳🎉

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

Successfully merging this pull request may close these issues.

Feature request: *-pc-windows-gnullvm targets
3 participants