Skip to content

Instantly share code, notes, and snippets.

@stvoidit
Created May 6, 2024 15:59
Show Gist options
  • Save stvoidit/6bbded06adcd07ddd26ed53776354688 to your computer and use it in GitHub Desktop.
Save stvoidit/6bbded06adcd07ddd26ed53776354688 to your computer and use it in GitHub Desktop.
python 3 compilation with clang-18 and full optimization on ubuntu22.04
#!/usr/bin/bash
PYVERSION=$1
clang_flags="PATH=/usr/lib/llvm-18/bin/:$PATH CC=clang-18 CXX=clang++-18 LLVM=-18 LD=ld.lld-18"
cd /tmp/
wget -O - "https://www.python.org/ftp/python/$PYVERSION/Python-$PYVERSION.tar.xz" | tar xJ
cd "Python-$PYVERSION"
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get install -y build-essential gdb lcov pkg-config \
libbz2-dev libffi-dev libgdbm-dev libgdbm-compat-dev liblzma-dev \
libncurses5-dev libncursesw5-dev libreadline6-dev libreadline-dev libsqlite3-dev libssl-dev \
lzma lzma-dev xz-utils tk-dev uuid-dev zlib1g-dev libnss3-dev
./configure $clang_flags LDFLAGS='-fuse-ld=lld' --enable-optimizations --with-lto=thin --with-computed-gotos
make -j$(nproc) $clang_flags
sudo make install
sudo python3 -m pip install --upgrade pip setuptools wheel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment