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

Weird PGO build issue on macOS 14.3 #117752

Closed
corona10 opened this issue Apr 11, 2024 · 5 comments
Closed

Weird PGO build issue on macOS 14.3 #117752

corona10 opened this issue Apr 11, 2024 · 5 comments
Labels
build The build process and cross-build OS-mac

Comments

@corona10
Copy link
Member

corona10 commented Apr 11, 2024

  • Xcode: 15.3 (22618)
  • Instruments: 15.3 (64565.111)

With ./configure --enable-optimizations, the PGO build itself is a success on my machine, but the status is weird.

Following build warnings are emitted at the first build

clang: warning: argument unused during compilation: '-fno-semantic-interposition' [-Wunused-command-line-argument]
...

During the profiling stage, several tests are not passed as before.

# Next, run the profile task to generate the profile information.
LLVM_PROFILE_FILE="code-%p.profclangr"  ./python.exe -m test --pgo --timeout=
Using random seed: 3569111910
Raised RLIMIT_NOFILE: 256 -> 1024
0:00:00 load avg: 4.25 Run 44 tests sequentially
0:00:00 load avg: 4.25 [ 1/44] test_array
0:00:00 load avg: 4.25 [ 2/44] test_base64
0:00:00 load avg: 4.25 [ 3/44] test_binascii -- test_base64 failed (env changed)
0:00:00 load avg: 4.25 [ 4/44] test_binop
0:00:00 load avg: 4.25 [ 5/44] test_bisect
0:00:00 load avg: 4.25 [ 6/44] test_bytes
0:00:02 load avg: 4.25 [ 7/44] test_bz2 -- test_bytes failed (env changed)
0:00:02 load avg: 4.25 [ 8/44] test_cmath
0:00:02 load avg: 4.25 [ 9/44] test_codecs
0:00:03 load avg: 4.25 [10/44] test_collections
0:00:03 load avg: 4.25 [11/44] test_complex
0:00:03 load avg: 4.25 [12/44] test_dataclasses
0:00:04 load avg: 4.25 [13/44] test_datetime
0:00:06 load avg: 4.63 [14/44] test_decimal
------------------------------------ NOTICE ------------------------------------
test_decimal may generate "malloc can't allocate region"
warnings on macOS systems. This behavior is known. Do not
report a bug unless tests are also failing.
See https://github.com/python/cpython/issues/85100
--------------------------------------------------------------------------------
0:00:08 load avg: 4.63 [15/44] test_difflib
0:00:09 load avg: 4.63 [16/44] test_embed
0:00:12 load avg: 4.50 [17/44] test_float -- test_embed failed (env changed)
0:00:12 load avg: 4.50 [18/44] test_fstring
0:00:13 load avg: 4.50 [19/44] test_functools
0:00:14 load avg: 4.50 [20/44] test_generators
0:00:14 load avg: 4.50 [21/44] test_hashlib
0:00:14 load avg: 4.62 [22/44] test_heapq
0:00:15 load avg: 4.62 [23/44] test_int
0:00:15 load avg: 4.62 [24/44] test_itertools
0:00:16 load avg: 4.62 [25/44] test_json -- test_itertools failed (env changed)
0:00:18 load avg: 4.62 [26/44] test_long -- test_json failed (env changed)
0:00:19 load avg: 4.41 [27/44] test_lzma
0:00:20 load avg: 4.41 [28/44] test_math
0:00:21 load avg: 4.41 [29/44] test_memoryview
0:00:21 load avg: 4.41 [30/44] test_operator
0:00:21 load avg: 4.41 [31/44] test_ordered_dict
0:00:21 load avg: 4.41 [32/44] test_patma
0:00:22 load avg: 4.41 [33/44] test_pickle
0:00:24 load avg: 4.41 [34/44] test_pprint
0:00:24 load avg: 4.41 [35/44] test_re
0:00:24 load avg: 4.38 [36/44] test_set -- test_re failed (env changed)
0:00:26 load avg: 4.38 [37/44] test_sqlite3
0:00:26 load avg: 4.38 [38/44] test_statistics -- test_sqlite3 failed (env changed)
0:00:29 load avg: 4.11 [39/44] test_str
0:00:30 load avg: 4.11 [40/44] test_struct -- test_str failed (env changed)
0:00:30 load avg: 4.11 [41/44] test_tabnanny -- test_struct failed (env changed)
0:00:30 load avg: 4.11 [42/44] test_time -- test_tabnanny failed (env changed)
0:00:32 load avg: 4.11 [43/44] test_xml_etree
0:00:33 load avg: 4.11 [44/44] test_xml_etree_c

Total duration: 33.8 sec
Total tests: run=9,203 skipped=182
Total test files: run=44/44 env_changed=10
Result: SUCCESS

Also, writing profile files is in a weird status.

/usr/bin/xcrun llvm-profdata merge -output=code.profclangd *.profclangr
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory
LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory

cc @ned-deily @ronaldoussoren @erlend-aasland

