Files
chromebrew/packages/llvm16_build.rb
Satadru Pramanik, DO, MPH, MEng 79efa1dfd5 Python => 3.13.0 (#10585)
* Python => 3.13

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fix VER variables in const.rb

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* bugfixes

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* More plumbing changes...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust py3_pip and py3_setuptools to not error during python3 preinstall.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fix hash error

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add no_binaries_needed

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* bugfixes...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 to pip.rb to fix python 3.13 builds.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add workaround for missing binaries...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update cmake

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add lots of package updates.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add py3_bcrypt, rename asciidoc, add more package builds.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* More updates

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* revert postgresql update

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* final updates?

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update curl

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* lint

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add curl to essential packages to try to prevent unit test failure on i686.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* updates

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* lint

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* fix accidental change to docker package.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Fiz condition of no new updates leavimg a message with CREW_UNATTENDED set.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* more updates, add missing libabigail binaries

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* rebuild py3_dbus_python

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* add arm build for 5.10 musl_linuxheaders

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add builds for openimageio.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust ruby buildsystem slightly to use cache more, adjust unit tests to properly invoke setarch, add py3_pynacl, update libsodium.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Ruby adjustments...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* unit test adjustments...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* unit test adjustments...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add error message to pip install...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* expand pip error reporting

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* More pip adjustments.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add more pip verbose error reporting.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add new workaround for pip failure on i686...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Refactor pip again...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* more refactoring...

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust py3_pip version restriction.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Avoid container jdk dependency in snowflake.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* update trove classifiers.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* adjust package fxn exit

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* adjust more jdk deps

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
2024-10-12 16:03:50 -05:00

214 lines
8.9 KiB
Ruby

require 'package'
class Llvm16_build < Package
description 'The LLVM Project is a collection of modular and reusable compiler and toolchain technologies. The optional packages clang, lld, lldb, polly, compiler-rt, libcxx, and libcxxabi are included.'
homepage 'https://llvm.org/'
version '16.0.6'
license 'Apache-2.0-with-LLVM-exceptions, UoI-NCSA, BSD, public-domain, rc, Apache-2.0 and MIT'
compatibility 'all'
source_url 'https://github.com/llvm/llvm-project.git'
git_hashtag "llvmorg-#{version}"
binary_compression 'tar.zst'
binary_sha256({
aarch64: 'ee0225da3164ae54a9d964b3606892b9cd0c6d37ade2096bbd64ce94eb2e586d',
armv7l: 'ee0225da3164ae54a9d964b3606892b9cd0c6d37ade2096bbd64ce94eb2e586d',
i686: '513668bf8310c34b0d0bfa26304a268a92904d3e6b81902f9148f69ab915ce6b',
x86_64: '53fbe0edeb0e5a7a9ad1767ce3bbaf00c306cf6f05960fe1e2bb0566ec61a748'
})
depends_on 'ocaml' => :build
depends_on 'py3_pygments' => :build
depends_on 'ccache' => :build
depends_on 'elfutils' # R
depends_on 'gcc_lib' # R
depends_on 'glibc' # R
depends_on 'libedit' # R
depends_on 'libffi' # R
depends_on 'libxml2' # R
depends_on 'ncurses' # R
depends_on 'py3_pyyaml' => :build
depends_on 'xzutils' # R
depends_on 'zlib' # R
depends_on 'zstd' # R
no_env_options
conflicts_ok
case ARCH
when 'aarch64', 'armv7l'
# LLVM_TARGETS_TO_BUILD = 'ARM;AArch64;AMDGPU'
# LLVM_TARGETS_TO_BUILD = 'all'.freeze
@ARCH_C_FLAGS = "-fPIC -mfloat-abi=hard -mthumb -mfpu=vfpv3-d16 -march=armv7-a+fp -ccc-gcc-name #{CREW_TARGET}"
@ARCH_CXX_FLAGS = "-fPIC -mfloat-abi=hard -mthumb -mfpu=vfpv3-d16 -march=armv7-a+fp -ccc-gcc-name #{CREW_TARGET}"
@ARCH_LDFLAGS = ''
@ARCH_LTO_LDFLAGS = "#{@ARCH_LDFLAGS} -flto=thin"
LLVM_PROJECTS_TO_BUILD = 'clang;clang-tools-extra;compiler-rt;libclc;lld;lldb;polly;pstl'.freeze
when 'i686'
# LLVM_TARGETS_TO_BUILD = 'X86'.freeze
# Because ld.lld: error: undefinler-rt;libc;libcxx;libcxxabi;libunwind;openmped symbol: __atomic_store
# Polly demands fPIC
@ARCH_C_FLAGS = '-latomic -fPIC'
@ARCH_CXX_FLAGS = '-latomic -fPIC'
# Because getting this error:
# ld.lld: error: relocation R_386_PC32 cannot be used against symbol isl_map_fix_si; recompile with -fPIC
# So as per https://github.com/openssl/openssl/issues/11305#issuecomment-602003528
@ARCH_LDFLAGS = '-Wl,-znotext'
@ARCH_LTO_LDFLAGS = "#{@ARCH_LDFLAGS} -flto=thin"
# lldb fails on i686 due to requirement for a kernel > 4.1.
# See https://github.com/llvm/llvm-project/issues/57594
LLVM_PROJECTS_TO_BUILD = 'clang;clang-tools-extra;compiler-rt;libclc;lld;lldb;polly;pstl'.freeze
when 'x86_64'
# LLVM_TARGETS_TO_BUILD = 'X86;AMDGPU'
# LLVM_TARGETS_TO_BUILD = 'all'.freeze
@ARCH_C_FLAGS = '-fPIC'
@ARCH_CXX_FLAGS = '-fPIC'
@ARCH_LDFLAGS = ''
@ARCH_LTO_LDFLAGS = "#{@ARCH_LDFLAGS} -flto=thin"
LLVM_PROJECTS_TO_BUILD = 'clang;clang-tools-extra;compiler-rt;libclc;lld;lldb;polly;pstl'.freeze
end
@ARCH_C_LTO_FLAGS = "#{@ARCH_C_FLAGS} -flto=thin"
@ARCH_CXX_LTO_FLAGS = "#{@ARCH_CXX_FLAGS} -flto=thin"
# flang isn't supported on 32-bit architectures.
# openmp is its own package.
# LLVM_PROJECTS_TO_BUILD = 'clang;clang-tools-extra;libcxx;libcxxabi;libunwind;lldb;compiler-rt;lld;polly;openmp'.freeze
# Using Targets 'all' for non-i686 because otherwise mesa complains.
# This may be patched upstream as per
# https://reviews.llvm.org/rG1de56d6d13c083c996dfd44a32041dacae037d66
LLVM_TARGETS_TO_BUILD = 'all'.freeze
def self.patch
return unless ARCH == 'i686'
# Patch for LLVM 15 because of https://github.com/llvm/llvm-project/issues/58851
File.write 'llvm_i686.patch', <<~LLVM_PATCH_EOF
--- a/clang/lib/Driver/ToolChains/Linux.cpp 2022-11-30 15:50:36.777754608 -0500
+++ b/clang/lib/Driver/ToolChains/Linux.cpp 2022-11-30 15:51:57.004417484 -0500
@@ -314,6 +314,7 @@ Linux::Linux(const Driver &D, const llvm
D.getVFS().exists(D.Dir + "/../lib/libc++.so"))
addPathIfExists(D, D.Dir + "/../lib", Paths);
+ addPathIfExists(D, concat(SysRoot, "#{CREW_LIB_PREFIX}"), Paths);
addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
}
LLVM_PATCH_EOF
system 'patch -Np1 -i llvm_i686.patch'
end
def self.build
############################################################
puts "Building LLVM Targets: #{LLVM_TARGETS_TO_BUILD}".lightgreen
puts "Building LLVM Projects: #{LLVM_PROJECTS_TO_BUILD}".lightgreen
############################################################
unless Dir.exist?('builddir')
FileUtils.mkdir_p 'builddir'
File.write 'builddir/clc', <<~CLC_EOF
#!/bin/bash
machine=$(gcc -dumpmachine)
version=$(gcc -dumpversion)
gnuc_lib=#{CREW_LIB_PREFIX}/gcc/${machine}/${version}
clang -B ${gnuc_lib} -L ${gnuc_lib} "$@"
CLC_EOF
File.write 'builddir/clc++', <<~CLCPLUSPLUS_EOF
#!/bin/bash
machine=$(gcc -dumpmachine)
version=$(gcc -dumpversion)
cxx_sys=#{CREW_PREFIX}/include/c++/${version}
cxx_inc=#{CREW_PREFIX}/include/c++/${version}/${machine}
gnuc_lib=#{CREW_LIB_PREFIX}/gcc/${machine}/${version}
clang++ -fPIC -rtlib=compiler-rt -stdlib=libc++ -cxx-isystem ${cxx_sys} -I ${cxx_inc} -B ${gnuc_lib} -L ${gnuc_lib} "$@"
CLCPLUSPLUS_EOF
system "cmake -B builddir -G Ninja llvm \
-DCMAKE_ASM_COMPILER_TARGET=#{CREW_TARGET} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=$(which clang) \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER_TARGET=#{CREW_TARGET} \
-DCMAKE_C_FLAGS='#{@ARCH_C_LTO_FLAGS}' \
-DCMAKE_CXX_COMPILER=$(which clang++) \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_FLAGS='#{@ARCH_CXX_LTO_FLAGS}' \
-DCMAKE_EXE_LINKER_FLAGS='#{@ARCH_LTO_LDFLAGS}' \
-DCMAKE_INSTALL_PREFIX=#{CREW_PREFIX} \
-DCMAKE_LINKER=$(which ld.lld) \
-D_CMAKE_TOOLCHAIN_PREFIX=llvm- \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-DLIBOMP_ENABLE_SHARED=ON \
-DLIBOMP_INSTALL_ALIASES=OFF \
-DLIBUNWIND_C_FLAGS='-fno-exceptions -funwind-tables' \
-DLIBUNWIND_CXX_FLAGS='-fno-exceptions -funwind-tables' \
-DLIBUNWIND_SUPPORTS_FNO_EXCEPTIONS_FLAG=ON \
-DLIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG=ON \
-DLLVM_BINUTILS_INCDIR='#{CREW_PREFIX}/include' \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_CCACHE_BUILD=ON \
-DLLVM_DEFAULT_TARGET_TRIPLE=#{CREW_TARGET} \
-DLLVM_ENABLE_FFI=ON \
-DLLVM_ENABLE_LTO=Thin \
-DLLVM_ENABLE_PROJECTS='#{LLVM_PROJECTS_TO_BUILD}' \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_RUNTIME=all \
-DLLVM_ENABLE_TERMINFO=ON \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_LIBDIR_SUFFIX='#{CREW_LIB_SUFFIX}' \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_TARGETS_TO_BUILD='#{LLVM_TARGETS_TO_BUILD}' \
-DOPENMP_ENABLE_LIBOMPTARGET=OFF \
-DPYTHON_EXECUTABLE=$(which python3) \
-Wno-dev"
end
@counter = 1
@counter_max = 20
loop do
break if Kernel.system "#{CREW_NINJA} -C builddir -j #{CREW_NPROC}"
puts "Make iteration #{@counter} of #{@counter_max}...".orange
@counter += 1
break if @counter > @counter_max
end
end
def self.install
system "DESTDIR=#{CREW_DEST_DIR} #{CREW_NINJA} -C builddir install"
Dir.chdir('builddir') do
FileUtils.install 'clc', "#{CREW_DEST_PREFIX}/bin/clc", mode: 0o755
FileUtils.install 'clc++', "#{CREW_DEST_PREFIX}/bin/clc++", mode: 0o755
FileUtils.mkdir_p "#{CREW_DEST_LIB_PREFIX}/bfd-plugins"
Dir.chdir("#{CREW_DEST_LIB_PREFIX}/bfd-plugins") do
FileUtils.ln_s "../../lib#{CREW_LIB_SUFFIX}/LLVMgold.so", 'LLVMgold.so'
end
# libunwind.* conflicts with libunwind package
FileUtils.rm Dir.glob("#{CREW_DEST_LIB_PREFIX}/libunwind.*")
end
end
# preserve for check, skip check for current version
def self.check
# Dir.chdir('builddir') do
# system 'samu check-llvm || true'
# system 'samu check-clang || true'
# system 'samu check-lld || true'
# end
end
def self.postinstall
puts
puts "To compile programs, use 'clang' or 'clang++'.".lightblue
puts
puts 'To avoid the repeated use of switch options,'.lightblue
puts "try the wrapper scripts 'clc' or 'clc++'.".lightblue
puts
puts 'For more information, see https://llvm.org/pubs/2008-10-04-ACAT-LLVM-Intro.pdf'.lightblue
puts
end
end