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

Failure to compile unit tests for procedural macros on stable-x86_64-pc-windows-gnu #128944

Open
quixoticaxis opened this issue Aug 10, 2024 · 2 comments
Labels
C-bug Category: This is a bug. O-windows-gnu Toolchain: GNU, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@quixoticaxis
Copy link

quixoticaxis commented Aug 10, 2024

I tried the following code.

In the proc-macro nested crate macros-derive:

use proc_macro::TokenStream;

#[proc_macro_derive(NoDerive)] // does nothing
pub fn derive_print_type(_input: proc_macro::TokenStream) -> proc_macro::TokenStream {
    TokenStream::new()
}

#[cfg(test)]
mod tests {

    #[test]
    fn test() {}
}

In the main crate:

use macros_derive::NoDerive;

fn main() {
    _ = S;
}

#[derive(NoDerive)]
struct S;

I expected to see this happen: cargo test runs to completion.

Instead, compilation of the test target fails:

Compiling macros v0.1.0 (…\proc-macro failure\macros)
Compiling macros-derive v0.1.0 (…\proc-macro failure\macros\derive)
error: Error calling dlltool 'dlltool.exe': program not found

error: could not compile macros-derive (lib test) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

If I add dlltool from self-contained folder (from inside the toolchain folder) to PATH, the compilation fails with:

error: Dlltool could not create import library

Stable version:

rustc 1.80.0 (0514789 2024-07-21)
binary: rustc
commit-hash: 0514789
commit-date: 2024-07-21
host: x86_64-pc-windows-gnu
release: 1.80.0
LLVM version: 18.1.7

Nightly version (same result):

rustc 1.82.0-nightly (ca5d25e 2024-08-09)
binary: rustc
commit-hash: ca5d25e
commit-date: 2024-08-09
host: x86_64-pc-windows-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

@quixoticaxis quixoticaxis added the C-bug Category: This is a bug. label Aug 10, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 10, 2024
@quixoticaxis
Copy link
Author

I've found out (looking at #103939) that it is possible to install MSYS2, then install clang for MSYS2 and use the clang's executable. (I did not test it for now. ) Is it the currently optimal workaround or are there easier ways to make things work with GNU toolchain on Windows?

@quixoticaxis
Copy link
Author

I tried different stable versions: seems like the tests compiled but failed with STATUS_DLL_NOT_FOUND up to 1.77, and failed to compile from 1.78 onwards.

I also found the version that worked out of the box. The last stable version I found to support proc-macro tests on Windows GNU toolchain is 1.43. Even tried a real test with proc-macro2 (used 0.4 version), works fine.

@jieyouxu jieyouxu added O-windows-gnu Toolchain: GNU, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 13, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-windows-gnu Toolchain: GNU, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants