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

PEVerify fails compiling entrypoint in metadata-only mode #76707

Open
jjonescz opened this issue Jan 10, 2025 · 3 comments · May be fixed by #76783
Open

PEVerify fails compiling entrypoint in metadata-only mode #76707

jjonescz opened this issue Jan 10, 2025 · 3 comments · May be fixed by #76783
Assignees
Milestone

Comments

@jjonescz
Copy link
Member

jjonescz commented Jan 10, 2025

Version Used: 9881daa

Steps to Reproduce:

[Fact]
public void EmitMetadataOnly_TopLevelStatements()
{
    CompileAndVerify("""
        System.Console.WriteLine("a");
        """,
        emitOptions: EmitOptions.Default.WithEmitMetadataOnly(true))
        .VerifyDiagnostics();
}

Expected Behavior: Succeeds.

Actual Behavior: PEVerify fails with "Bad token as entry point in CLR header."

Note that using Main and TestOptions.ReleaseExe fails in the same way.

Perhaps it's expected that ref assemblies are only supported by PEVerify for class libraries, not console apps.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 10, 2025
@jjonescz jjonescz changed the title Top-level statements fail PEVerify in metadata-only mode PEVerify fails compiling entrypoint in metadata-only mode Jan 10, 2025
@AlekseyTs
Copy link
Contributor

We might be failing to set the entry point in metadata only mode.

@AlekseyTs
Copy link
Contributor

CC @jcouv

@jaredpar jaredpar added this to the 17.14 milestone Jan 15, 2025
@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jan 15, 2025
@jjonescz jjonescz linked a pull request Jan 16, 2025 that will close this issue
@jjonescz
Copy link
Member Author

jjonescz commented Jan 17, 2025

Working on a fix by emitting entrypoint in metadata-only EXE compilation. But it's a breaking change - previously a metadata-only EXE compilation wouldn't fail if the entrypoint was missing, now it does. Alternatively, I could make it so that it doesn't fail when the entrypoint is missing and continue with the previous behavior (emitting an invalid, PEVerify-failing assembly) in that case.

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

Successfully merging a pull request may close this issue.

3 participants