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

x86_64-win7-windows-msvc target cannot run #128218

Closed
linuxlin365 opened this issue Jul 26, 2024 · 13 comments
Closed

x86_64-win7-windows-msvc target cannot run #128218

linuxlin365 opened this issue Jul 26, 2024 · 13 comments
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. O-windows-7 OS: Windows 7 or Windows Server 2008 R2 or etc.

Comments

@linuxlin365
Copy link

linuxlin365 commented Jul 26, 2024

I'm using rust 1.79.0 and can't find the win7 target

cargo build --release --target x86_64-win7-windows-msvc:

warning: `C:\Users\GL\.cargo\config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
   Compiling cfg-if v1.0.0
   Compiling scopeguard v1.2.0
   Compiling simd-adler32 v0.3.5
   Compiling typenum v1.16.0
   Compiling windows_x86_64_msvc v0.48.0
   Compiling adler v1.0.2
   Compiling memchr v2.5.0
   Compiling subtle v2.5.0
   Compiling crossbeam-epoch v0.9.15
   Compiling libc v0.2.147
   Compiling futures-core v0.3.28
   Compiling memoffset v0.9.0
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-win7-windows-msvc` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-win7-windows-msvc`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `adler` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `cfg-if` (lib) due to 1 previous error
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-win7-windows-msvc` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-win7-windows-msvc`

error: could not compile `subtle` (lib) due to 1 previous error
error: could not compile `libc` (lib) due to 1 previous error
error: could not compile `simd-adler32` (lib) due to 1 previous error
error: could not compile `scopeguard` (lib) due to 1 previous error
error: could not compile `typenum` (lib) due to 1 previous error
error: could not compile `memchr` (lib) due to 1 previous error
error: could not compile `windows_x86_64_msvc` (lib) due to 1 previous error
error: could not compile `memoffset` (lib) due to 1 previous error
error: could not compile `futures-core` (lib) due to 1 previous error

rustup target add x86_64-win7-windows-msvc:

error: toolchain 'stable-x86_64-pc-windows-msvc' does not support target 'x86_64-win7-windows-msvc'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html

rustc --version:

PS D:\code\py\mitmproxy_rs-0.2.2\ffi> rustc --version
rustc 1.79.0 (129f3b996 2024-06-10)

rustc --version --verbose:

PS D:\code\py\mitmproxy_rs-0.2.2\ffi> rustc --version --verbose
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-pc-windows-msvc
release: 1.79.0
LLVM version: 18.1.7
@linuxlin365 linuxlin365 added the C-bug Category: This is a bug. label Jul 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 26, 2024
@tgross35
Copy link
Contributor

tgross35 commented Jul 26, 2024

Do you know the most recent version this worked with, was it 1.78? And can you test with nightly?

Per the docs you will need to build with -Z build-std, but the compiler forbidding the target is weird https://doc.rust-lang.org/beta/rustc/platform-support/win7-windows-msvc.html. Unless maybe we only enable it for nightly.

@tgross35 tgross35 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-windows-7 OS: Windows 7 or Windows Server 2008 R2 or etc. labels Jul 26, 2024
@tgross35
Copy link
Contributor

tgross35 commented Jul 26, 2024

Cc @roblabla who is listed as the target maintainer, if you know anything more.

@linuxlin365
Copy link
Author

您知道最新版本是否适用吗?是 1.78 吗?您可以使用 Nightly 进行测试吗?

根据文档,您需要使用 进行构建-Z build-std,但编译器禁止目标很奇怪https://doc.rust-lang.org/beta/rustc/platform-support/win7-windows-msvc.html。除非我们只在夜间启用它。

@tgross35 Use x86 64-win7-windows-msvc only at night, right?

@tgross35
Copy link
Contributor

I think maybe. Could you try the following?

rustup update nightly

# Only need one of these, but I don't know which one will work
cargo +nightly build --target x86_64-win7-windows-msvc
cargo +nightly build --target x86_64-win7-windows-msvc -Zbuild-std

The cargo command might tell you to run a rustup command, do that if it asks.

@linuxlin365
Copy link
Author

rustup update nightly

# Only need one of these, but I don't know which one will work
cargo +nightly build --target x86_64-win7-windows-msvc
cargo +nightly build --target x86_64-win7-windows-msvc -Zbuild-std

I tried to run the command you said

cargo +nightly build --target x86_64-win7-windows-msvc --release

warning: `C:\Users\GL\.cargo\config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
    Blocking waiting for file lock on package cache
    Updating `aliyun` index
  Downloaded memoffset v0.8.0 (registry `aliyun`)
  Downloaded stable_deref_trait v1.2.0 (registry `aliyun`)
  Downloaded universal-hash v0.5.1 (registry `aliyun`)
  Downloaded poly1305 v0.8.0 (registry `aliyun`)
  Downloaded untrusted v0.9.0 (registry `aliyun`)
  Downloaded pyo3-asyncio v0.18.0 (registry `aliyun`)
  Downloaded lazy_static v1.4.0 (registry `aliyun`)
  Downloaded semver v1.0.18 (registry `aliyun`)
  Downloaded thiserror v1.0.43 (registry `aliyun`)
  Downloaded smoltcp v0.10.0 (registry `aliyun`)
  Downloaded serde v1.0.171 (registry `aliyun`)
  Downloaded tracing v0.1.37 (registry `aliyun`)
  Downloaded heapless v0.7.16 (registry `aliyun`)
  Downloaded flume v0.10.14 (registry `aliyun`)
  Downloaded serde_derive v1.0.171 (registry `aliyun`)
  Downloaded rayon v1.7.0 (registry `aliyun`)
  Downloaded qoi v0.4.1 (registry `aliyun`)
  Downloaded petgraph v0.6.3 (registry `aliyun`)
  Downloaded futures-util v0.3.28 (registry `aliyun`)
  Downloaded miniz_oxide v0.7.1 (registry `aliyun`)
  Downloaded flate2 v1.0.26 (registry `aliyun`)
  Downloaded syn v2.0.26 (registry `aliyun`)
  Downloaded regex v1.9.1 (registry `aliyun`)
  Downloaded pyo3 v0.18.3 (registry `aliyun`)
  Downloaded parking_lot_core v0.9.8 (registry `aliyun`)
  Downloaded tempfile v3.6.0 (registry `aliyun`)
  Downloaded smallvec v1.11.0 (registry `aliyun`)
  Downloaded pyo3-build-config v0.18.3 (registry `aliyun`)
  Downloaded pin-project-internal v1.1.2 (registry `aliyun`)
  Downloaded defmt v0.3.5 (registry `aliyun`)
  Downloaded data-encoding v2.4.0 (registry `aliyun`)
  Downloaded tiff v0.8.1 (registry `aliyun`)
  Downloaded num-integer v0.1.45 (registry `aliyun`)
  Downloaded regex-automata v0.3.3 (registry `aliyun`)
  Downloaded itertools v0.10.5 (registry `aliyun`)
  Downloaded cfg-if v1.0.0 (registry `aliyun`)
  Downloaded untrusted v0.7.1 (registry `aliyun`)
  Downloaded unindent v0.1.11 (registry `aliyun`)
  Downloaded typenum v1.16.0 (registry `aliyun`)
  Downloaded libc v0.2.147 (registry `aliyun`)
  Downloaded thiserror-impl v1.0.43 (registry `aliyun`)
  Downloaded rustc-demangle v0.1.23 (registry `aliyun`)
  Downloaded prost-build v0.11.9 (registry `aliyun`)
  Downloaded pin-project-lite v0.2.10 (registry `aliyun`)
  Downloaded object v0.31.1 (registry `aliyun`)
  Downloaded opaque-debug v0.3.0 (registry `aliyun`)
  Downloaded num-rational v0.4.1 (registry `aliyun`)
  Downloaded multimap v0.8.3 (registry `aliyun`)
  Downloaded winapi v0.3.9 (registry `aliyun`)
  Downloaded 49 crates (7.2 MB) in 15.88s (largest was `tiff` at 1.4 MB)
   Compiling autocfg v1.1.0
   Compiling proc-macro2 v1.0.66
   Compiling unicode-ident v1.0.11
   Compiling cfg-if v1.0.0
   Compiling windows_x86_64_msvc v0.48.0
   Compiling scopeguard v1.2.0
   Compiling libc v0.2.147
   Compiling version_check v0.9.4
   Compiling typenum v1.16.0
   Compiling syn v1.0.109
   Compiling simd-adler32 v0.3.5
   Compiling once_cell v1.18.0
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-win7-windows-msvc` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-win7-windows-msvc`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-win7-windows-msvc` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-win7-windows-msvc`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: could not compile `simd-adler32` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `scopeguard` (lib) due to 1 previous error
error: could not compile `cfg-if` (lib) due to 1 previous error



rustup target add x86_64-win7-windows-msvc

error: toolchain 'nightly-x86_64-pc-windows-msvc' does not support target 'x86_64-win7-windows-msvc'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html

The compilation succeeded, but the linking failed:

cargo +nightly build --target x86_64-win7-windows-msvc -Zbuild-std --release

   Compiling pyo3-asyncio v0.18.0
error: linking with `link.exe` failed: exit code: 1181
  |
  = note: "D:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\GL\\AppData\\Local\\Temp\\rustc1w6Mnw\\lib.def" "/NOLOGO" "C:\\Users\\GL\\AppData\\Local\\Temp\\rustc1w6Mnw\\symbols.o" "D:\\code\\py\\mitmproxy_rs-0.2.2\\target\\x86_64-win7-windows-msvc\\release\\deps\\mitmproxy_rs.mitmproxy_rs.a05f9abf469ef553-cgu.0.rcgu.o" "/LIBPATH:D:\\code\\py\\mitmproxy_rs-0.2.2\\target\\x86_64-win7-windows-msvc\\release\\deps" "/LIBPATH:D:\\code\\py\\mitmproxy_rs-0.2.2\\target\\release\\deps" "/LIBPATH:D:\\code\\py\\mitmproxy_rs-0.2.2\\target\\x86_64-win7-windows-msvc\\release\\build\\ring-35f8b0ce549f7d6d\\out" "/LIBPATH:C:\\Users\\GL\\AppData\\Local\\Programs\\Python\\Python311\\libs" "/LIBPATH:C:\\Users\\GL\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-win7-windows-msvc\\lib" "C:\\Users\\GL\\AppData\\Local\\Temp\\rustc1w6Mnw\\libring-8f3c9fe5a7f78c50.rlib" "D:\\code\\py\\mitmproxy_rs-0.2.2\\target\\x86_64-win7-windows-msvc\\release\\deps\\libcompiler_builtins-043e6885e8ec3f1f.rlib" "bcrypt.lib" "advapi32.lib" "windows.0.48.0.lib" "advapi32.lib" "cfgmgr32.lib" "credui.lib" "fwpuclnt.lib" "kernel32.lib" "ntdll.lib" "secur32.lib" "user32.lib" "ws2_32.lib" "ntdll.lib" "windows.0.48.0.lib" "kernel32.lib" "windows.0.48.0.lib" "python3.lib" "legacy_stdio_definitions.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "kernel32.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:C:\\Users\\GL\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-win7-windows-msvc\\lib" "/OUT:D:\\code\\py\\mitmproxy_rs-0.2.2\\target\\x86_64-win7-windows-msvc\\release\\deps\\mitmproxy_rs.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:D:\\code\\py\\mitmproxy_rs-0.2.2\\target\\x86_64-win7-windows-msvc\\release\\deps\\mitmproxy_rs.dll.lib" "/DEBUG" "/PDBALTPATH:%_PDB%" "/NATVIS:C:\\Users\\GL\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\intrinsic.natvis" "/NATVIS:C:\\Users\\GL\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\liballoc.natvis" "/NATVIS:C:\\Users\\GL\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libcore.natvis" "/NATVIS:C:\\Users\\GL\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\etc\\libstd.natvis"
  = note: LINK : fatal error LNK1181: 无法打开输入文件“windows.0.48.0.lib”␍


