#!/bin/bash #=========================== # UMVIRT LINUX FROM SCRATCH #=========================== # Compilation script. # Network mode. #=========================== # Release: 0.2 # Package: llvm #=========================== # DB commit: eeb5b556770c9a541df710c0fd927901d6de9d66 # APP commit: #=========================== echo "ULFS Package installation start" echo "===============================" echo "Package: llvm" echo "Release: 0.2" echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi #Creating log directory mkdir -p /var/log/ulfs-packages/llvm/ #Saving start timestamp date +%s > /var/log/ulfs-packages/llvm/start.time #Going to source directory... cd /sources #Checking dependances... #Checking cmake... if [ ! -f /var/cache/ulfs-packages/cmake ]; then echo "Dependance \"cmake\" not found. Trying to install..."; wget --no-check-certificate https://ulfs.org/linux/packages//0.2/cmake/install -O - | bash if [ ! -f /var/cache/ulfs-packages/cmake ]; then echo "Dependance \"cmake\" is not installed. Exiting..." exit fi fi #Saving downloading timestamp date +%s > /var/log/ulfs-packages/llvm/download.time #Downloading source package archive... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/l/llvm-16.0.5.src.tar.xz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/l/llvm-16.0.5.src.tar.xz #Checking source package file existance if [ ! -f llvm-16.0.5.src.tar.xz ]; then echo "Error: Can't find llvm-16.0.5.src.tar.xz. Exiting!" exit fi #Checking source package file checksum if [ -f llvm-16.0.5.src.tar.xz.md5sum ]; then MD5=`LANG=C md5sum -c llvm-16.0.5.src.tar.xz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of llvm-16.0.5.src.tar.xz is wrong. Exiting!" exit fi fi #Downloadning add-ons... #Downloadning add-on "llvm-cmake.src.tar.xz"... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/l/llvm-cmake.src.tar.xz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/l/llvm-cmake.src.tar.xz #Checking addon file existance if [ ! -f llvm-cmake.src.tar.xz ]; then echo "Error: Can't find llvm-cmake.src.tar.xz. Exiting!" exit fi #Checking add-on file checksum if [ -f llvm-cmake.src.tar.xz.md5sum ]; then MD5=`LANG=C md5sum -c llvm-cmake.src.tar.xz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of llvm-cmake.src.tar.xz is wrong. Exiting!" exit fi fi #Downloadning add-on "llvm-third-party.src.tar.xz"... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/l/llvm-third-party.src.tar.xz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/l/llvm-third-party.src.tar.xz #Checking addon file existance if [ ! -f llvm-third-party.src.tar.xz ]; then echo "Error: Can't find llvm-third-party.src.tar.xz. Exiting!" exit fi #Checking add-on file checksum if [ -f llvm-third-party.src.tar.xz.md5sum ]; then MD5=`LANG=C md5sum -c llvm-third-party.src.tar.xz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of llvm-third-party.src.tar.xz is wrong. Exiting!" exit fi fi #Downloadning add-on "clang-16.0.5.src.tar.xz"... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/c/clang-16.0.5.src.tar.xz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/c/clang-16.0.5.src.tar.xz #Checking addon file existance if [ ! -f clang-16.0.5.src.tar.xz ]; then echo "Error: Can't find clang-16.0.5.src.tar.xz. Exiting!" exit fi #Checking add-on file checksum if [ -f clang-16.0.5.src.tar.xz.md5sum ]; then MD5=`LANG=C md5sum -c clang-16.0.5.src.tar.xz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of clang-16.0.5.src.tar.xz is wrong. Exiting!" exit fi fi #Downloadning add-on "clang-16.0.5-enable_default_ssp-1.patch"... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/c/clang-16.0.5-enable_default_ssp-1.patch.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/c/clang-16.0.5-enable_default_ssp-1.patch #Checking addon file existance if [ ! -f clang-16.0.5-enable_default_ssp-1.patch ]; then echo "Error: Can't find clang-16.0.5-enable_default_ssp-1.patch. Exiting!" exit fi #Checking add-on file checksum if [ -f clang-16.0.5-enable_default_ssp-1.patch.md5sum ]; then MD5=`LANG=C md5sum -c clang-16.0.5-enable_default_ssp-1.patch.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of clang-16.0.5-enable_default_ssp-1.patch is wrong. Exiting!" exit fi fi #Downloadning add-on "compiler-rt-16.0.5.src.tar.xz"... wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/c/compiler-rt-16.0.5.src.tar.xz.md5sum wget --no-check-certificate -nc https://ulfs.org/linux/downloads/package_files/0.2/packages/c/compiler-rt-16.0.5.src.tar.xz #Checking addon file existance if [ ! -f compiler-rt-16.0.5.src.tar.xz ]; then echo "Error: Can't find compiler-rt-16.0.5.src.tar.xz. Exiting!" exit fi #Checking add-on file checksum if [ -f compiler-rt-16.0.5.src.tar.xz.md5sum ]; then MD5=`LANG=C md5sum -c compiler-rt-16.0.5.src.tar.xz.md5sum | grep OK` if [ "$MD5" == "" ] ; then echo "Error: Checksum of compiler-rt-16.0.5.src.tar.xz is wrong. Exiting!" exit fi fi #Saving cleanup timestamp date +%s > /var/log/ulfs-packages/llvm/cleanup.time rm -rfv /sources/llvm-16.0.5.src/ #Saving extracting timestamp date +%s > /var/log/ulfs-packages/llvm/unpack.time #Extracting tar source package archive with default parameters... tar -xf llvm-16.0.5.src.tar.xz #Checking package directory size after unpack... du -s llvm-16.0.5.src | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/llvm/unpack.size #Going to source package directory... cd llvm-16.0.5.src #Saving configuration timestamp date +%s > /var/log/ulfs-packages/llvm/configure.time #Sleep 1 second sleep 1 if [[ "$ULFS_PKG_DATERESET" == "YES" ]] then #Changing all files creation time (except build configuration files) in source directory to find them after installation find /sources/llvm-16.0.5.src \! -path "*/configure*" \! -path "*/Makefile*" \! -path "*.make" \! -path "*.m4" \! -path "*.am" \! -path "*.mk" \! -path "*.stamp" \! -path "*gentpl.py" -exec touch -m {} + fi #Running configuration script... echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi cat > ulfs_configure.sh << EOIS echo "Initializing distributed build environment... " if [[ "\$ULFS_ICECC" == "YES" ]] then export PATH="\$ULFS_ICECC_PATH:\$PATH" echo "ICECC" fi echo "Environment debug..." echo "PATH: \$PATH" echo "MAKEFLAGS: \$MAKEFLAGS" echo "NINJAJOBS: \$NINJAJOBS" env | grep ULFS tar -xf ../llvm-cmake.src.tar.xz && tar -xf ../llvm-third-party.src.tar.xz && sed '/LLVM_COMMON_CMAKE_UTILS/s@../cmake@llvm-cmake.src@' \\ -i CMakeLists.txt && sed '/LLVM_THIRD_PARTY_DIR/s@../third-party@llvm-third-party.src@' \\ -i cmake/modules/HandleLLVMOptions.cmake tar -xf ../clang-16.0.5.src.tar.xz -C tools && mv tools/clang-16.0.5.src tools/clang tar -xf ../compiler-rt-16.0.5.src.tar.xz -C projects && mv projects/compiler-rt-16.0.5.src projects/compiler-rt grep -rl '#!.*python' | xargs sed -i '1s/python\$/python3/' patch -Np2 -d tools/clang <../clang-16.0.5-enable_default_ssp-1.patch sed 's/clang_dfsan/& -fno-stack-protector/' -i projects/compiler-rt/test/dfsan/origin_unaligned_memtrans.c mkdir -v build && cd build && ARG_DOCS="" if [[ "\$ULFS_PKG_DOCUMENTATION" == "YES" ]] then ARG_DOCS="-DLLVM_BUILD_DOCS=ON -DLLVM_ENABLE_SPHINX=ON -DSPHINX_WARNINGS_AS_ERRORS=OFF" fi CC=gcc CXX=g++ \\ cmake -DCMAKE_INSTALL_PREFIX=/usr \\ -DLLVM_ENABLE_FFI=ON \\ -DCMAKE_BUILD_TYPE=Release \\ -DLLVM_BUILD_LLVM_DYLIB=ON \\ -DLLVM_LINK_LLVM_DYLIB=ON \\ -DLLVM_ENABLE_RTTI=ON \\ -DLLVM_TARGETS_TO_BUILD="host;AMDGPU;BPF" \\ -DLLVM_BINUTILS_INCDIR=/usr/include \\ -DLLVM_INCLUDE_BENCHMARKS=OFF \\ -DCLANG_DEFAULT_PIE_ON_LINUX=ON \\ -Wno-dev \$ARG_DOCS -G Ninja .. EOIS cat ulfs_configure.sh | bash 2>&1 | tee /var/log/ulfs-packages/llvm/configure.log #Saving build timestamp date +%s > /var/log/ulfs-packages/llvm/build.time #Running build script... echo "checking config file" if [ -f $ULFS_CONFIG_FILE ] then echo "loading config file $ULFS_CONFIG_FILE..." . $ULFS_CONFIG_FILE fi cat > ulfs_build.sh << EOIS echo "Initializing distributed build environment... " if [[ "\$ULFS_ICECC" == "YES" ]] then export PATH="\$ULFS_ICECC_PATH:\$PATH" echo "ICECC" fi echo "Environment debug..." echo "PATH: \$PATH" echo "MAKEFLAGS: \$MAKEFLAGS" echo "NINJAJOBS: \$NINJAJOBS" env | grep ULFS cd build ninja if [[ "\$ULFS_PKG_DOCUMENTATION" == "YES" ]] then ninja docs-llvm-html docs-llvm-man ninja docs-clang-html docs-clang-man fi if [[ "\$ULFS_PKG_TEST" == "YES" ]] then systemctl --user start dbus && systemd-run --user --pty -d -G -p LimitCORE=0 ninja check-all fi EOIS cat ulfs_build.sh | bash 2>&1 | tee /var/log/ulfs-packages/llvm/build.log #Saving install timestamp date +%s > /var/log/ulfs-packages/llvm/install.time #Running install script... cat > ulfs_install.sh << EOIS cd build cmake --install . cp bin/FileCheck /usr/bin if [[ "\$ULFS_PKG_DOCUMENTATION" == "YES" ]] then install -v -d -m755 /usr/share/doc/llvm-16.0.5 && mv -v /usr/share/doc/LLVM/llvm /usr/share/doc/llvm-16.0.5 && rmdir -v --ignore-fail-on-non-empty /usr/share/doc/LLVM install -v -d -m755 /usr/share/doc/llvm-16.0.5 && mv -v /usr/share/doc/LLVM/clang /usr/share/doc/llvm-16.0.5 && rmdir -v --ignore-fail-on-non-empty /usr/share/doc/LLVM fi EOIS USER=`whoami` if [ "$USER" == "root" ] ; then cat ulfs_install.sh | bash 2>&1 | tee /var/log/ulfs-packages/llvm/install.log else cat ulfs_install.sh | sudo bash 2>&1 | tee /var/log/ulfs-packages/llvm/install.log fi #Saving finish timestamp date +%s > /var/log/ulfs-packages/llvm/finish.time #Checking package directory size after unpack... cd /sources du -s llvm-16.0.5.src | awk 'NR==1 {print $1}' > /var/log/ulfs-packages/llvm/install.size echo "ULFS package installation completed." #Producing files list echo "Looking for installed files..." if [ -f /var/log/ulfs-packages/llvm/files.txt ]; then rm /var/log/ulfs-packages/llvm/files.txt fi USER=`whoami` if [ "$USER" == "root" ] ; then find /bin -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt find /sbin -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt find /usr -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt find /etc -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt find /opt -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt find /lib -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt find /lib64 -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt find /var -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time \! -path "/var/log/ulfs-packages/llvm/*" >> /var/log/ulfs-packages/llvm/files.txt else sudo find /bin -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt sudo find /sbin -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt sudo find /usr -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt sudo find /etc -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt sudo find /opt -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt sudo find /lib -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt sudo find /lib64 -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time >> /var/log/ulfs-packages/llvm/files.txt sudo find /var -type f -newer /var/log/ulfs-packages/llvm/configure.time \! -newer /var/log/ulfs-packages/llvm/finish.time \! -path "/var/log/ulfs-packages/llvm/*" >> /var/log/ulfs-packages/llvm/files.txt fi #Marking package as installed... mkdir -p /var/cache/ulfs-packages USER=`whoami` if [ "$USER" == "root" ] ; then touch /var/cache/ulfs-packages/llvm else sudo touch /var/cache/ulfs-packages/llvm fi #Calculate delta size a=`cat /var/log/ulfs-packages/llvm/unpack.size` b=`cat /var/log/ulfs-packages/llvm/install.size` c=$(($b-$a)) echo $c > /var/log/ulfs-packages/llvm/delta.size #Calculate prepare time a=`cat /var/log/ulfs-packages/llvm/start.time` b=`cat /var/log/ulfs-packages/llvm/configure.time` dp=$(($b-$a)) #Calculate download time a=`cat /var/log/ulfs-packages/llvm/download.time` b=`cat /var/log/ulfs-packages/llvm/unpack.time` dd=$(($b-$a)) #Calculate delta time a=`cat /var/log/ulfs-packages/llvm/configure.time` b=`cat /var/log/ulfs-packages/llvm/finish.time` db=$(($b-$a)) echo $db > /var/log/ulfs-packages/llvm/delta.time #Report echo "" echo "ULFS Package installation report" echo "================================" echo "Package: llvm" echo "Release: 0.2" echo "Build size: $c" echo "Prepare time: $dp sec." echo "Download time: $dd sec." echo "Build time: $db sec." #End of script