Page MenuHomePhabricator

[Bug 39548][Clang] PGO bootstrap fails with python3: errors in perf-helper.py
ClosedPublic

Authored by Romain-Geissler-1A on Nov 3 2018, 6:24 AM.

Details

Summary

Hi,

Current clang fail to bootstrap in PGO mode when only python3 is available, because perf-helper.py is not compatible with python 3. We can see two errors:

  File "/workdir/src/llvm-7.0.0.src/tools/clang/utils/perf-training/perf-helper.py", line 299
    by_count.sort(key = lambda (_,n): -n)
                               ^
SyntaxError: invalid syntax

which can be fixed by removing the parameter parenthesis.

And

$ "/usr/bin/python3.6" "/workdir/src/llvm-7.0.0.src/tools/clang/utils/perf-training/perf-helper.py" "cc1" "/workdir/build/final-system/llvm-build/tools/clang/stage2-instrumented-bins/bin/clang" "-Wall" "-pedantic" "-c" "/home/jenkins/workspace/OTF_Toolchain_release_2.0-HLXHYRKCVDYQJLF23VGZ3MVAU6VGURX537LUE3KFVM2SSPMZ6IOA/output/src/llvm-7.0.0.src/tools/clang/utils/perf-training/cxx/hello_world.cpp"
# command stderr:
Traceback (most recent call last):
  File "/workdir/src/llvm-7.0.0.src/tools/clang/utils/perf-training/perf-helper.py", line 408, in <module>
    main()
  File "/workdir/src/llvm-7.0.0.src/tools/clang/utils/perf-training/perf-helper.py", line 405, in main
    sys.exit(f(sys.argv[2:]))
  File "/workdir/src/llvm-7.0.0.src/tools/clang/utils/perf-training/perf-helper.py", line 159, in cc1
    cc1_cmd = get_cc1_command_for_args(cmd, cc1_env)
  File "/workdir/src/llvm-7.0.0.src/tools/clang/utils/perf-training/perf-helper.py", line 119, in get_cc1_command_for_args
    for ln in cc_output.split('\n'):
TypeError: a bytes-like object is required, not 'str'

error: command failed with exit status: 1

which can be made both 2 and 3 compatible by using the attribute universal_newlines=True

Cheers,
Romain

Diff Detail

Repository
rC Clang

Event Timeline

Romain-Geissler-1A edited the summary of this revision. (Show Details)Nov 3 2018, 6:25 AM

Hi @serge-sans-paille @michaelplatings,

I saw you recently merged some Python 3 related stuff. Here is an older review from November still never reviewed. You fixed already the fix around the lambda, yet I still need to add "universal_newlines" on current trunk otherwise I have some bytes vs str objects error. Do you think you can land this small change too ?

Cheers,
Romain

@Romain-Geissler-1A sure thing. Can you rebase your patch on master first?

Rebased to master

This revision is now accepted and ready to land.Fri, Jan 11, 5:13 AM

Thank you !

Since I have no write access to the repository, can anyone of you commit this patch ?

Cheers,
Romain

This revision was automatically updated to reflect the committed changes.