Skip to content

crossgen2 fails when a Managed C++ dll is passed as a reference assembly #67849

Closed

Description

@AArnott

Description

When trying to crossgen2 a C# assembly that was originally compiled with a reference to a Managed C++ dll, crossgen2 fails

This is not asking for support to crossgen a managed C++ dll. But given crossgen2 produces the best native code when the transitive closure of assemblies referenced by a C# assembly are provided, my build script passes in all the reference (or copy local runtime) assemblies. Filtering out the Managed C++ assembly is infeasible because my build script has no insight into the content of the ref assemblies to ascertain which are managed C++. If crossgen2 cannot process these, it should skip them (possibly emitting a warning) instead of emitting an error and bailing out.

Reproduction Steps

crossgen2 somecsharp.dll -r somemanagedcpp.dll

Expected behavior

A successful crossgen run. Ideally with fully compiled native code even in methods that reference APIs from the managed C++ assembly.

Actual behavior

The assembly cannot be crossgen'd at all.

Internal.CommandLine.CommandLineException : error : managed C++ is not supported: (managed c++ dll path)

Regression?

No response

Known Workarounds

I manually drop the reference to the Managed C++ assembly from the CLI and it starts working.
Note this works even while the c# assembly retains the reference to the managed C++ assembly itself.

Configuration

No response

Other information

No response

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Apr 11, 2022
  2. AArnott commented on Apr 11, 2022

    @AArnott
    ContributorAuthor

    #38096 might be related.

  3. MichalStrehovsky commented on Apr 15, 2022

    @MichalStrehovsky
    Member

    This might be as easy as deleting the current detection and enabling the check that NativeAOT compiler uses: dotnet/runtimelab#1046 (remove ifdef)

    Might want to change the exception to be a TypeSystem one so that it doesn't crash the compiler and instead takes the codepaths that we e.g. have for unresolvable references.

  4. self-assigned this
    on Jun 20, 2022
  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 20, 2022
  6. added this to the 7.0.0 milestone on Jun 20, 2022
  7. trylek commented on Jun 20, 2022

    @trylek
    Member

    I agree that non-destructive behavior is probably more appropriate, in contrast to NativeAOT we just need to make sure that a bug doesn't end up incorrectly marking all assemblies as Managed C++ as that's a "non-destructive" bug in Crossgen2 but still one we don't want to tolerate as it would cancel all R2R perf wins; so we should probably either add a command-line option to suppress the failure or just make it a failure for the "main" input files but not for the "reference" files.

  8. modified the milestones: 7.0.0, 8.0.0 on Jul 27, 2022
  9. modified the milestones: 8.0.0, 9.0.0 on Aug 4, 2023
  10. modified the milestones: 9.0.0, 10.0.0 on Aug 6, 2024
  11. ivdiazsa commented on Aug 21, 2024

    @ivdiazsa
    Contributor

    Is this issue still happening?

  12. locked and limited conversation to collaborators on Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions