-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
bpo-30345: Add -g to LDFLAGS to ease debug #7709
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
Conversation
When using PGO+LTO and compile without LDFLAGS=-g, gdb fails to get function arguments: add -g to LDFLAGS to ease debug.
cc @Traceur759 |
Hum, who can review this change? :-) @pitrou @ned-deily @serhiy-storchaka @methane @doko42 modified configure.ac recently. Also @encukou maybe? |
configure
Outdated
@@ -6716,6 +6716,9 @@ then | |||
else | |||
OPT="-g $WRAP -O3 -Wall" | |||
fi | |||
# bpo-30345: When using PGO+LTO and compile without LDFLAGS=-g, | |||
# gdb fails to get function arguments. | |||
LDFLAGS="$LDFLAGS -g" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be added only in debug mode? I afraid that adding -g
in release mode can disable some optimizations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already always pass -g to CFLAGS, even in release mode.
Extract of gcc manual page:
-g Produce debugging information in the operating system's native
format (stabs, COFF, XCOFF, or DWARF). GDB can work with this
debugging information.
On most systems that use stabs format, -g enables use of extra
debugging information that only GDB can use; this extra information
makes debugging work better in GDB but probably makes other
debuggers crash or refuse to read the program. If you want to
control for certain whether to generate the extra information, use
-gstabs+, -gstabs, -gxcoff+, -gxcoff, or -gvms (see below).
It's unrelated to optimizations. It's just an option to ask to include also debug symbols in the produced binary file (like ELF file on Linux).
If you want to get ride of them, just run "strip python". Linux vendors are able to distribute these debug symbols in a different package, like python-debuginfo on Fedora.
I'm not 100% sure, that's why I'm asking for a review :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, now I got this.
I think it's ok to add |
AFAIK,
LINKCC is CC for most case, but not always. |
I think it means whether CC supports |
"AFAIK, -g is required only when LTO because code generation is happen in link time. So I think it's safer that adding -g here in configure.ac." Done. |
"(also, what exactly is $ac_cv_prog_cc_g?) I think it means whether CC supports -g or not." Hum, why, I cannot add -g for all platforms? |
Only add -g if it's supported by the C compiler.
I don't know linker without -g support. |
I modified my PR to respect $ac_cv_prog_cc_g. |
I'm sorry, I meant why ac_cv_prog_cc_g is used in general. LTO is used only with clang and gcc. So no need to worry about others when adding |
I'm OK to merge this with or without $ac_cv_prog_cc_g check. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, @vstinner, I could not cleanly backport this to |
Add -g to LDFLAGS when compiling with LTO to get debug symbols. (cherry picked from commit 06fe77a) Co-authored-by: Victor Stinner <[email protected]>
GH-7824 is a backport of this pull request to the 3.7 branch. |
GH-7826 is a backport of this pull request to the 3.6 branch. |
Add -g to LDFLAGS when compiling with LTO to get debug symbols. (cherry picked from commit 06fe77a) Co-authored-by: Victor Stinner <[email protected]>
When using PGO+LTO and compile without LDFLAGS=-g, gdb fails to get
function arguments: add -g to LDFLAGS to ease debug.
https://bugs.python.org/issue30345