Skip to content

Commit b86eaf9

Browse files
committed
build a partial graalvm to get an svm image
1 parent b28b3c6 commit b86eaf9

File tree

1 file changed

+8
-33
lines changed

1 file changed

+8
-33
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ def _get_stdlib_home():
5454
return os.path.join(SUITE.dir, "graalpython", "lib-python", "3")
5555

5656

57-
def _get_svm_binary():
58-
return os.path.join(SUITE.dir, "graalpython-svm")
59-
60-
61-
def __get_svm_binary_from_graalvm():
62-
vmdir = os.path.join(mx.suite("truffle").dir, "..", "vm")
63-
return os.path.join(vmdir, "mxbuild", "-".join([mx.get_os(), mx.get_arch()]), "graalpython.image", "graalpython")
64-
65-
6657
def _extract_graalpython_internal_options(args):
6758
non_internal = []
6859
additional_dists = []
@@ -224,19 +215,15 @@ def find_eclipse():
224215
return
225216

226217

227-
def python_build_svm(args):
228-
mx.run_mx(
229-
["--dynamicimports", "/substratevm,/vm", "build",
230-
"--force-deprecation-as-warning", "--dependencies",
231-
"GRAAL_MANAGEMENT,graalpython.image"],
232-
nonZeroIsFatal=True
233-
)
234-
shutil.copy(__get_svm_binary_from_graalvm(), _get_svm_binary())
218+
_SVM_ARGS = ["--dynamicimports", "/vm,/tools,/substratevm",
219+
"--disable-polyglot", "--disable-libpolyglot"]
235220

236221

237222
def python_svm(args):
238-
python_build_svm(args)
239-
svm_image = __get_svm_binary_from_graalvm()
223+
mx.run_mx(_SVM_ARGS + ["build"])
224+
out = mx.OutputCapture()
225+
mx.run_mx(_SVM_ARGS + ["graalvm-home"], out=mx.TeeOutputCapture(out))
226+
svm_image = os.path.join(out.data.strip(), "bin", "graalpython")
240227
mx.run([svm_image] + args)
241228
return svm_image
242229

@@ -328,14 +315,8 @@ def graalpython_gate_runner(args, tasks):
328315

329316
with Task('GraalPython Python tests on SVM', tasks, tags=[GraalPythonTags.svmunit]) as task:
330317
if task:
331-
svm_image_name = "./graalpython-svm"
332-
if not os.path.exists(svm_image_name):
333-
svm_image_name = python_svm(["-h"])
334-
llvm_home = mx_subst.path_substitutions.substitute('--native.Dllvm.home=<path:SULONG_LIBS>')
335-
args = ["--python.CoreHome=%s" % os.path.join(SUITE.dir, "graalpython", "lib-graalpython"),
336-
"--python.StdLibHome=%s" % os.path.join(SUITE.dir, "graalpython", "lib-python/3"),
337-
llvm_home]
338-
run_python_unittests(svm_image_name, args)
318+
svm_image_name = python_svm(["-h"])
319+
run_python_unittests(svm_image_name)
339320

340321
with Task('GraalPython license header update', tasks, tags=[GraalPythonTags.license]) as task:
341322
if task:
@@ -360,11 +341,6 @@ def graalpython_gate_runner(args, tasks):
360341
])
361342
if success not in out.data:
362343
mx.abort('Output from generated SVM image "' + svm_image + '" did not match success pattern:\n' + success)
363-
llvm_home = mx_subst.path_substitutions.substitute('--native.Dllvm.home=<path:SULONG_LIBS>')
364-
args = ["--python.CoreHome=%s" % os.path.join(SUITE.dir, "graalpython", "lib-graalpython"),
365-
"--python.StdLibHome=%s" % os.path.join(SUITE.dir, "graalpython", "lib-python/3"),
366-
llvm_home]
367-
run_python_unittests(svm_image, args)
368344

369345

370346
mx_gate.add_gate_runner(SUITE, graalpython_gate_runner)
@@ -881,7 +857,6 @@ def mx_post_parse_cmd_line(namespace):
881857
'python-update-import': [update_import_cmd, 'import name'],
882858
'delete-graalpython-if-testdownstream': [delete_self_if_testdownstream, ''],
883859
'python-checkcopyrights': [python_checkcopyrights, 'Make sure code files have copyright notices'],
884-
'python-build-svm': [python_build_svm, 'build svm image if it is outdated'],
885860
'python-svm': [python_svm, 'run python svm image (building it if it is outdated'],
886861
'punittest': [punittest, ''],
887862
'python3-unittests': [python3_unittests, 'run the cPython stdlib unittests'],

0 commit comments

Comments
 (0)