Skip to content

Managed ilasm fails to assemble VTableFixups.il with nested preprocessor conditionals #137424

Closed

Description

@akoeplinger

Description

The ilasm package update in #137416 breaks the build of the mixed-mode loader test assemblies VTableFixupsX64.ilproj and VTableFixupsX86.ilproj. The assembler rejects the nested #ifdef/#else directives in VTableFixups.il, then emits cascading macro-expansion and VTable-fixup errors.

@jkoritzinsky could you take a look at the managed ilasm preprocessor handling here?

Reproduction Steps

Use the source at commit bc6c20ebb0b070adc9ba59c69ddd2eaf329aa078 with Microsoft.NET.Sdk.IL / Microsoft.NETCore.ILAsm version 12.0.0-alpha.1.26561.116.

Build src/tests/Loader/classloader/MixedMode/VTableFixupsX64.ilproj or VTableFixupsX86.ilproj in a Windows runtime-test build. The x64 assembler invocation from CI is equivalent to running the package's ilasm in that directory with:

-QUIET -NOLOGO -ANAME=VTableFixupsX64 -OPTIMIZE -DLL -PE64 -X64 -OUTPUT=VTableFixupsX64.dll X64.il VTableFixups.il

The relevant source is:

#ifdef ARM64
#define SLOT "int64"
#else
#ifdef X64
#define SLOT "int64"
#else
#define SLOT "int32"
#endif
#endif

This is confirmed by the linked CI logs; a standalone local reproduction has not yet been run.

Expected behavior

The assembler handles the nested conditionals, selects int64 for X64 (or int32 for X86), and assembles the VTableFixups tests successfully.

Actual behavior

VTableFixups.il(13,1): error Preprocessor: preprocessor syntax error at: '#else\r'
VTableFixups.il(14,9): error ILA0000: line 14:8 no viable alternative at input '#defineint64'

For X86 this is followed by ILA0042 (VTable fixup width flags do not match I386) and ILA0043 (invalid VTable entries).

Evidence: Windows x86 build, Windows ARM64 build.

Regression?

Observed after updating the ilasm package from 12.0.0-alpha.1.26528.120 to 12.0.0-alpha.1.26561.116 in the codeflow PR. A standalone old/new package comparison has not yet been performed.

Known Workarounds

Temporarily exclude the two affected VTableFixups assemblies and their dependent test case while retaining the other mixed-mode loader tests. Re-enable them once the corrected ilasm package is consumed and both assemblies build and their tests pass.

Configuration

Windows runtime-test builds targeting x86, x64, and ARM64. The failing input assemblies are the X86 and X64 VTableFixups projects. This fails during IL assembly, before test execution.

Other information

Source inspection suggests PreprocessedTokenSource.ConsumeDisabledPreprocessorBlock returns NextTokenWithoutNestedEof when entering the active #else branch. In this input, that returns the immediately following #ifdef X64 without processing it as a directive. The next #else can then be interpreted as a second else for the outer conditional. This is a suspected cause, not a locally verified fix.

Source: https://github.com/dotnet/runtime/blob/bc6c20ebb0b070adc9ba59c69ddd2eaf329aa078/src/tools/ilasm/src/ILAssembler/PreprocessedTokenSource.cs

Note

This issue was generated by GitHub Copilot from CI logs and source inspection.

Activity

  1. added
    untriaged
    on Nov 12, 2026
  2. dotnet-policy-service commented on Nov 12, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @dotnet/jit-contrib
    See info in area-owners.md if you want to be subscribed.

  3. removed
    untriaged
    on Nov 14, 2026
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

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions