Skip to content

[Native Image] [Windows] Required environment variable names use case-sensitive compare on Windows #11818

@stooke

Description

@stooke

Describe the Issue

The intent of the code in EnvVariableUtils.java is to convert (on Windows) all environment variable names to uppercase, and then see if they are in the set of required names. The appropriate code is called, but not used correctly.

public static boolean isKeyRequired(String key) {
     mapKey(key);
     return isKeyRequiredCondition(key);
}

should be

public static boolean isKeyRequired(String key) {
      return isKeyRequiredCondition(mapKey(key));
}

I have submitted PR #11819 to resolve this issue.

Using the latest version of GraalVM can resolve many issues.

GraalVM Version

openjdk version "26" 2026-03-17
OpenJDK Runtime Environment GraalVM CE 26-dev+8.1 (build 26+8-jvmci-b01)
OpenJDK 64-Bit Server VM GraalVM CE 26-dev+8.1 (build 26+8-jvmci-b01, mixed mode, sharing)

Operating System and Version

Windows 10 Pro

Build Command

(any usual build command, "Path" is set and contains cl.exe somewhere)

Expected Behavior

A compile happens:

========================================================================================================================
GraalVM Native Image: Generating 'test.listdir.listdir.exe' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------
[1/8] Initializing...                                                                                    (7.9s @ 0.10GB)
 Java version: 26+8, vendor version: GraalVM CE 26-dev+8.1
 Graal compiler: optimization level: 0, target machine: x86-64-v3
 C compiler: cl.exe (microsoft, x64, 19.40.33811)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature

Actual Behavior

A compile doesn't happen:

========================================================================================================================
GraalVM Native Image: Generating 'test.listdir.listdir.exe' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------

[1/8] Initializing...                                                                                    (0.0s @ 0.09GB)
Error: Default native-compiler executable 'cl.exe' not found via environment variable PATH
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Internal exception: com.oracle.svm.core.util.UserError$UserException: Default native-compiler executable 'cl.exe' not found via environment variable PATH
To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:138)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.addSkipCheckingInfo(CCompilerInvoker.java:109)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.<init>(CCompilerInvoker.java:77)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker$WindowsCCompilerInvoker.<init>(CCompilerInvoker.java:115)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.create(CCompilerInvoker.java:89)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:1089)

Steps to Reproduce

Attempt a native compile on Windows, with the PATH variable set to "Path" (apparently the Windows system itself can do this by default). native-image will claim cl.exe is not on the path.

Additional Context

No response

Build Log Output and Error Messages

========================================================================================================================
GraalVM Native Image: Generating 'test.listdir.listdir.exe' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------

[1/8] Initializing...                                                                                    (0.0s @ 0.09GB)
Error: Default native-compiler executable 'cl.exe' not found via environment variable PATH
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
Internal exception: com.oracle.svm.core.util.UserError$UserException: Default native-compiler executable 'cl.exe' not found via environment variable PATH
To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:138)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.addSkipCheckingInfo(CCompilerInvoker.java:109)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.<init>(CCompilerInvoker.java:77)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker$WindowsCCompilerInvoker.<init>(CCompilerInvoker.java:115)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.create(CCompilerInvoker.java:89)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:1089)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions