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

Starting with nightly-2021-01-13 (1.51) rustc fails to build archives on Windows 7 #81051

Closed
MSxDOS opened this issue Jan 15, 2021 · 43 comments · Fixed by #82605
Closed

Starting with nightly-2021-01-13 (1.51) rustc fails to build archives on Windows 7 #81051

MSxDOS opened this issue Jan 15, 2021 · 43 comments · Fixed by #82605
Assignees
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. ICEBreaker-LLVM Bugs identified for the LLVM ICE-breaker group O-windows Operating system: Windows P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@MSxDOS
Copy link

MSxDOS commented Jan 15, 2021

E.g. cargo check --verbose on https://github.com/japaric/ufmt

F:\ufmt-master>cargo check --verbose
   Compiling unicode-xid v0.2.1
       Fresh ufmt-write v0.1.0 (F:\ufmt-master\write)
     Running `rustc --crate-name unicode_xid F:\.cargo\registry\src\github.com-1ecc6299db9
ec823\unicode-xid-0.2.1\src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,art
ifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -
-cfg "feature=\"default\"" -C metadata=df09097284490053 -C extra-filename=-df0909728449005
3 --out-dir F:\ufmt-master\target\debug\deps -L dependency=F:\ufmt-master\target\debug\dep
s --cap-lints allow`
       Fresh proc-macro-hack v0.5.19
   Compiling proc-macro2 v1.0.24
     Running `rustc --crate-name proc_macro2 --edition=2018 F:\.cargo\registry\src\github.
com-1ecc6299db9ec823\proc-macro2-1.0.24\src\lib.rs --error-format=json --json=diagnostic-r
endered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no
-C debuginfo=2 --cfg "feature=\"default\"" --cfg "feature=\"proc-macro\"" -C metadata=b463
43984a7d2c00 -C extra-filename=-b46343984a7d2c00 --out-dir F:\ufmt-master\target\debug\dep
s -L dependency=F:\ufmt-master\target\debug\deps --extern unicode_xid=F:\ufmt-master\targe
t\debug\deps\libunicode_xid-df09097284490053.rmeta --cap-lints allow --cfg lexerror_displa
y --cfg hygiene --cfg use_proc_macro --cfg wrap_proc_macro --cfg proc_macro_span`
error: failed to build archive: permission denied

error: aborting due to previous error

error: could not compile `unicode-xid`

Caused by:
  process didn't exit successfully: `rustc --crate-name unicode_xid F:\.cargo\registry\src
