Skip to content

Commit

Permalink
Use ; as classpath separator on Windows
Browse files Browse the repository at this point in the history
Speculative fix for this error seen in CI:
```
Exception in thread "main" java.nio.file.InvalidPathException: Illegal char <:> at index 77: bazel-out/x64_windows-fastbuild/bin/src/main/protobuf/libdeps_proto-speed.jar:bazel-out/x64_windows-fastbuild/bin/external/com_google_protobuf/java/core/libcore.jar:bazel-out/x64_windows-fastbuild/bin/external/com_google_protobuf/java/core/liblite_runtime_only.jar:bazel-out/x64_windows-fastbuild/bin/external/maven/com/google/guava/guava/31.1-jre/guava-31.1-jre.jar:bazel-out/x64_windows-fastbuild/bin/external/maven/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:bazel-out/x64_windows-fastbuild/bin/external/maven/com/google/errorprone/error_prone_annotations/2.20.0/processed_error_prone_annotations-2.20.0.jar:bazel-out/x64_windows-fastbuild/bin/external/maven/com/google/errorprone/error_prone_type_annotations/2.20.0/processed_error_prone_type_annotations-2.20.0.jar:bazel-out/x64_windows-fastbuild/bin/external/maven/com/github/stephenc/jcip/jcip-annotations/1.0-1/processed_jcip-annotations-1.0-1.jar:bazel-out/x64_windows-fastbuild/bin/external/maven/com/google/code/findbugs/jsr305/3.0.2/processed_jsr305-3.0.2.jar:third_party/turbine/turbine_direct.jar
	at java.base@20.0.2/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base@20.0.2/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base@20.0.2/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base@20.0.2/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base@20.0.2/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:232)
	at java.base@20.0.2/java.nio.file.Path.of(Path.java:148)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.expandAsteriskClassPathElement(NativeImage.java:1795)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.addCustomImageClasspath(NativeImage.java:1774)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.processClasspathArgs(DefaultOptionHandler.java:435)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.DefaultOptionHandler.consume(DefaultOptionHandler.java:72)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage$NativeImageArgsProcessor.apply(NativeImage.java:1703)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.processNativeImageArgs(NativeImage.java:2016)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.completeImageBuild(NativeImage.java:945)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.build(NativeImage.java:1592)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1557)
	at org.graalvm.nativeimage.driver/com.oracle.svm.driver.NativeImage.main(NativeImage.java:1531)
```
  • Loading branch information
fmeum authored and sgammon committed Aug 29, 2023
1 parent 43adbdc commit 2996427
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion internal/native_image/rules.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ _DEFAULT_GVM_REPO = "@graalvm"
_GVM_TOOLCHAIN_TYPE = "%s//graalvm/toolchain" % _RULES_REPO
_BAZEL_CPP_TOOLCHAIN_TYPE = "@bazel_tools//tools/cpp:toolchain_type"
_BAZEL_CURRENT_CPP_TOOLCHAIN = "@bazel_tools//tools/cpp:current_cc_toolchain"
_WINDOWS_CONSTRAINT = "@platforms//os:windows"

_PASSTHRU_ENV_VARS = [
"INCLUDE",
Expand Down Expand Up @@ -89,6 +90,9 @@ _NATIVE_IMAGE_ATTRS = {
"_cc_toolchain": attr.label(
default = Label(_BAZEL_CURRENT_CPP_TOOLCHAIN),
),
"_windows_constraint": attr.label(
default = Label(_WINDOWS_CONSTRAINT),
),
}

def _graal_binary_implementation(ctx):
Expand Down Expand Up @@ -199,7 +203,15 @@ def _graal_binary_implementation(ctx):

args = ctx.actions.args()
args.add("--no-fallback")
args.add("-cp", ":".join([f.path for f in classpath_depset.to_list()]))

# TODO: This check really should be on the exec platform, not the target platform, but that
# requires going through a separate rule. Since GraalVM doesn't support cross-compilation, the
# distinction doesn't matter for now.
if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]):
path_list_separator = ";"
else:
path_list_separator = ":"
args.add("-cp", path_list_separator.join([f.path for f in classpath_depset.to_list()]))

if gvm_toolchain != None and ctx.attr.pass_compiler_path:
args.add("--native-compiler-path=%s" % c_compiler_path)
Expand Down

0 comments on commit 2996427

Please sign in to comment.