@tgross35
Copy link
Contributor

Ok, the second result is more like what is expected. However, I have no clue whether or not Microsoft's more recent link.exe is supposed to work for windows 7 targets. Maybe you can try following the cross compilation steps at https://doc.rust-lang.org/beta/rustc/platform-support/win7-windows-msvc.html#cross-compilation-toolchains-and-c-code?

@linuxlin365
Copy link
Author

@tgross35 thank you

I have successfully compiled and linked but it won't work under Windows 7

image

image

IsProcessCritical Function Minimum support Windows 8.1
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocesscritical

I don't quite understand the reason for the rust compiler, will I not be able to run in win7 after I set the win7 target?

@tgross35
Copy link
Contributor

Windows 7 reached its EOL in 2020 and its end of extended support in early 2023. After that happened, it was demoted to a tier3 target.

Tier3 means that the Rust compiler knows about it, but it is not really officially supported. Meaning it is not tested in CI, and things may break. Fixes are always welcome from anyone who uses the target, it's just unlikely that anybody who doesn't use windows 7 will pick it up.

Some more info: https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-3.

I don't know what the fix is here, but if you figure out exactly where the requirement for IsProcessCritical comes from, it might be possible to fix. (Doesn't seem to be mentioned in the Rust codebase).

@tgross35
Copy link
Contributor

