Skip to content

Commit 4ad2604

Browse files
committed
[GR-60022] Map files in shared objects to relative paths for debugging on other systems.
PullRequest: graalpython/3604
2 parents 4f81ad5 + 2c113fb commit 4ad2604

File tree

7 files changed

+33
-19
lines changed

7 files changed

+33
-19
lines changed

graalpython/com.oracle.graal.python.cext/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
33
#
44
# All rights reserved.
55
#
@@ -43,7 +43,8 @@ endif()
4343

4444
if(WIN32)
4545
require_var(GRAALVM_LLVM_LIB_DIR)
46-
endif()
46+
endif()
47+
require_var(GRAALPY_PARENT_DIR)
4748
require_var(CAPI_INC_DIR)
4849
require_var(PYCONFIG_INCLUDE_DIR)
4950
require_var(TRUFFLE_H_INC)
@@ -69,6 +70,8 @@ set(CFLAGS_WARNINGS -Wall -Werror,-Wunknown-warning-option -Wno-unused-function
6970
-Wno-incompatible-pointer-types-discards-qualifiers -Wno-pointer-type-mismatch
7071
-Wno-braced-scalar-init -Wno-deprecated-declarations)
7172

73+
add_compile_options(-ffile-prefix-map=${GRAALPY_PARENT_DIR}=.)
74+
7275
# preprocessor defines for all platforms
7376
add_compile_definitions(
7477
NDEBUG

graalpython/com.oracle.graal.python.hpy.llvm/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
33
#
44
# All rights reserved.
55
#
@@ -45,6 +45,7 @@ set(TARGET_LIB "hpy-native")
4545
# don't install into the system but into the MX project's output dir
4646
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR})
4747

48+
require_var(GRAALPY_PARENT_DIR)
4849
require_var(GRAALVM_HPY_INCLUDE_DIR)
4950
require_var(GRAALVM_PYTHON_INCLUDE_DIR)
5051
require_var(PYCONFIG_INCLUDE_DIR)
@@ -116,14 +117,15 @@ if(WIN32)
116117
endif()
117118

118119
if(MSVC)
119-
target_compile_options(${TARGET_LIB} PRIVATE /Z7 /O2 /WX)
120+
target_compile_options(${TARGET_LIB} PRIVATE /O2 /WX)
120121
else()
121122
if(NOT WIN32)
122123
target_compile_options(${TARGET_LIB} PRIVATE
123124
-Werror
124125
)
125126
endif()
126127
target_compile_options(${TARGET_LIB} PRIVATE
128+
-ffile-prefix-map=${GRAALPY_PARENT_DIR}=.
127129
-Wno-int-to-pointer-cast
128130
-Wno-int-conversion
129131
-Wno-void-pointer-to-int-cast

graalpython/python-libbz2/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
33
#
44
# All rights reserved.
55
#
@@ -44,9 +44,9 @@ add_library(${TARGET_BZIP2SUPPORT} SHARED)
4444
target_compile_definitions(${TARGET_BZIP2SUPPORT} PRIVATE NDEBUG)
4545

4646
if(WIN32)
47-
target_compile_options(${TARGET_BZIP2SUPPORT} PRIVATE /Z7 /O2 /WX)
47+
target_compile_options(${TARGET_BZIP2SUPPORT} PRIVATE /O2 /WX)
4848
else()
49-
target_compile_options(${TARGET_BZIP2SUPPORT} PRIVATE -Wall -Werror -O3 -g)
49+
target_compile_options(${TARGET_BZIP2SUPPORT} PRIVATE -Wall -Werror -O3)
5050
endif()
5151

5252
# don't install into the system but into the MX project's output dir

graalpython/python-libbz2/libbz2.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
33
#
44
# All rights reserved.
55
#
@@ -57,9 +57,9 @@ set_target_properties(${TARGET_LIBBZ2} PROPERTIES POSITION_INDEPENDENT_CODE TRUE
5757
target_compile_definitions(${TARGET_LIBBZ2} PRIVATE _FILE_OFFSET_BITS=64)
5858

5959
if(WIN32)
60-
target_compile_options(${TARGET_LIBBZ2} PRIVATE /Z7 /O2 /Wall)
60+
target_compile_options(${TARGET_LIBBZ2} PRIVATE /O2 /Wall)
6161
else()
62-
target_compile_options(${TARGET_LIBBZ2} PRIVATE -Wall -Winline -O2 -g)
62+
target_compile_options(${TARGET_LIBBZ2} PRIVATE -Wall -Winline -O2)
6363
endif()
6464

6565
# don't install into the system but into the MX project's output dir

graalpython/python-liblzma/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2023, Oracle and/or its affiliates.
2+
# Copyright (c) 2023, 2024, Oracle and/or its affiliates.
33
#
44
# All rights reserved.
55
#
@@ -82,10 +82,10 @@ if(WIN32)
8282
target_compile_options(${TARGET_LZMA} PRIVATE /Z7 /O2)
8383
target_compile_options(${TARGET_LZMASUPPORT} PRIVATE /Z7 /O2 /W3 /WX)
8484
else()
85-
target_compile_options(${TARGET_LZMA} PRIVATE -fPIC -DPIC -g -O2)
85+
target_compile_options(${TARGET_LZMA} PRIVATE -fPIC -DPIC -O2)
8686
target_compile_definitions(${TARGET_LZMA} PRIVATE PIC)
8787

88-
target_compile_options(${TARGET_LZMASUPPORT} PRIVATE -g -O3 -Wall -Werror)
88+
target_compile_options(${TARGET_LZMASUPPORT} PRIVATE -O3 -Wall -Werror)
8989
endif()
9090

9191
# don't install into the system but into the MX project's output dir

mx.graalpython/mx_graalpython.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,10 @@ def _get_suite_dir(suitename):
16731673
return mx.suite(suitename).dir
16741674

16751675

1676+
def _get_suite_parent_dir(suitename):
1677+
return os.path.dirname(mx.suite(suitename).dir)
1678+
1679+
16761680
def _get_src_dir(projectname):
16771681
for suite in mx.suites():
16781682
for p in suite.projects:
@@ -1789,6 +1793,7 @@ def dev_tag(arg=None, **kwargs):
17891793

17901794

17911795
mx_subst.path_substitutions.register_with_arg('suite', _get_suite_dir)
1796+
mx_subst.path_substitutions.register_with_arg('suite_parent', _get_suite_parent_dir)
17921797
mx_subst.path_substitutions.register_with_arg('src_dir', _get_src_dir)
17931798
mx_subst.path_substitutions.register_with_arg('output_root', _get_output_root)
17941799
mx_subst.path_substitutions.register_with_arg('py_ver', py_version_short)

mx.graalpython/suite.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@
701701
"TRUFFLE_H_INC": "<path:SULONG_LEGACY>/include",
702702
"TRUFFLE_NFI_H_INC": "<path:com.oracle.truffle.nfi.native>/include",
703703
"CMAKE_C_COMPILER": "<toolchainGetToolPath:native,CC>",
704+
"GRAALPY_PARENT_DIR": "<suite_parent:graalpython>",
704705
"GRAALPY_EXT": "<graalpy_ext:native>",
705706
},
706707
"results": [
@@ -721,6 +722,7 @@
721722
"TRUFFLE_H_INC": "<path:SULONG_LEGACY>/include",
722723
"TRUFFLE_NFI_H_INC": "<path:com.oracle.truffle.nfi.native>/include",
723724
"CMAKE_C_COMPILER": "<toolchainGetToolPath:native,CC>",
725+
"GRAALPY_PARENT_DIR": "<suite_parent:graalpython>",
724726
"GRAALPY_EXT": "<graalpy_ext:native>",
725727
},
726728
"results": [
@@ -777,6 +779,7 @@
777779
"GRAALVM_PYTHON_INCLUDE_DIR": "<path:com.oracle.graal.python.cext>/include",
778780
"TRUFFLE_H_INC": "<path:SULONG_LEGACY>/include",
779781
"CMAKE_C_COMPILER": "<toolchainGetToolPath:native,CC>",
782+
"GRAALPY_PARENT_DIR": "<suite_parent:graalpython>",
780783
},
781784
},
782785
},
@@ -788,6 +791,7 @@
788791
"GRAALVM_PYTHON_INCLUDE_DIR": "<path:com.oracle.graal.python.cext>/include",
789792
"TRUFFLE_H_INC": "<path:SULONG_LEGACY>/include",
790793
"CMAKE_C_COMPILER": "<toolchainGetToolPath:native,CC>",
794+
"GRAALPY_PARENT_DIR": "<suite_parent:graalpython>",
791795
},
792796
},
793797
},
@@ -811,8 +815,8 @@
811815
"<others>": {
812816
"cflags": [
813817
"-DHPY_ABI_HYBRID", "-DHPY_EMBEDDED_MODULES", "-DNDEBUG", "-DMS_WINDOWS",
814-
# cflags equivalent to -g -O3 -Wall (/W3, could be /Wall) -Werror (/WX)
815-
"-D_CRT_SECURE_NO_WARNINGS", "/Z7", "/O2", "/W3", "/WX",
818+
# cflags equivalent to -O3 -Wall (/W3, could be /Wall) -Werror (/WX)
819+
"-D_CRT_SECURE_NO_WARNINGS", "/O2", "/W3", "/WX",
816820
"-I\"<path:com.oracle.graal.python.cext>/include\"",
817821
"-I\"<path:com.oracle.graal.python.cext>/include/internal\"",
818822
"-I\"<path:com.oracle.graal.python.cext>/src\"",
@@ -847,13 +851,13 @@
847851
"deliverable": "zsupport",
848852
"buildDependencies": [],
849853
"cflags": [
850-
"-DNDEBUG", "-g", "-O3", "-Werror",
854+
"-DNDEBUG", "-O3", "-Werror",
851855
],
852856
"ldlibs": ["-lz"],
853857
"os_arch": {
854858
"windows": {
855859
"<others>": {
856-
# "/Z7", "/O2", "/WX", # cflags to replace -g -O3 -Werror
860+
# "/O2", "/WX", # cflags to replace -O3 -Werror
857861
"defaultBuild": False,
858862
},
859863
},
@@ -871,12 +875,12 @@
871875
"deliverable": "posix",
872876
"buildDependencies": [],
873877
"cflags": [
874-
"-DNDEBUG", "-g", "-O3", "-Wall", "-Werror",
878+
"-DNDEBUG", "-O3", "-Wall", "-Werror",
875879
],
876880
"os_arch": {
877881
"windows": {
878882
"<others>": {
879-
# "/Z7", "/O2", "/WX", # cflags to replace -g -O3 -Werror
883+
# "/O2", "/WX", # cflags to replace -O3 -Werror
880884
"defaultBuild": False,
881885
},
882886
},

0 commit comments

Comments
 (0)