Compiling CPython with Clang 13

Hi folks, I’m trying to build CPython 3.9.6 with Clang 13 but there’s something wrong with PGO. Basically I ran these commands

$ CC=clang-13 ./configure --with-lto=full --enable-shared --enable-optimizations --prefix /usr/local/cpython-3.9
$ make

I trimmed the output to the last lines

Total duration: 1 min 11 sec
Tests result: SUCCESS
make[1]: Leaving directory '/home'
make build_all_merge_profile
make[1]: Entering directory '/home'
/usr/bin/llvm-profdata merge -output=code.profclangd *.profclangr
warning: code-21093.profclangr: malformed instrumentation profile data
warning: code-21112.profclangr: malformed instrumentation profile data
warning: code-21121.profclangr: malformed instrumentation profile data
warning: code-21129.profclangr: malformed instrumentation profile data
warning: code-21137.profclangr: malformed instrumentation profile data
warning: code-21147.profclangr: malformed instrumentation profile data
warning: code-21155.profclangr: malformed instrumentation profile data
warning: code-21108.profclangr: malformed instrumentation profile data
warning: code-21117.profclangr: malformed instrumentation profile data
warning: code-21125.profclangr: malformed instrumentation profile data
warning: code-21133.profclangr: malformed instrumentation profile data
warning: code-21142.profclangr: malformed instrumentation profile data
warning: code-21151.profclangr: malformed instrumentation profile data
warning: code-21106.profclangr: malformed instrumentation profile data
warning: code-21115.profclangr: malformed instrumentation profile data
warning: code-21123.profclangr: malformed instrumentation profile data
warning: code-21131.profclangr: malformed instrumentation profile data
warning: code-21139.profclangr: malformed instrumentation profile data
warning: code-21149.profclangr: malformed instrumentation profile data
warning: code-21157.profclangr: malformed instrumentation profile data
warning: code-21110.profclangr: malformed instrumentation profile data
warning: code-21119.profclangr: malformed instrumentation profile data
warning: code-21127.profclangr: malformed instrumentation profile data
warning: code-21135.profclangr: malformed instrumentation profile data
warning: code-21145.profclangr: malformed instrumentation profile data
warning: code-21153.profclangr: malformed instrumentation profile data
warning: code-21105.profclangr: malformed instrumentation profile data
warning: code-21113.profclangr: malformed instrumentation profile data
warning: code-21122.profclangr: malformed instrumentation profile data
warning: code-21130.profclangr: malformed instrumentation profile data
warning: code-21138.profclangr: malformed instrumentation profile data
warning: code-21148.profclangr: malformed instrumentation profile data
warning: code-21156.profclangr: malformed instrumentation profile data
warning: code-21109.profclangr: malformed instrumentation profile data
warning: code-21118.profclangr: malformed instrumentation profile data
warning: code-21126.profclangr: malformed instrumentation profile data
warning: code-21134.profclangr: malformed instrumentation profile data
warning: code-21143.profclangr: malformed instrumentation profile data
warning: code-21152.profclangr: malformed instrumentation profile data
warning: code-21107.profclangr: malformed instrumentation profile data
warning: code-21116.profclangr: malformed instrumentation profile data
warning: code-21124.profclangr: malformed instrumentation profile data
warning: code-21132.profclangr: malformed instrumentation profile data
warning: code-21140.profclangr: malformed instrumentation profile data
warning: code-21150.profclangr: malformed instrumentation profile data
warning: code-21158.profclangr: malformed instrumentation profile data
warning: code-21111.profclangr: malformed instrumentation profile data
warning: code-21120.profclangr: malformed instrumentation profile data
warning: code-21128.profclangr: malformed instrumentation profile data
warning: code-21136.profclangr: malformed instrumentation profile data
warning: code-21146.profclangr: malformed instrumentation profile data
warning: code-21154.profclangr: malformed instrumentation profile data
error: no profile can be merged
make[1]: *** [Makefile:541: build_all_merge_profile] Error 1
make[1]: Leaving directory '/home'
make: *** [Makefile:525: profile-run-stamp] Error 2

I don’t know what’s wrong. Does anyone have any idea on how to solve this? Thanks in advance!

Do you have multiple copies of clang installed? It’s possible that /usr/bin/llvm-profdata is from older version that does not support the PGO data from clang 13.

2 Likes

I don’t think so. I am downloading and installing Clang myself in the following Dockerfile

ARG release=focal
ARG distro=ubuntu

FROM $distro:$release

ARG release
ARG llvmver=13

ENV DEBIAN_FRONTEND=noninteractive 
ENV LLVM http://apt.llvm.org/$release/ llvm-toolchain-$release-$llvmver main

RUN apt-get update \
 && apt-get install -y \
  gnupg \
  apt-transport-https \
  ca-certificates \
  curl

RUN echo deb $LLVM\\ndeb-src $LLVM >> /etc/apt/sources.list.d/llvm.list
RUN curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -

RUN apt-get update \
 && apt-get install -y build-essential clang-$llvmver lld-$llvmver \
  libncurses-dev libgdbm-dev libz-dev tk-dev libsqlite3-dev libreadline-dev liblzma-dev libffi-dev libssl-dev

RUN ln -s llvm-ar-$llvmver llvm-ar
RUN ln -s llvm-profdata-$llvmver llvm-profdata

Basically I’m setting the symlinks to make this work. Could this be the problem?