Skip to content

Commit e807e07

Browse files
committed
Fix build with secure control plane
Since GraalVM version 24 is used, the `lkql` build breaks when the _Secure Control Plane_ is enabled on `rocky8`. The error message on failure is: ``` _[engine] WARNING: The Truffle API JAR is missing the 'truffleattach' resource, likely due to issues when Truffle was repackaged into a fat JAR. _As a result, the optimized Truffle runtime is unavailable, and Truffle cannot provide native access to languages and tools. _To customize the behavior of this warning, use the 'polyglotimpl.AttachLibraryFailureAction' system property. ``` The root cause of the issue is described by the graalvm issue [8222](oracle/graal#8222), where the `polyglot` package tries to create a `.cache` directory in the `user.home` directory. When using the _Secure Control Plane_, only the buildspace of the spec is a writable directory. Setting the `polyglot.engine.userResourceCache` variable to a writable path fixed the problem, and it is now possible to build with _Secure Control Plane_ enabled. Closes eng/libadalang/langkit-query-language#549+
1 parent 8441ffa commit e807e07

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lkql_jit/standalone/make_native.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""----------------------------------------------------------------------------
22
-- L K Q L J I T --
33
-- --
4-
-- Copyright (C) 2023, AdaCore --
4+
-- Copyright (C) 2023-2025, AdaCore --
55
-- --
66
-- This library is free software; you can redistribute it and/or modify it --
77
-- under terms of the GNU General Public License as published by the Free --
@@ -45,6 +45,8 @@
4545
import subprocess
4646
import sys
4747

48+
from pathlib import Path
49+
4850
sys.path.append("..")
4951
# noinspection PyUnresolvedReferences
5052
from utils import GraalManager, parse_args, is_windows
@@ -122,13 +124,23 @@ def look_for_files_in_env(files: list[str], env_var_name: str) -> dict[str, str]
122124

123125
# Run the Native-Image compiler if required by the build process
124126
if "lkql_cli" in args.native_components:
127+
# Get the buildspace tmp dir to set the polyglot cache path. When
128+
# built in docker images (where only the buildspace is writable), the
129+
# build crashes because it tries to create $HOME/.cache. This behavior
130+
# may be overridden by the polyglot.engine.userResourceCache value.
131+
# There is nothing in args (build_mode, classpath native_components) to
132+
# give a clue about buildspace location, guess it from this file's path.
133+
buildspace: Path = Path(__file__).parents[3]
134+
tmp_path: Path = Path(buildspace, "tmp")
135+
125136
# Create the base Native-Image command
126137
cmd = [
127138
graal.native_image,
128139
"-cp",
129140
args.classpath,
130141
"--no-fallback",
131142
"--initialize-at-build-time",
143+
f"-Dpolyglot.engine.userResourceCache={tmp_path.as_posix()}",
132144
*os_specific_options,
133145
]
134146

0 commit comments

Comments
 (0)