Skip to content

Commit

Permalink
Merge pull request #81 from sgammon/release/0.10.x-windows
Browse files Browse the repository at this point in the history
fix: fix modern build on Windows by adding `cmd.exe` to `PATH`
  • Loading branch information
fmeum authored Sep 1, 2023
2 parents 743979a + dac6792 commit 2f3609f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/native_image/classic.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _graal_binary_classic_implementation(ctx):
native_toolchain = _resolve_cc_toolchain(
ctx,
transitive_inputs,
is_windows = ctx.configuration.host_path_separator == ";",
)

args = ctx.actions.args()
Expand Down
3 changes: 3 additions & 0 deletions internal/native_image/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def _graal_binary_implementation(ctx):
native_toolchain = _resolve_cc_toolchain(
ctx,
transitive_inputs,
is_windows = ctx.target_platform_has_constraint(
ctx.attr._windows_constraint[platform_common.ConstraintValueInfo],
),
)

args = ctx.actions.args()
Expand Down
11 changes: 8 additions & 3 deletions internal/native_image/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ load(
"C_COMPILE_ACTION_NAME",
)

def resolve_cc_toolchain(ctx, transitive_inputs):
def resolve_cc_toolchain(ctx, transitive_inputs, *, is_windows):
"""Build a context struct for accessing the native C toolchain.
Available struct properties:
Expand All @@ -31,6 +31,7 @@ def resolve_cc_toolchain(ctx, transitive_inputs):
Args:
ctx: Context from the rule implementation.
transitive_inputs: List of transitive inputs (mutated).
is_windows: Whether the target (and hence execution) platform is Windows.
Returns:
Resulting struct; see method documentation for parameters."""
Expand Down Expand Up @@ -101,8 +102,12 @@ def resolve_cc_toolchain(ctx, transitive_inputs):
path_set[tool_dir] = None

paths = sorted(path_set.keys())
if ctx.configuration.host_path_separator == ":":
# HACK: ":" is a proxy for a UNIX-like host.
if is_windows:
# Graal verifies the Visual Studio setup by looking for cl.exe in PATH,
# which in turn relies on cmd.exe being in PATH.
# https://github.com/oracle/graal/blob/46de6045d403bb373f65d5e3303f9d3d09f838df/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/WindowsBuildEnvironmentUtil.java#L130-L135
paths.append("C:\\Windows\\System32")
else:
# The tools returned above may be bash scripts that reference commands
# in directories we might not otherwise include. For example,
# on macOS, wrapped_ar calls dirname.
Expand Down

0 comments on commit 2f3609f

Please sign in to comment.