|
1 | 1 | """---------------------------------------------------------------------------- |
2 | 2 | -- L K Q L J I T -- |
3 | 3 | -- -- |
4 | | --- Copyright (C) 2023, AdaCore -- |
| 4 | +-- Copyright (C) 2023-2025, AdaCore -- |
5 | 5 | -- -- |
6 | 6 | -- This library is free software; you can redistribute it and/or modify it -- |
7 | 7 | -- under terms of the GNU General Public License as published by the Free -- |
|
45 | 45 | import subprocess |
46 | 46 | import sys |
47 | 47 |
|
| 48 | +from pathlib import Path |
| 49 | + |
48 | 50 | sys.path.append("..") |
49 | 51 | # noinspection PyUnresolvedReferences |
50 | 52 | 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] |
122 | 124 |
|
123 | 125 | # Run the Native-Image compiler if required by the build process |
124 | 126 | 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 | + |
125 | 136 | # Create the base Native-Image command |
126 | 137 | cmd = [ |
127 | 138 | graal.native_image, |
128 | 139 | "-cp", |
129 | 140 | args.classpath, |
130 | 141 | "--no-fallback", |
131 | 142 | "--initialize-at-build-time", |
| 143 | + f"-Dpolyglot.engine.userResourceCache={tmp_path.as_posix()}", |
132 | 144 | *os_specific_options, |
133 | 145 | ] |
134 | 146 |
|
|
0 commit comments