Skip to content

Commit f8de01a

Browse files
eregontimfel
authored andcommitted
[GR-53462] Always copy libpythonvm.so.debug for graalpy-standalone for native standalones
PullRequest: graalpython/3926
2 parents 528ab1d + 10932b4 commit f8de01a

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

graalpython/com.oracle.graal.python.pegparser.generator/CMakeLists.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.0)
1+
cmake_minimum_required(VERSION 3.10)
22
project(pegparser)
33

44
set(PEGPARSER_SRC_PATH "${CMAKE_CURRENT_LIST_DIR}/../com.oracle.graal.python.pegparser/src")
@@ -14,7 +14,6 @@ else()
1414
set(PYTHON_EXE "python3")
1515
endif()
1616

17-
set(PARSER_OUTPUT "Parser.java")
1817
set(PARSER_TARGET "${PARSER_PATH}/Parser.java")
1918

2019
set(GRAMMAR "${INPUT_PATH}/python.gram")
@@ -33,17 +32,17 @@ file(GLOB_RECURSE ASDL_FILES
3332

3433
set(ASDL_STAMP "Python.asdl.stamp")
3534

36-
add_custom_target(grammar ALL
37-
DEPENDS "${PARSER_OUTPUT}")
3835
add_custom_command(
39-
OUTPUT "${PARSER_OUTPUT}"
36+
OUTPUT "${PARSER_TARGET}"
4037
COMMAND ${PYTHON_EXE} "${CMAKE_CURRENT_LIST_DIR}/main_parser_gen.py" "${GRAMMAR}" "${TOKENS}" "${PARSER_TARGET}"
41-
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/main_parser_gen.py" "${GRAMMAR}" "${TOKENS}" "${PARSER_TARGET}" ${PEGEN_FILES} ${PEGJAVA_FILES})
38+
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/main_parser_gen.py" "${GRAMMAR}" "${TOKENS}" ${PEGEN_FILES} ${PEGJAVA_FILES})
4239

43-
add_custom_target(asdl ALL
44-
DEPENDS "${ASDL_STAMP}")
4540
add_custom_command(
4641
OUTPUT "${ASDL_STAMP}"
47-
COMMAND ${PYTHON_EXE} "${CMAKE_CURRENT_LIST_DIR}/main_asdl_gen.py" "${ASDL}" --sst-path "${PEGPARSER_SRC_PATH}" --ast-path "${GRAALPY_SRC_PATH}"
48-
COMMAND ${CMAKE_COMMAND} -E touch "${ASDL_STAMP}"
42+
COMMAND ${PYTHON_EXE} "${CMAKE_CURRENT_LIST_DIR}/main_asdl_gen.py" "${ASDL}" --sst-path "${PEGPARSER_SRC_PATH}" --ast-path "${GRAALPY_SRC_PATH}" --stamp "${ASDL_STAMP}"
4943
DEPENDS "${CMAKE_CURRENT_LIST_DIR}/main_asdl_gen.py" "${ASDL}" ${ASDL_FILES})
44+
45+
add_custom_target(
46+
Parser
47+
ALL
48+
DEPENDS "${PARSER_TARGET}" "${ASDL_STAMP}")

graalpython/com.oracle.graal.python.pegparser.generator/main_asdl_gen.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python3
2-
# Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# The Universal Permissive License (UPL), Version 1.0
@@ -43,14 +43,32 @@
4343
from asdl.asdl_java import generate
4444

4545

46+
def stamp(sst_path: pathlib.Path, ast_path: pathlib.Path):
47+
if sst_path.is_dir() and ast_path.is_dir():
48+
return [
49+
p.read_bytes() for p in sorted(sst_path.rglob("*")) if p.is_file()
50+
] + [
51+
p.read_bytes() for p in sorted(ast_path.rglob("*")) if p.is_file()
52+
]
53+
else:
54+
return []
55+
56+
4657
def main():
4758
parser = argparse.ArgumentParser()
4859
parser.add_argument("input_file", type=pathlib.Path)
4960
parser.add_argument("-S", "--sst-path", type=pathlib.Path, required=True)
5061
parser.add_argument("-A", "--ast-path", type=pathlib.Path, required=True)
62+
parser.add_argument("--stamp", type=pathlib.Path, required=True)
5163

5264
args = parser.parse_args()
65+
66+
old_contents = stamp(args.sst_path, args.ast_path)
5367
generate(args.input_file, args.sst_path, args.ast_path)
68+
if old_contents != stamp(args.sst_path, args.ast_path):
69+
args.stamp.touch()
70+
else:
71+
print(f"{args.sst_path} and {args.ast_path} not modified")
5472

5573

5674
if __name__ == '__main__':

mx.graalpython/mx_graalpython.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,9 @@ def _graalpy_launcher():
610610
return f"{name}.exe" if WIN32 else name
611611

612612

613-
# dev means Default TruffleRuntime and "build the minimum possible"
613+
# dev only has effect if standalone_type is 'jvm' and means minimal, Default TruffleRuntime (no JIT)
614614
def graalpy_standalone_home(standalone_type, enterprise=False, dev=False, build=True):
615615
assert standalone_type in ['native', 'jvm']
616-
assert not (enterprise and dev), "EE dev standalones are not implemented yet"
617616
jdk_version = mx.get_jdk().version
618617

619618
# Check if GRAALPY_HOME points to some compatible pre-built GraalPy standalone
@@ -677,7 +676,7 @@ def graalpy_standalone_home(standalone_type, enterprise=False, dev=False, build=
677676

678677
python_home = os.path.join(SUITE.dir, 'mxbuild', f"{mx.get_os()}-{mx.get_arch()}", standalone_dist)
679678

680-
if dev and standalone_type == 'native':
679+
if standalone_type == 'native':
681680
debuginfo = os.path.join(SUITE.dir, 'mxbuild', f"{mx.get_os()}-{mx.get_arch()}", "libpythonvm", "libpythonvm.so.debug")
682681
if os.path.exists(debuginfo):
683682
shutil.copy(debuginfo, os.path.join(python_home, 'lib'))
@@ -868,7 +867,7 @@ def python_svm(_=None):
868867
Also builds the standalone if not built already."""
869868
if mx_gate.get_jacoco_agent_args():
870869
return python_jvm()
871-
launcher = graalpy_standalone('native', dev=True)
870+
launcher = graalpy_standalone('native')
872871
mx.log(launcher)
873872
return launcher
874873

@@ -2497,9 +2496,6 @@ def graalpy_standalone_wrapper(args_in):
24972496
parser.add_argument('--no-build', action='store_true',
24982497
help="Doesn't build the standalone, only prints the patch to its launcher")
24992498
args = parser.parse_args(args_in)
2500-
if args.edition == 'ee':
2501-
if not mx.suite('graalpython-enterprise', fatalIfMissing=False):
2502-
mx.abort("You must add --dynamicimports graalpython-enterprise for EE edition")
25032499
print(graalpy_standalone(args.type, enterprise=args.edition == 'ee', build=not args.no_build))
25042500

25052501
def graalpy_jmh(args):

0 commit comments

Comments
 (0)