123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- # Build recipe for llvm.
- #
- # Copyright (c) 2021-2022 Matias Fonzo, <selk@dragora.org>.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- # Exit immediately on any error
- set -e
- program=llvm
- version=13.0.1
- release=1
- # Define a category for the output of the package name
- pkgcategory=devel
- tarname=${program}-${version}.src.tar.xz
- tarname_clang=clang-${version}.src.tar.xz
- tarname_compilerrt=compiler-rt-${version}.src.tar.xz
- # Remote source(s)
- fetch="
- https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/$tarname
- https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/$tarname_clang
- https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/$tarname_compilerrt
- "
- homepage=https://llvm.org
- license="Apachev2 + LLVM exceptions"
- description="
- The LLVM compiler.
- The LLVM Project is a collection of modular and reusable compiler and
- toolchain technologies. Despite its name, LLVM has little to do with
- traditional virtual machines. The name \"LLVM\" itself is not an
- acronym; it is the full name of the project.
- For more information, visit: $homepage
- "
- # Source documentation
- docs="CREDITS.TXT LICENSE.TXT README.txt"
- docsdir="${docdir}/${program}-${version}"
- # Source directory used by this software
- srcdir=${program}-${version}.src
- build()
- {
- unpack "${tardir}/$tarname"
- cd "$srcdir"
- cd tools
- unpack "${tardir}/$tarname_clang"
- mv clang-${version}.src clang
- cd ../projects
- unpack "${tardir}/$tarname_compilerrt"
- mv compiler-rt-${version}.src compiler-rt
- cd ..
- unset -v tarname_clang tarname_compilerrt
- # Set sane permissions
- chmod -R u+w,go-w,a+rX-s .
- # Make sure to point to Python version 3 (Thanks to BLFS!)
- grep -rl '#!.*python' | xargs sed -i '1s/python$/python3/'
- # Set the SANITIZER flag to TRUE for Musl
- patch -p0 < "${worktree}/patches/llvm/compiler_rt_sanitizer.diff"
- rm -rf BUILD
- mkdir BUILD
- cd BUILD
- cmake CC=gcc CXX=g++ \
- -DCMAKE_C_FLAGS_RELEASE:STRING="$QICFLAGS" \
- -DCMAKE_CXX_FLAGS_RELEASE:STRING="$QICXXFLAGS" \
- -DCMAKE_EXE_LINKER_FLAGS:STRING="$QILDFLAGS -Wl,--no-keep-memory" \
- -DCMAKE_SHARED_LINKER_FLAGS:STRING="$QILDFLAGS -Wl,--no-keep-memory" \
- -DCMAKE_INSTALL_PREFIX=/usr \
- -DLLVM_LIBDIR_SUFFIX=${libSuffix} \
- -DLLVM_BINUTILS_INCDIR=/usr/include \
- -DCMAKE_INSTALL_MANDIR=$mandir \
- -DCMAKE_INSTALL_DOCDIR=$docsdir \
- -DCMAKE_BUILD_TYPE=Release \
- -DLLVM_BUILD_LLVM_DYLIB=ON \
- -DLLVM_LINK_LLVM_DYLIB=ON \
- -DLLVM_ENABLE_FFI=ON \
- -DLLVM_ENABLE_RTTI=ON \
- -DLLVM_ENABLE_ZLIB=ON \
- -DLLVM_INSTALL_UTILS=ON \
- -DLLVM_ENABLE_ASSERTIONS=OFF \
- -DLLVM_APPEND_VC_REV=OFF \
- -DLLVM_PARALLEL_COMPILE_JOBS=$jobs \
- -DLLVM_INCLUDE_BENCHMARKS=OFF \
- -G Ninja ..
- ninja -j${jobs}
- DESTDIR="$destdir" ninja -j${jobs} install
- # Strip ELF executables only excluding shared objects
- find "$destdir" -type f | xargs file | awk '/ELF/ && /executable/' | \
- cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
- # Strip static libraries in order to reduce the package size
- find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
- cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || true
- # Compress and link man pages (if needed)
- if test -d "${destdir}/$mandir"
- then
- (
- cd "${destdir}/$mandir"
- find . -type f -exec lzip -9 {} +
- find . -type l | while read -r file
- do
- ln -sf "$(readlink -- "$file").lz" "${file}.lz"
- rm -- "$file"
- done
- )
- fi
- cd ../
- # Copy documentation
- mkdir -p "${destdir}/$docsdir"
- cp -p $docs "${destdir}/$docsdir"
- }
|