-
-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
"make profile-opt" overrides CFLAGS_NODIST #79680
Comments
Makefile.pre.in contains the rule: build_all_generate_profile: I'm not sure that CFLAGS_NODIST="$(CFLAGS) $(PGO_PROF_GEN_FLAG)" is correct: it overrides user The code comes from bpo-23390: commit 2f90aa6
(...)
+ CFLAGS_NODIST has been added by bpo-21121: commit acb8c52
This issue is related to bpo-35257: "Avoid leaking linker flags into distutils: add PY_LDFLAGS_NODIST". |
I wrote PR 11164 to fix the issue. Example: $ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS_NODIST="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-generate -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
(...) => CFLAGS_NODIST is missing: I don't see -O1 in the command line. With my change: $ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS_NODIST="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -O1 -fprofile-generate -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
(...) => CFLAGS_NODIST is used: I see "-O1" in the command line. |
I also tested CFLAGS, just in case. Current behavior: $ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall -O1 -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-generate -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
(...) => CFLAGS is respected: I see -O1 in the command line. With PR 11164: $ git clean -fdx
$ ./configure --with-pydebug
$ make profile-opt CFLAGS="-O1"
(...)
gcc -pthread -c -Wno-unused-result -Wsign-compare -g -Og -Wall -O1 -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-generate -I./Include/internal -I. -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
(...) => CFLAGS is respected: I see -O1 in the command line. |
Oh wait, "make build_all_generate_profile" and "make profile-opt" have another issue. They modify LDFLAGS, whereas PGO flags seem to be very specific to the compiler, not to the linker. I reopen the issue. build_all_generate_profile: profile-opt: profile-run-stamp LDFLAGS="$(LDFLAGS) $(PGO_PROF_GEN_FLAG)" of "make build_all_generate_profile" looks harmless: passing PGO flags to the linker works since gcc is used as the linker. Except that LDFLAGS is exported and used by distutils, and passing PGO flags to build third party code is not ok: see bpo-35257. For "make profile-opt", LDFLAGS="$(LDFLAGS)" looks useless. PGO flags depend on the compiler:
I don't think that any of these flags should be passed to the LDFLAGS. Passing these flags to CFLAGS should be enough. |
But the If those are left off of the link step, you won't have an instrumented binary and won't generate profile data. |
Oh, I didn't try my PR... $ ./configure --enable-optimizations
$ make
...
/usr/bin/ld: libpython3.8m.a(myreadline.o):(.data+0xa0): undefined reference to `__gcov_merge_add'
... My PR simply doesn't work: we have to pass PGO flags to the linker. At least for the first step generating a profile. My bad, sorry, I close my PR 11219. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: