Skip to content

Importing pal.h causes undeclared identifier because of order of macro definitions #78286

Open

Description

Description

I have some code which uses the .NET 6 JIT and I'm updating it too .NET 7. It needs to import <windows.h> and <pal.h> but I'm getting an error on cross-compile/universal2 builds in clang-c++:

 In file included from /Users/anthonyshaw/CLionProjects/pyjion/src/pyjion/codemodel.h:43:
      In file included from /Users/anthonyshaw/CLionProjects/pyjion/CoreCLR/src/coreclr/pal/inc/rt/windows.h:12:
      In file included from /Users/anthonyshaw/CLionProjects/pyjion/CoreCLR/src/coreclr/pal/inc/rt/palrt.h:136:
      /Users/anthonyshaw/CLionProjects/pyjion/CoreCLR/src/coreclr/pal/inc/pal.h:3546:1: error: use of undeclared identifier 'g_arm64_atomics_present'
      Define_InterlockMethod(
      ^
      /Users/anthonyshaw/CLionProjects/pyjion/CoreCLR/src/coreclr/pal/inc/pal.h:3501:9: note: expanded from macro 'Define_InterlockMethod'
          if (g_arm64_atomics_present)                                \
              ^
      /Users/anthonyshaw/CLionProjects/pyjion/CoreCLR/src/coreclr/pal/inc/pal.h:3553:1: error: use of undeclared identifier 'g_arm64_atomics_present'
      Define_InterlockMethod(
      ^
      /Users/anthonyshaw/CLionProjects/pyjion/CoreCLR/src/coreclr/pal/inc/pal.h:3501:9: note: expanded from macro 'Define_InterlockMethod'
          if (g_arm64_atomics_present)                                \

Looking at the source code, the macro HOST_ARM64 is defined beneath the check on line 77 for it, so the global is never defined, which means imports of this header fail.

The header is required to use clrlibjit.xxx directly.

Reproduction Steps

Expected behavior

Actual behavior

Regression?

Yes, worked on .NET 6

Known Workarounds

No response

Configuration

No response

Other information

No response

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions