From 8755316d185be2d8625474f61c63efd7987f6f92 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 4 May 2024 22:56:44 +0900 Subject: [PATCH 01/10] gh-101525: Skip test_gdb if the binary is BOLTed. --- Lib/test/libregrtest/utils.py | 4 ++++ Lib/test/support/__init__.py | 11 +++++++++++ Lib/test/test_gdb/__init__.py | 3 +++ .../2024-05-04-22-56-41.gh-issue-101525.LHK166.rst | 1 + 4 files changed, 19 insertions(+) create mode 100644 Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index 2a3449016fe951..8ff2134837f6db 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -343,6 +343,10 @@ def get_build_info(): if support.check_cflags_pgo(): # PGO (--enable-optimizations) optimizations.append('PGO') + + if support.check_bolt_optimized(): + optimizations.append('BOLT') + if optimizations: build.append('+'.join(optimizations)) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 3149fd732f64a7..6f9e4441d5735f 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -866,6 +866,17 @@ def check_cflags_pgo(): return any(option in cflags_nodist for option in pgo_options) +def check_bolt_optimized(): + # BOLTed binary can be checked based on ELF information. + # link: https://github.com/llvm/llvm-project/issues/60253 + binary_path = sys.executable + with open(binary_path, 'rb') as f: + binary = f.read() + if b'.note.bolt_info' in binary: + return True + return False + + Py_GIL_DISABLED = bool(sysconfig.get_config_var('Py_GIL_DISABLED')) def requires_gil_enabled(msg="needs the GIL enabled"): diff --git a/Lib/test/test_gdb/__init__.py b/Lib/test/test_gdb/__init__.py index 99557739af6748..0dd721780233e6 100644 --- a/Lib/test/test_gdb/__init__.py +++ b/Lib/test/test_gdb/__init__.py @@ -24,6 +24,9 @@ if support.check_cflags_pgo(): raise unittest.SkipTest("test_gdb is not reliable on PGO builds") +if support.check_bolt_optimized(): + raise unittest.SkipTest("test_gdb is not reliable on BOLT optimized builds") + def load_tests(*args): return support.load_package_tests(os.path.dirname(__file__), *args) diff --git a/Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst b/Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst new file mode 100644 index 00000000000000..3b5f46c4620006 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst @@ -0,0 +1 @@ +Skip test_gdb if the binary is BOLTed. Patch by Donghee Na. From 973abd69cb43ad7135a78db3d10192ca978e9cfd Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 4 May 2024 23:03:10 +0900 Subject: [PATCH 02/10] Address code review --- Lib/test/support/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 6f9e4441d5735f..f8e2b8bd5abc4d 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -867,6 +867,9 @@ def check_cflags_pgo(): def check_bolt_optimized(): + # Always return false is the platform is WASI. + if is_wasi: + return False # BOLTed binary can be checked based on ELF information. # link: https://github.com/llvm/llvm-project/issues/60253 binary_path = sys.executable From 83d879cea6a0bdb7bb8b8a13ca017c85afaf8607 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sat, 4 May 2024 23:03:54 +0900 Subject: [PATCH 03/10] nit --- Lib/test/support/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index f8e2b8bd5abc4d..7eddbcbbb74e86 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -867,7 +867,7 @@ def check_cflags_pgo(): def check_bolt_optimized(): - # Always return false is the platform is WASI. + # Always return false, if the platform is WASI. if is_wasi: return False # BOLTed binary can be checked based on ELF information. From af9c391b3f0cada870cf268bb340b75c476c6120 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 6 May 2024 14:45:01 +0900 Subject: [PATCH 04/10] Address code review --- Lib/test/libregrtest/utils.py | 3 --- Lib/test/support/__init__.py | 10 ++-------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index 8ff2134837f6db..133011c3a01afa 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -344,9 +344,6 @@ def get_build_info(): # PGO (--enable-optimizations) optimizations.append('PGO') - if support.check_bolt_optimized(): - optimizations.append('BOLT') - if optimizations: build.append('+'.join(optimizations)) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 7eddbcbbb74e86..0864be2166f711 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -870,14 +870,7 @@ def check_bolt_optimized(): # Always return false, if the platform is WASI. if is_wasi: return False - # BOLTed binary can be checked based on ELF information. - # link: https://github.com/llvm/llvm-project/issues/60253 - binary_path = sys.executable - with open(binary_path, 'rb') as f: - binary = f.read() - if b'.note.bolt_info' in binary: - return True - return False + return '--enable-bolt' in sysconfig.get_config_var('CONFIG_ARGS') Py_GIL_DISABLED = bool(sysconfig.get_config_var('Py_GIL_DISABLED')) @@ -892,6 +885,7 @@ def expected_failure_if_gil_disabled(): return unittest.expectedFailure return lambda test_case: test_case + if Py_GIL_DISABLED: _header = 'PHBBInP' else: From e9ec9b9c2fa3a9ab55d2935e5b2ab1c645249fa4 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 6 May 2024 22:32:27 +0900 Subject: [PATCH 05/10] Address code review --- Lib/test/libregrtest/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index 133011c3a01afa..495691054ab913 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -344,6 +344,10 @@ def get_build_info(): # PGO (--enable-optimizations) optimizations.append('PGO') + if support.check_bolt_optimized(): + # BOLT (--enable-bolt) + optimizations.append('BOLT') + if optimizations: build.append('+'.join(optimizations)) From 2d6d05a9612021ebfa9a6ab7a64332b422ba0a0a Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 6 May 2024 22:42:14 +0900 Subject: [PATCH 06/10] fix --- Lib/test/support/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 0864be2166f711..f2ca5b62b842d7 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -870,7 +870,8 @@ def check_bolt_optimized(): # Always return false, if the platform is WASI. if is_wasi: return False - return '--enable-bolt' in sysconfig.get_config_var('CONFIG_ARGS') + config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' + return '--enable-bolt' in configs_args Py_GIL_DISABLED = bool(sysconfig.get_config_var('Py_GIL_DISABLED')) From b8547069efaa019e965a3652f7738d8d4c8f450b Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 6 May 2024 22:43:18 +0900 Subject: [PATCH 07/10] nit --- Lib/test/support/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index f2ca5b62b842d7..16d65af13ead60 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -886,7 +886,6 @@ def expected_failure_if_gil_disabled(): return unittest.expectedFailure return lambda test_case: test_case - if Py_GIL_DISABLED: _header = 'PHBBInP' else: From c0bd894d82c72e04542d6143b7f9f6fbbdce9db2 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 6 May 2024 23:17:35 +0900 Subject: [PATCH 08/10] fix --- Lib/test/support/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 16d65af13ead60..00d45daf732469 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -871,7 +871,7 @@ def check_bolt_optimized(): if is_wasi: return False config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' - return '--enable-bolt' in configs_args + return '--enable-bolt' in config_args Py_GIL_DISABLED = bool(sysconfig.get_config_var('Py_GIL_DISABLED')) From ea13917b7230ce550494fbd9093acca40f3a908a Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Sun, 1 Sep 2024 01:55:00 +0900 Subject: [PATCH 09/10] Address code review --- Lib/test/support/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 00d45daf732469..dbf479dddff7b3 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -867,7 +867,8 @@ def check_cflags_pgo(): def check_bolt_optimized(): - # Always return false, if the platform is WASI. + # Always return false, if the platform is WASI, + # because BOLT optimization does not support WASM binary. if is_wasi: return False config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' From 0e9d019855dcffa4a94e6328f0fc9fc59ef01dfe Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Mon, 2 Sep 2024 21:59:40 +0900 Subject: [PATCH 10/10] Address code review --- .../next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst b/Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst index 3b5f46c4620006..ae8001ad373119 100644 --- a/Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst +++ b/Misc/NEWS.d/next/Tests/2024-05-04-22-56-41.gh-issue-101525.LHK166.rst @@ -1 +1,2 @@ -Skip test_gdb if the binary is BOLTed. Patch by Donghee Na. +Skip ``test_gdb`` if the binary is relocated by BOLT. +Patch by Donghee Na.