Hm actually - could you try compiling a simple Hello World with no dependencies? Maybe only one of the deps needs it but std doesn't.

@roblabla
Copy link
Contributor

roblabla commented Jul 26, 2024

x86_64-win7-windows-msvc is tier3, so it is not built by the Rust CI, and hence not available through rustup. You'll need to use a nightly toolchain with -Zbuild-std to run it.

I do run the CI on private infrastructure to make sure it works on windows 7, and it's currently passing.

I think the immediate problem you're seeing is here. Your program is using IsProcessCritical, which is not available on Windows 7. You'll need the code to avoid this function.

Furthermore, there are currently problems with windows-rs where it will implicitly use functions that aren't supported on Windows 7 since 0.53 (see microsoft/windows-rs#2817), and other versions also have other problems with the win7 target. I have some forks for some versions (latest is 0.52) to avoid those issues over at https://github.com/justrustThings/windows-rs (look for the branches called stuff-)

@saethlin saethlin added C-discussion Category: Discussion or questions that doesn't represent real issues. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 30, 2024
@saethlin
Copy link
Member

I'm closing this because I don't think there's anything for us to do here. Don't let that stop you from continuing to comment, if you want to.

@deadash
Copy link

deadash commented Oct 12, 2024

@roblabla When compiling and running the project on Windows 7, the eprint macro is not working as expected. The compilation is done using the following command:

cargo +nightly build --target i686-win7-windows-msvc -Z build-std --release

Environment:

  • Operating System: Windows 7
  • Rust Version: rustc 1.83.0-nightly (1bc403d 2024-10-11)
  • Target: i686-win7-windows-msvc

@tgross35
Copy link
Contributor

@deadash that seems like a separate problem from the original here (the original being related to a dependency that is using IsProcessCritical). Could you open a new issue? Please also include a description of what the unexpected behavior is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-discussion Category: Discussion or questions that doesn't represent real issues. O-windows-7 OS: Windows 7 or Windows Server 2008 R2 or etc.
Projects
None yet
Development

No branches or pull requests

6 participants