Linked PRs

Retargeted PRs:

@erlend-aasland erlend-aasland added the build The build process and cross-build label Apr 11, 2024
@erlend-aasland erlend-aasland changed the title Weired PGO build on macOS 14.3 Weird PGO build issue on macOS 14.3 Apr 11, 2024
@erlend-aasland
Copy link
Contributor

erlend-aasland commented Apr 11, 2024

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Apr 11, 2024

@erlend-aasland
Copy link
Contributor

Following build warnings are emitted at the first build [...]

clang: warning: argument unused during compilation: '-fno-semantic-interposition' [-Wunused-command-line-argument]

This clang warning is also mentioned in issue #110577. Some of our $CC checks in configure.ac are inaccurate1. However, IIUC c6d7e82 should have take care of that.

For example, applying this patch (as hinted to in #110577) gets rid of the warning:

diff --git a/configure.ac b/configure.ac
index e195e15b39..325b5b973b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1796,10 +1796,12 @@ if test "$Py_OPT" = 'true' ; then
   DEF_MAKE_RULE="build_all"
   case $CC in
     *gcc*)
-      AX_CHECK_COMPILE_FLAG([-fno-semantic-interposition],[
-      CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
-      LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
-      ])
+      if test -n "${cc_is_clang}"; then
+        AX_CHECK_COMPILE_FLAG([-fno-semantic-interposition],[
+        CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
+        LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
+        ])
+      fi
       ;;
   esac
 elif test "$ac_sys_system" = "Emscripten" -o "$ac_sys_system" = "WASI"; then

Footnotes

  1. which is also mentioned in some of the other related issues I linked to].

erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Apr 11, 2024
Force the compiler to issue an error if the flag is not supported.
@erlend-aasland
Copy link
Contributor

Regarding this:

LLVM Profile Error: Failed to write file "code-75991.profclangr": No such file or directory

Try this patch:

diff --git a/configure.ac b/configure.ac
index 60c4141a3d..2570fc5f32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2013,7 +2013,7 @@ case "$CC_BASENAME" in
     PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
     PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
     LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
-    LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
+    LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
     if test $LLVM_PROF_FOUND = not-found
     then
       LLVM_PROF_ERR=yes
@@ -2029,7 +2029,7 @@ case "$CC_BASENAME" in
         PGO_PROF_GEN_FLAG="-fprofile-instr-generate"
         PGO_PROF_USE_FLAG="-fprofile-instr-use=code.profclangd"
         LLVM_PROF_MERGER="${LLVM_PROFDATA} merge -output=code.profclangd *.profclangr"
-        LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"code-%p.profclangr\""
+        LLVM_PROF_FILE="LLVM_PROFILE_FILE=\"\$(shell pwd)/code-%p.profclangr\""
         if test "${LLVM_PROF_FOUND}" = "not-found"
         then
           LLVM_PROF_ERR=yes

This should also get rid of the "env changed" warnings, as profile data will now not interfere with the test environment.

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Apr 11, 2024

Moreover, we should consider compiling with -Wno-profile-instr-unprofiled (and perhaps also -Wno-profile-instr-out-of-date) when PGO is enabled. There is no need to warn about the files that lack profile data.

erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Apr 12, 2024
…irectory

This prevents spurious 'env changed' and llvm-profdata merge errors.
erlend-aasland added a commit that referenced this issue Apr 12, 2024
…ry (#117790)

This prevents spurious 'env changed' and llvm-profdata merge errors.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 12, 2024
…irectory (pythonGH-117790)

This prevents spurious 'env changed' and llvm-profdata merge errors.
(cherry picked from commit 396b831)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Apr 12, 2024
* -Wno-profile-instr-unprofiled for source files without profile data

* -Wno-profile-instr-out-of-date for _bootstrap_python.c
erlend-aasland added a commit that referenced this issue Apr 12, 2024
…directory (GH-117790) (#117795)

This prevents spurious 'env changed' and llvm-profdata merge errors.

(cherry picked from commit 396b831)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
erlend-aasland added a commit that referenced this issue Apr 12, 2024
Force the compiler to issue an error if the flag is not supported.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 12, 2024
…honGH-117789)

Force the compiler to issue an error if the flag is not supported.
(cherry picked from commit 49fc141)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
erlend-aasland added a commit that referenced this issue Apr 12, 2024
…-117789) (#117800)

Force the compiler to issue an error if the flag is not supported.
(cherry picked from commit 49fc141)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Apr 12, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 12, 2024
…tions (pythonGH-117803)

(cherry picked from commit 1ddbeae)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
erlend-aasland added a commit that referenced this issue Apr 12, 2024
…ations (GH-117803) (#117805)

(cherry picked from commit 1ddbeae)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…irectory (python#117790)

This prevents spurious 'env changed' and llvm-profdata merge errors.
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…hon#117789)

Force the compiler to issue an error if the flag is not supported.
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build OS-mac
Projects
None yet
Development

No branches or pull requests

2 participants