\github.com-1ecc6299db9ec823\unicode-xid-0.2.1\src\lib.rs --error-format=json --json=diagn
ostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C embed-bitc
ode=no -C debuginfo=2 --cfg "feature=\"default\"" -C metadata=df09097284490053 -C extra-fi
lename=-df09097284490053 --out-dir F:\ufmt-master\target\debug\deps -L dependency=F:\ufmt-
master\target\debug\deps --cap-lints allow` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error: failed to build archive: permission denied

error: aborting due to previous error

error: build failed
rustc 1.51.0-nightly (e38fb306b 2021-01-14)
binary: rustc
commit-hash: e38fb306b7f5e65cca34df2dab1f0db15e1defb4
commit-date: 2021-01-14
host: x86_64-pc-windows-msvc
release: 1.51.0-nightly
LLVM version: 11.0
@MSxDOS MSxDOS added the C-bug Category: This is a bug. label Jan 15, 2021
@tesuji
Copy link
Contributor

tesuji commented Jan 16, 2021

Cannot reproduce on Windows target on CI.
Maybe check you systems again.

@MSxDOS
Copy link
Author

MSxDOS commented Jan 17, 2021

The failure happens on a Windows 7 x64 machine. I reproduced this on another machine running Windows 7 x86, this time with i686-pc-windows-gnu toolchain.

@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 17, 2021
@tesuji
Copy link
Contributor

tesuji commented Jan 17, 2021

I don't have any Windows machine to test (left alone Windows 7 which not available on CI).
All builds on Windows 10 with msvc and gnu toolchain succeeded: https://github.com/lzutao/ufmt/runs/1717188912?check_suite_focus=true

Let's ping Windows group to see if any folks can verify the issue:
@rustbot ping windows

@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2021

Error: Only Rust team members can ping teams.

Please let @rust-lang/release know if you're having trouble with this bot.

@LeSeulArtichaut
Copy link
Contributor

@rustbot ping windows

@rustbot rustbot added the O-windows Operating system: Windows label Jan 17, 2021
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2021

Hey Windows Group! This bug has been identified as a good "Windows candidate".
In case it's useful, here are some instructions for tackling these sorts of
bugs. Maybe take a look?
Thanks! <3

cc @arlosi @danielframpton @gdr-at-ms @kennykerr @luqmana @lzybkr @nico-abram @retep998 @rylev @sivadeilra

@sivadeilra
Copy link

sivadeilra commented Jan 17, 2021

Speaking for the Windows team at Microsoft, Windows 7 has reached End of Life. We're not interested in providing any further support for Win 7 development.

We (and members of the Rust community) are also actively working on min_api_target_version RFC, which would officially deprecate some older Windows platforms (those that are EOL) for Rust.

I realize that this position may not be satisfying. However, we have to draw the line somewhere on supporting old versions of OSes, and Windows 7 has reached its official EOL. You may still be able to target Windows 7, by cross-compiling (compiling on a modern Windows version, or by compiling on Linux targeting Windows).

@sivadeilra
Copy link

Also, you might check whether you have any anti-virus products installed. If so, try disabling them, or at least adding an exception that covers your development tree. Sometimes "permissions" problems are caused by anti-virus products opening and scanning executable files.

@camelid
Copy link
Member

camelid commented Jan 18, 2021

Apparently, Windows 7 is still a Tier 1 target, so even though it's EOL for Microsoft, Rust still has to support it. It seems that maybe we should reduce Windows 7 to a lower tier at some point soon.

@KamilaBorowska
Copy link
Contributor

KamilaBorowska commented Jan 19, 2021

I would like to point out that according to Firefox Hardware Across the Web report, Windows 7 is used by 23% of Firefox users. Microsoft also offers paid extended security updates through January 2023 for Windows 7 which may be actually used in enterprise environments. I think it's too early to drop support for Windows 7.

That said, this particular issue feels like an issue with anti-virus. @MSxDOS, could you check whether this issue occurs with an antivirus product disabled?

@asaadmohammed74
Copy link

I would like to point out that according to Firefox Hardware Across the Web report, Windows 7 is used by 23% of Firefox users. Microsoft also offers paid extended security updates through January 2023 for Windows 7 which may be actually used in enterprise environments. I think it's too early to drop support for Windows 7.

That said, this particular issue feels like an issue with anti-virus. @MSxDOS, could you check whether this issue occurs with an antivirus product disabled?

im having the same issue, i also use windows 7 x64. and don't have any anti virus installed

@MSxDOS
Copy link
Author

MSxDOS commented Jan 19, 2021

could you check whether this issue occurs with an antivirus product disabled?

I've already checked and eliminated that from the list of possible causes along with any possible system issues I could think of. The problem appears on two machines with different hardware and software, one of which had a fresh installation of Rust toolchain via rustup and the issue appeared instantly.

There's not much I can draw from that cargo log. By the looks of it the issue happens with crates that depend on and use proc-macro crates. In some cases cargo check doesn't trigger it but cargo build does.

@asaadmohammed74
Copy link

using RUSTC_LOG=debug
INFO rustc_codegen_ssa::back::link preparing rlib to "G:\\Development\\rust\\hello_world\\target\\debug\\deps\\libanyhow-a96d4d06084a2ac6.rlib

@apiraino
Copy link
Contributor

@asaadmohammed74 and @MSxDOS just a blind shot, IIUC the error error: failed to build archive: permission denied suggests there's an issue when rustc tries to write on those volumes (F: and G:).

Does the user executing rustc have proper permission to those volumes? Does the error happens intermittently or it is always reproducible?

@tmiasko
Copy link
Contributor

tmiasko commented Jan 20, 2021

The commit range includes the update of LLVM submodule #80796, so it is probably caused by one of:

@lzybkr
Copy link
Contributor

lzybkr commented Jan 20, 2021

Permission denied sometimes means another process has an open handle to the file. Process Monitor has been useful to me in tracking down similar issues, which turned out to be an antivirus product in my case.

@apiraino apiraino added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 27, 2021
@FredericaBernkastel
Copy link

Downgraded to nightly-2021-01-12, compilation is successful again.

@MSxDOS
Copy link
Author

MSxDOS commented Jan 29, 2021

@apiraino There are no issues with permissions on both machines... The error is always reproducible.

@leafinsky-li
Copy link

Downgraded to nightly-2021-01-12, compilation is successful again.
I encountered the same problem when upgrading the latest version. After downgrading this version, everything works fine again.

@moxian
Copy link
Contributor

moxian commented Feb 7, 2021

The issue title downplaying the problem a bit.
nightly-2021-01-14 and onward is unable to compile any library crate. I.e. running

rustc +nightly src/lib.rs --crate-type lib

on an empty lib.rs gives the same

error: failed to build archive: permission denied

error: aborting due to previous error

This makes rustc effectively unusable on windows 7. (except for binaries with zero non-proc-macro dependencies)

Here's what's happening, per process monitor:
20210207-085410-Procmon64

I am neither windows, nor LLVM expert so i cannot really interpret it, but to transcribe what's happening (judging purely by the names of the winapi calls):

On stable:

  • we create the temporary libmain.rlib.temp-archive-6748ddf.a
  • write to it
  • SetDispositionInformationFile(Delete = False) (??)
  • rename it to libmain.rlib

very straightforward

On nightly many more things are happening and i'm not sure why:

  • We create the temporary libmain.rlib.temp-archive-d4be097.a
  • Open it and immediately close, multiple times with different arguments (??)
  • SetDispositionInformationFile(Delete = True) (????) (!!!)
  • Write to it
  • QueryOpen it, get told that DELETE_PENDING
  • give up.

Oh, and @tmiasko implied, but did not explicitly mention, the regression happened in #80960.

@moxian
Copy link
Contributor

moxian commented Feb 7, 2021

(Not sure if i have permission to do this, but..)
@rustbot modify labels: +I-prioritize

@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 7, 2021
@LeSeulArtichaut LeSeulArtichaut added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Feb 7, 2021
@LeSeulArtichaut
Copy link
Contributor

Let's @rustbot ping llvm

@cuviper
Copy link
Member

cuviper commented Feb 26, 2021

I opened rust-lang/llvm-project#92 to start, a simple revert which reportedly fixes this issue -- #81051 (comment).

cuviper added a commit to cuviper/llvm-project that referenced this issue Feb 27, 2021
… TempFile doesn't reside on a local drive"

This reverts commit 79657e2.

The change regressed on Windows 7 -- rust-lang/rust#81051
nikic pushed a commit to rust-lang/llvm-project that referenced this issue Feb 27, 2021
… TempFile doesn't reside on a local drive"

This reverts commit 6ec777c, which was
cherry picked to 11.x from 79657e2.

The change regressed on Windows 7 -- rust-lang/rust#81051
nikic pushed a commit to rust-lang/llvm-project that referenced this issue Feb 27, 2021
… TempFile doesn't reside on a local drive"

This reverts commit 79657e2.

The change regressed on Windows 7 -- rust-lang/rust#81051
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 28, 2021
Revert LLVM D81803 because it broke Windows 7

This submodule update reverts <https://reviews.llvm.org/D81803>.

While that change is meant to fix a real bug, [LLVM PR42623], it caused
new permission errors on Windows 7 that make it unable to build any
archives. This is probably the same root cause as [LLVM PR48378].

Fixes rust-lang#81051. We'll file a new Rust issue to track the LLVM resolution.

[LLVM PR42623]: https://bugs.llvm.org/show_bug.cgi?id=42623
[LLVM PR48378]: https://bugs.llvm.org/show_bug.cgi?id=48378
@bors bors closed this as completed in 31814c4 Feb 28, 2021
@moxian
Copy link
Contributor

moxian commented Mar 1, 2021

I just want to confirm that the fix is in nightly, and it's working!

Thanks, @cuviper!

@klensy
Copy link
Contributor

klensy commented Mar 1, 2021

But while it not applied to beta, it can't build rust with download-ci-llvm = true, as it download beta files from 2021-02-14, or maybe i do something wrong.

@moxian
Copy link
Contributor

moxian commented Mar 1, 2021

Either setting your src/stage0.txt to have

date: 2021-02-28
rustc: nightly

or setting in your config.toml

[build]
rustc = "/path/to/nightly/toolchain/bin/rustc.exe"
cargo = "/path/to/nightly/toolchain/bin/cargo.exe"

should work

P.s.: correction: for some reason src/stage0.txt method does not work for me, but the config.toml does.

Although now that I re-read your message, i'm not sure if download-ci-llvm = true would further impact this. I.e. I don't know if the llvm on ci has the fix commit or not. But then again, download-ci-llvm = true seems to do nothing for me, as in I'm trying to run python x.py build and it's currently rebuilding llvm from source anyway, so..

@cuviper
Copy link
Member

cuviper commented Mar 1, 2021

I'm not sure how that download is updated, but the PR is beta-nominated, so once that's approved we can backport it to the beta branch and then update master stage0.txt. Hopefully that will sort it out!

@Mark-Simulacrum
Copy link
Member

Normally we only do so once a cycle, but we're happy to accept PRs if there's some reason to update it outside of that.

@cuviper
Copy link
Member

cuviper commented Mar 1, 2021

See #82677 to track long-term resolution between Windows 7 and the reverted bug fix.

cuviper added a commit to cuviper/rust that referenced this issue Mar 10, 2021
This submodule update reverts <https://reviews.llvm.org/D81803>.

While that change is meant to fix a real bug, [LLVM PR42623], it caused
new permission errors on Windows 7 that make it unable to build any
archives. This is probably the same root cause as [LLVM PR48378].

Fixes rust-lang#81051. We'll file a new Rust issue to track the LLVM resolution.

[LLVM PR42623]: https://bugs.llvm.org/show_bug.cgi?id=42623
[LLVM PR48378]: https://bugs.llvm.org/show_bug.cgi?id=48378

(cherry picked from commit 31814c4)
aganea added a commit to llvm/llvm-project that referenced this issue Mar 24, 2021
As reported here: https://bugs.llvm.org/show_bug.cgi?id=48378#c0
and here: rust-lang/rust#81051
since 79657e2, some programs such as llvm-ar
don't work properly on Windows 7.

The issue is shown in the snippet by Oleksandr Prodan:
https://pastebin.com/v51m3uBU

In essence, once the 'DeleteFile' flag has been set on FILE_DISPOSITION_INFO,
the file path can't be queried anymore with GetFinalPathNameByHandleW. This
however works on Windows 10, GetFinalPathNameByHandleW would return sucessfully.

To workaround the issue, we simply reset the 'DeleteFile' flag before even
checking if we're dealing with a network file.

Tested with `llvm-ar r empty.a a.obj` ran on a network mount. At the moment, we
cannot specifically add a test coverage for this, since it requres mounting a
network drive.
@aganea
Copy link

aganea commented Mar 24, 2021

Hello! I've fixed the issue in LLVM in llvm/llvm-project@64ab2b6 - please let me know if the issue is still there in the next code drop.

@cuviper
Copy link
Member

cuviper commented Mar 24, 2021

Thanks @aganea! I don't have access to test this myself, but hopefully the Windows 7 users here can try it out. Let's collect further feedback on the new open issue, #82677.

tstellar pushed a commit to llvm/llvm-project that referenced this issue Mar 29, 2021
As reported here: https://bugs.llvm.org/show_bug.cgi?id=48378#c0
and here: rust-lang/rust#81051
since 79657e2, some programs such as llvm-ar
don't work properly on Windows 7.

The issue is shown in the snippet by Oleksandr Prodan:
https://pastebin.com/v51m3uBU

In essence, once the 'DeleteFile' flag has been set on FILE_DISPOSITION_INFO,
the file path can't be queried anymore with GetFinalPathNameByHandleW. This
however works on Windows 10, GetFinalPathNameByHandleW would return sucessfully.

To workaround the issue, we simply reset the 'DeleteFile' flag before even
checking if we're dealing with a network file.

Tested with `llvm-ar r empty.a a.obj` ran on a network mount. At the moment, we
cannot specifically add a test coverage for this, since it requres mounting a
network drive.

(cherry picked from commit 64ab2b6)
arichardson pushed a commit to CTSRD-CHERI/llvm-project that referenced this issue Apr 19, 2021
As reported here: https://bugs.llvm.org/show_bug.cgi?id=48378#c0
and here: rust-lang/rust#81051
since 79657e2, some programs such as llvm-ar
don't work properly on Windows 7.

The issue is shown in the snippet by Oleksandr Prodan:
https://pastebin.com/v51m3uBU

In essence, once the 'DeleteFile' flag has been set on FILE_DISPOSITION_INFO,
the file path can't be queried anymore with GetFinalPathNameByHandleW. This
however works on Windows 10, GetFinalPathNameByHandleW would return sucessfully.

To workaround the issue, we simply reset the 'DeleteFile' flag before even
checking if we're dealing with a network file.

Tested with `llvm-ar r empty.a a.obj` ran on a network mount. At the moment, we
cannot specifically add a test coverage for this, since it requres mounting a
network drive.
s194604 pushed a commit to s194604/llvm-playground that referenced this issue Mar 6, 2022
As reported here: https://bugs.llvm.org/show_bug.cgi?id=48378#c0
and here: rust-lang/rust#81051
since 79657e2, some programs such as llvm-ar
don't work properly on Windows 7.

The issue is shown in the snippet by Oleksandr Prodan:
https://pastebin.com/v51m3uBU

In essence, once the 'DeleteFile' flag has been set on FILE_DISPOSITION_INFO,
the file path can't be queried anymore with GetFinalPathNameByHandleW. This
however works on Windows 10, GetFinalPathNameByHandleW would return sucessfully.

To workaround the issue, we simply reset the 'DeleteFile' flag before even
checking if we're dealing with a network file.

Tested with `llvm-ar r empty.a a.obj` ran on a network mount. At the moment, we
cannot specifically add a test coverage for this, since it requres mounting a
network drive.

(cherry picked from commit 64ab2b6)
ajohnson-uoregon pushed a commit to ajohnson-uoregon/clang-rewrite-only that referenced this issue Jul 17, 2022
As reported here: https://bugs.llvm.org/show_bug.cgi?id=48378#c0
and here: rust-lang/rust#81051
since cf62b1d, some programs such as llvm-ar
don't work properly on Windows 7.

The issue is shown in the snippet by Oleksandr Prodan:
https://pastebin.com/v51m3uBU

In essence, once the 'DeleteFile' flag has been set on FILE_DISPOSITION_INFO,
the file path can't be queried anymore with GetFinalPathNameByHandleW. This
however works on Windows 10, GetFinalPathNameByHandleW would return sucessfully.

To workaround the issue, we simply reset the 'DeleteFile' flag before even
checking if we're dealing with a network file.

Tested with `llvm-ar r empty.a a.obj` ran on a network mount. At the moment, we
cannot specifically add a test coverage for this, since it requres mounting a
network drive.

(cherry picked from commit 1d96b47)
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
As reported here: https://bugs.llvm.org/show_bug.cgi?id=48378#c0
and here: rust-lang/rust#81051
since 79657e2339b58bc01fe1b85a448bb073d57d90bb, some programs such as llvm-ar
don't work properly on Windows 7.

The issue is shown in the snippet by Oleksandr Prodan:
https://pastebin.com/v51m3uBU

In essence, once the 'DeleteFile' flag has been set on FILE_DISPOSITION_INFO,
the file path can't be queried anymore with GetFinalPathNameByHandleW. This
however works on Windows 10, GetFinalPathNameByHandleW would return sucessfully.

To workaround the issue, we simply reset the 'DeleteFile' flag before even
checking if we're dealing with a network file.

Tested with `llvm-ar r empty.a a.obj` ran on a network mount. At the moment, we
cannot specifically add a test coverage for this, since it requres mounting a
network drive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. ICEBreaker-LLVM Bugs identified for the LLVM ICE-breaker group O-windows Operating system: Windows P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.