Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-101525: Skip test_gdb if the binary is BOLTed. #118572

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

corona10
Copy link
Member

@corona10 corona10 commented May 4, 2024

@corona10
Copy link
Member Author

corona10 commented May 4, 2024

Now the all tests are fully passed with BOLTed binary.

binary_path = sys.executable
with open(binary_path, 'rb') as f:
binary = f.read()
if b'.note.bolt_info' in binary:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you call readelf -e <binary_path> and grep .note.bolt_info? Checking headers is efficient and robust.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think it will be the best way to handle this issue. But I am not sure it will be okay to call external binary for this. I may need to get opinions from @vstinner and @erlend-aasland WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not checking sysconfig? This check looks slow and not reliable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not checking sysconfig? This check looks slow and not reliable.

Do you have any recommendation points? CFLAG does not guarantee the build is BOLTed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe test:

'--enable-bolt' in sysconfig.get_config_var('CONFIG_ARGS')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only put the code in test_gdb if you're worried that the the test is not reliable. And add a comment to explain it.

Copy link
Member Author

@corona10 corona10 May 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then there is no way to display the optimization information but okay got it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot expect "readelf" to be available, it would be a new dependency. I dislike looking for a string in a binary without parsing the ELF binary.

We call external binaries in test.support to determine macOS features, so there is precedent for doing that sort of thing; is readelf a standalone package, or is it part of the compiler toolchain?

Copy link
Member Author

@corona10 corona10 May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; is readelf a standalone package, or is it part of the compiler toolchain?

AFAIK, it's part of binutils: https://sourceware.org/binutils/docs/binutils/readelf.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, it's part of binutils: https://sourceware.org/binutils/docs/binutils/readelf.html

Thanks. binutils is preinstalled on the Ubuntu runners GitHub provides, so there is no more dependencies for the CI there. Also, anyone who wants to build their own CPython probably already did apt install build-essential, which includes binutils. Looks to me like there are no more deps introduced. What about macOS?

@@ -336,6 +336,7 @@ def get_build_info():
if support.check_cflags_pgo():
# PGO (--enable-optimizations)
optimizations.append('PGO')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you added a function in test.support, can you add a "BOLT" case here?

@corona10 corona10 requested a review from vstinner May 6, 2024 13:33
@corona10 corona10 changed the title gh-101525: Skip test_gdb if the binary is BOLTed. [WIP] gh-101525: Skip test_gdb if the binary is BOLTed. May 6, 2024
@corona10 corona10 changed the title [WIP] gh-101525: Skip test_gdb if the binary is BOLTed. gh-101525: Skip test_gdb if the binary is BOLTed. May 6, 2024
@aaupov
Copy link

aaupov commented May 6, 2024

By the way, since -update-debug-sections is used (https://github.com/python/cpython/blob/main/configure.ac#L2185), do you really need to skip gdb tests?

@corona10
Copy link
Member Author

corona10 commented May 6, 2024

By the way, since -update-debug-sections is used (https://github.com/python/cpython/blob/main/configure.ac#L2185), do you really need to skip gdb tests?

Well, when I run a test_gdb with BOLTed binary, sometimes it fails, well let me try with other systems too.

Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner
Copy link
Member

vstinner commented May 7, 2024

I suggest to backport the change to 3.12, and maybe also to 3.11.

@@ -856,6 +856,14 @@ def check_cflags_pgo():
return any(option in cflags_nodist for option in pgo_options)


def check_bolt_optimized():
# Always return false, if the platform is WASI.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment only says what the code does, but not why. Could you rewrite it to state why this is happening? I can easily see by the code that we always return false if we're on WASI; there is no need to manifest that info into a comment ;)

@corona10
Copy link
Member Author

corona10 commented May 8, 2024

I suggest to backport the change to 3.12, and maybe also to 3.11.

@vstinner @erlend-aasland
BOLT is the experimental feature from 3.12 :)
Anyway, I will finalize this PR during the PyCon US. This week, I am too busy with all my tasks at my full-time job before the conference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants