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 support for Arm64EC #2957

Merged
merged 1 commit into from
Apr 5, 2024
Merged

Add support for Arm64EC #2957

merged 1 commit into from
Apr 5, 2024

Conversation

dpaoliello
Copy link
Collaborator

@dpaoliello dpaoliello commented Mar 28, 2024

Rust recently added support for Arm64EC (rust-lang/rust#119199), but adding support in the Standard Library (rust-lang/rust#123144) requires that windows-bindgen emit the correct cfg items for Arm64EC.

This adds support for emitting the Arm64EC cfg attributes and reuses the existing AArch64 target crate (to match how MSVC links against the arm64 VC and Windows SDK libs).

crates/tools/msvc/src/main.rs Outdated Show resolved Hide resolved
crates/tools/msvc/src/main.rs Outdated Show resolved Hide resolved
crates/tools/msvc/src/main.rs Outdated Show resolved Hide resolved
crates/tools/msvc/src/main.rs Outdated Show resolved Hide resolved
@kennykerr
Copy link
Collaborator

This looks better! If only we could test ARM64 on GitHub. 🙄

@riverar
Copy link
Collaborator

riverar commented Mar 28, 2024

Arm64ec binaries can link against x64 and Arm64ec libs, but not Arm64 libs.

@dpaoliello dpaoliello force-pushed the arm64ec branch 2 times, most recently from b393989 to 2e5cbd3 Compare March 28, 2024 23:16
@dpaoliello
Copy link
Collaborator Author

Arm64ec binaries can link against x64 and Arm64ec libs, but not Arm64 libs.

Ah, good point, looks like a bunch of the libs in the Windows SDK arm64 directory are actually ARM64X (x64 + Arm64EC). So, for simplicity, we can link against the x64 target crate.

@kennykerr
Copy link
Collaborator

Until we can get ARM testing on GitHub, do either of you @dpaoliello / @riverar have hardware that you can manually cargo test --all this on?

@riverar
Copy link
Collaborator

riverar commented Mar 29, 2024

/raf run nightly-aarch64-pc-windows-msvc 😂

test sanitized_value ... FAILED

failures:

---- sanitized_value stdout ----
thread 'sanitized_value' panicked at crates\samples\components\json_validator\src\lib.rs:310:9:
assertion `left == right` failed
  left: ",\0agXn 1,\"name\":\"Kenny\"}"
 right: "{\"age\":21,\"name\":\"Kenny\"}"
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Output rustc 1.79.0-nightly (c9f8f3438 2024-03-27)

C:\sources\windows-rs>cargo test -p riddle   && cargo test -p sample_bits   && cargo test -p sample_com_uri   && cargo test -p sample_component_hello_world   && cargo test -p sample_component_json_validator   && cargo test -p sample_component_json_validator_winrt   && cargo test -p sample_component_json_validator_winrt_client   && cargo test -p sample_consent   && cargo test -p sample_core_app   && cargo test -p sample_counter   && cargo test -p sample_counter_sys   && cargo test -p sample_create_window   && cargo test -p sample_create_window_sys   && cargo test -p sample_credentials   && cargo test -p sample_data_protection   && cargo test -p sample_dcomp   && cargo test -p sample_delay_load   && cargo test -p sample_delay_load_sys   && cargo test -p sample_device_watcher   && cargo test -p sample_direct2d   && cargo test -p sample_direct3d12   && cargo test -p sample_enum_windows   && cargo test -p sample_enum_windows_sys   && cargo test -p sample_kernel_event   && cargo test -p sample_memory_buffer   && cargo test -p sample_message_box   && cargo test -p sample_message_box_sys   && cargo test -p sample_ocr   && cargo test -p sample_overlapped   && cargo test -p sample_privileges   && cargo test -p sample_privileges_sys   && cargo test -p sample_rss   && cargo test -p sample_shell   && cargo test -p sample_simple   && cargo test -p sample_spellchecker   && cargo test -p sample_task_dialog   && cargo test -p sample_task_dialog_sys   && cargo test -p sample_thread_pool_work   && cargo test -p sample_thread_pool_work_sys   && cargo test -p sample_uiautomation   && cargo test -p sample_wmi   && cargo test -p sample_xml   && cargo test -p test_agile   && cargo test -p test_agile_reference   && cargo test -p test_alternate_success_code   && cargo test -p test_arch   && cargo test -p test_arch_feature   && cargo test -p test_array   && cargo test -p test_bcrypt   && cargo test -p test_bstr   && cargo test -p test_calling_convention   && cargo test -p test_cfg_generic   && cargo test -p test_collections   && cargo test -p test_component   && cargo test -p test_component_client   && cargo test -p test_const_fields   && cargo test -p test_const_params   && cargo test -p test_const_ptrs   && cargo test -p test_core   && cargo test -p test_debug   && cargo test -p test_debug_inspectable   && cargo test -p test_debugger_visualizer   && cargo test -p test_deprecated   && cargo test -p test_dispatch   && cargo test -p test_does_not_return   && cargo test -p test_enums   && cargo clean   && cargo test -p test_error   && cargo test -p test_event   && cargo test -p test_extensions   && cargo test -p test_handles   && cargo test -p test_helpers   && cargo test -p test_implement   && cargo test -p test_interface   && cargo test -p test_interface_core   && cargo test -p test_interop   && cargo test -p test_lib   && cargo test -p test_literals   && cargo test -p test_match   && cargo test -p test_matrix3x2   && cargo test -p test_metadata   && cargo test -p test_msrv   && cargo test -p test_no_use   && cargo test -p test_not_dll   && cargo test -p test_query_signature   && cargo test -p test_readme   && cargo test -p test_registry   && cargo test -p test_reserved   && cargo test -p test_resources   && cargo test -p test_result   && cargo test -p test_return_handle   && cargo test -p test_return_struct   && cargo test -p test_riddle   && cargo test -p test_simple_component   && cargo test -p test_standalone   && cargo test -p test_string_param   && cargo test -p test_structs   && cargo test -p test_sys   && cargo test -p test_targets   && cargo test -p test_unions   && cargo test -p test_variant   && cargo test -p test_wdk   && cargo test -p test_weak   && cargo test -p test_weak_ref   && cargo test -p test_win32   && cargo test -p test_win32_arrays   && cargo test -p test_window_long   && cargo test -p test_winrt   && cargo test -p tool_gnu   && cargo test -p tool_lib   && cargo test -p tool_license   && cargo test -p tool_metadata   && cargo test -p tool_msvc   && cargo test -p tool_sys   && cargo test -p tool_windows   && cargo test -p tool_yml   && cargo test -p windows   && cargo test -p windows-bindgen   && cargo test -p windows-core   && cargo test -p windows-implement   && cargo test -p windows-interface   && cargo test -p windows-metadata   && cargo test -p windows-registry   && cargo test -p windows-result   && cargo test -p windows-sys   && cargo test -p windows-targets   && cargo test -p windows-version   && cargo test -p windows_aarch64_gnullvm   && cargo test -p windows_aarch64_msvc   && cargo test -p windows_i686_gnu   && cargo test -p windows_i686_msvc   && cargo test -p windows_x86_64_gnu   && cargo test -p windows_x86_64_gnullvm   && cargo test -p windows_x86_64_msvc 
   Compiling unicode-ident v1.0.12
   Compiling proc-macro2 v1.0.79
   Compiling crossbeam-utils v0.8.19
   Compiling rayon-core v1.12.1
   Compiling serde v1.0.197
   Compiling serde_json v1.0.115
   Compiling ryu v1.0.17
   Compiling itoa v1.0.11
   Compiling either v1.10.0
   Compiling windows-metadata v0.55.0 (C:\sources\windows-rs\crates\libs\metadata)
   Compiling crossbeam-epoch v0.9.18
   Compiling quote v1.0.35
   Compiling syn v2.0.55
   Compiling crossbeam-deque v0.8.5
   Compiling rayon v1.10.0
   Compiling serde_derive v1.0.197
   Compiling windows-bindgen v0.55.0 (C:\sources\windows-rs\crates\libs\bindgen)
   Compiling riddle v0.3.0 (C:\sources\windows-rs\crates\tools\riddle)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 16.83s
     Running unittests src\main.rs (target\debug\deps\riddle-67765644401f9a9e.exe)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Compiling proc-macro2 v1.0.79
   Compiling unicode-ident v1.0.12
   Compiling windows_aarch64_msvc v0.52.4 (C:\sources\windows-rs\crates\targets\aarch64_msvc)
   Compiling windows-targets v0.52.4 (C:\sources\windows-rs\crates\libs\targets)
   Compiling windows-result v0.1.0 (C:\sources\windows-rs\crates\libs\result)
   Compiling quote v1.0.35
   Compiling syn v2.0.55
   Compiling windows-interface v0.53.0 (C:\sources\windows-rs\crates\libs\interface)
   Compiling windows-implement v0.53.0 (C:\sources\windows-rs\crates\libs\implement)
   Compiling windows-core v0.55.0 (C:\sources\windows-rs\crates\libs\core)
   Compiling windows v0.54.0 (C:\sources\windows-rs\crates\libs\windows)
   Compiling sample_bits v0.0.0 (C:\sources\windows-rs\crates\samples\windows\bits)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 11.07s
     Running unittests src\main.rs (target\debug\deps\sample_bits-834055803df733a4.exe)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Compiling windows v0.54.0 (C:\sources\windows-rs\crates\libs\windows)
   Compiling sample_com_uri v0.0.0 (C:\sources\windows-rs\crates\samples\windows\com_uri)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 4.07s
     Running unittests src\main.rs (target\debug\deps\sample_com_uri-d8d7897276a807ac.exe)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Compiling sample_component_hello_world v0.0.0 (C:\sources\windows-rs\crates\samples\components\hello_world)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.27s
     Running unittests src\lib.rs (target\debug\deps\sample_component_hello_world-b03b1215ebe8b329.exe)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Compiling autocfg v1.2.0
   Compiling windows_aarch64_msvc v0.52.4
   Compiling windows_aarch64_msvc v0.48.5
   Compiling memchr v2.7.2
   Compiling pin-project-lite v0.2.13
   Compiling once_cell v1.19.0
   Compiling cfg-if v1.0.0
   Compiling syn v2.0.55
   Compiling bytes v1.6.0
   Compiling futures-core v0.3.30
   Compiling tracing-core v0.1.32
   Compiling fnv v1.0.7
   Compiling windows-targets v0.52.4
   Compiling windows-targets v0.48.5
   Compiling tinyvec_macros v0.1.1
   Compiling windows-sys v0.52.0
   Compiling windows-sys v0.48.0
   Compiling tinyvec v1.6.0
   Compiling num-traits v0.2.18
   Compiling slab v0.4.9
   Compiling num-bigint v0.4.4
   Compiling tracing v0.1.40
   Compiling http v0.2.12
   Compiling num-rational v0.4.1
   Compiling futures-io v0.3.30
   Compiling futures-task v0.3.30
   Compiling hashbrown v0.14.3
   Compiling pin-utils v0.1.0
   Compiling percent-encoding v2.3.1
   Compiling anstyle v1.0.6
   Compiling socket2 v0.5.6
   Compiling equivalent v1.0.1
   Compiling utf8parse v0.2.1
   Compiling httparse v1.8.0
   Compiling futures-sink v0.3.30
   Compiling indexmap v2.2.6
   Compiling anstyle-parse v0.2.3
   Compiling num-integer v0.1.46
   Compiling anstyle-wincon v3.0.2
   Compiling anstyle-query v1.0.2
   Compiling form_urlencoded v1.2.1
   Compiling futures-util v0.3.30
   Compiling unicode-normalization v0.1.23
   Compiling lock_api v0.4.11
   Compiling aho-corasick v1.1.3
   Compiling colorchoice v1.0.0
   Compiling unicode-bidi v0.3.15
   Compiling parking_lot_core v0.9.9
   Compiling regex-syntax v0.8.3
   Compiling version_check v0.9.4
   Compiling try-lock v0.2.5
   Compiling want v0.3.1
   Compiling ahash v0.8.11
   Compiling idna v0.5.0
   Compiling anstream v0.6.13
   Compiling regex-automata v0.4.6
   Compiling num-iter v0.1.44
   Compiling serde_derive v1.0.197
   Compiling mio v0.8.11
   Compiling num-complex v0.4.5
   Compiling http-body v0.4.6
   Compiling futures-channel v0.3.30
   Compiling tokio v1.37.0
   Compiling strsim v0.11.0
   Compiling minimal-lexical v0.2.1
   Compiling clap_lex v0.7.0
   Compiling heck v0.5.0
   Compiling smallvec v1.13.2
   Compiling bit-vec v0.6.3
   Compiling httpdate v1.0.3
   Compiling tower-service v0.3.2
   Compiling num-conv v0.1.0
   Compiling scopeguard v1.2.0
   Compiling time-core v0.1.2
   Compiling anyhow v1.0.81
   Compiling powerfmt v0.2.0
   Compiling time-macros v0.2.17
   Compiling deranged v0.3.11
   Compiling bit-set v0.5.3
   Compiling regex v1.10.4
   Compiling clap_derive v4.5.4
   Compiling nom v7.1.3
   Compiling clap_builder v4.5.2
   Compiling num v0.4.1
   Compiling windows-interface v0.53.0 (C:\sources\windows-rs\crates\libs\interface)
   Compiling windows-implement v0.53.0 (C:\sources\windows-rs\crates\libs\implement)
   Compiling tokio-util v0.7.10
   Compiling serde v1.0.197
   Compiling winreg v0.50.0
   Compiling url v2.5.0
   Compiling h2 v0.3.25
   Compiling getrandom v0.2.12
   Compiling encoding_rs v0.8.33
   Compiling base64 v0.21.7
   Compiling sync_wrapper v0.1.2
   Compiling mime v0.3.17
   Compiling zerocopy v0.7.32
   Compiling ipnet v2.9.0
   Compiling lazy_static v1.4.0
   Compiling log v0.4.21
   Compiling fraction v0.13.1
   Compiling clap v4.5.4
   Compiling windows-core v0.55.0 (C:\sources\windows-rs\crates\libs\core)
   Compiling iso8601 v0.6.1
   Compiling time v0.3.34
   Compiling serde_json v1.0.115
   Compiling serde_urlencoded v0.7.1
   Compiling hyper v0.14.28
   Compiling parking_lot v0.12.1
   Compiling fancy-regex v0.11.0
   Compiling num-cmp v0.1.0
   Compiling uuid v1.8.0
   Compiling bytecount v0.6.7
   Compiling windows v0.54.0 (C:\sources\windows-rs\crates\libs\windows)
   Compiling reqwest v0.11.27
   Compiling jsonschema v0.17.1
   Compiling sample_component_json_validator v0.0.0 (C:\sources\windows-rs\crates\samples\components\json_validator)
    Finished `test` profile [unoptimized + debuginfo] target(s) in 30.37s
     Running unittests src\lib.rs (target\debug\deps\sample_component_json_validator-f5238ba2882a02cc.exe)

running 4 tests
test invalid_create_params ... ok
test invalid_validate_params ... ok
test simple ... ok
test sanitized_value ... FAILED

failures:

---- sanitized_value stdout ----
thread 'sanitized_value' panicked at crates\samples\components\json_validator\src\lib.rs:310:9:
assertion `left == right` failed
  left: ",\0agXn 1,\"name\":\"Kenny\"}"
 right: "{\"age\":21,\"name\":\"Kenny\"}"
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


failures:
    sanitized_value

test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.14s

error: test failed, to rerun pass `-p sample_component_json_validator --lib`

@dpaoliello
Copy link
Collaborator Author

We'd need to test it with arm64ec-pc-windows-msvc, but I haven't finished adding standard library support for that target yet - I'm trying to get it working locally, but LLVM is giving me some weird failures...

@riverar
Copy link
Collaborator

riverar commented Mar 29, 2024

@dpaoliello Ah right. If you'd like a hand, I'd be happy to stand up arm64ec testing here too. Just need to know what to pull down.

@kennykerr
Copy link
Collaborator

kennykerr commented Apr 1, 2024

@dpaoliello if you're stuck in a chicken-egg situation trying to update rust-lang via windows-bindgen we could do this in two steps. First add the cfg support and then separately update the targets, since the Standard Library doesn't use windows-targets.

@dpaoliello
Copy link
Collaborator Author

That's not the issue: your tests uncovered a gap in LLVM's support for Arm64EC, so I'm going to have to fix that first.

@kennykerr
Copy link
Collaborator

Sweet!

@riverar
Copy link
Collaborator

riverar commented Apr 1, 2024

We can address gnu/gnulvvm targets later too if that helps.

@dpaoliello
Copy link
Collaborator Author

@kennykerr I've resolved the issues that I was seeing, and can confirm that the tests 1) pass when building as Arm64EC and run on an Arm64 device and 2) the test binaries are run as "Arm64 (x64 compatible)" (per Task Manager).

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

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

Thanks - that's good enough for me.

@kennykerr kennykerr merged commit ac4643e into microsoft:master Apr 5, 2024
69 checks passed
@dpaoliello dpaoliello deleted the arm64ec branch April 5, 2024 20:02
@ChrisDenton ChrisDenton mentioned this pull request Jun 6, 2024
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.

None yet

4 participants