Commit c2ae645d authored by satmandu's avatar satmandu Committed by GitHub

llvm -> 11.1.0 (#4775)

* llvm -> 11.0.1 (rc2)

* add ARM logic

* Add AMDGPU logic since mesa complains otherwise

* build all targets (otherwise mesa build complains)

* rubify

* Update llvm.rb

* cleanup

* sync w/ WIP build.

* Update llvm.rb

* sync to currently compiling build

* use binutils branch

* Current testing package file

* Working on x86_64!

* This allows compilation with llvm installed.

* add lto-fat-objects and also use parallel lto

* Update llvm.rb

* Add llvm_stage1

* Don't build AMDGPU target for i686, reduces file size below 250Mb

* cleanup

* s/Tenacious D Joke//

* remove unused constants

* set LLVM_DEFAULT_TARGET_TRIPLE to CREW_BUILD

* Use CREW_BUILD

* Reflect true version

* remove binutils, rubyize

* rubyize
parent 961f43a1
require 'package' require 'package'
class Llvm < Package class Llvm < 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, libcxxabi and openmp are included.' 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, libcxxabi, and openmp are included.'
homepage 'http://llvm.org/' homepage 'http://llvm.org/'
version '10.0.0' @_ver = '11.1.0-rc1'
version @_ver
compatibility 'all' compatibility 'all'
source_url 'https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/llvm-10.0.0.src.tar.xz' source_url "https://github.com/llvm/llvm-project/archive/llvmorg-#{@_ver}.tar.gz"
source_sha256 'df83a44b3a9a71029049ec101fb0077ecbbdf5fe41e395215025779099a98fdf' source_sha256 'e610297041129a5c5b24355a988c99c7452ee7105ee2355334a8c521b988eb3c'
binary_url ({ binary_url ({
aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-10.0.0-chromeos-armv7l.tar.xz', aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-11.1.0-rc1-chromeos-armv7l.tar.xz',
armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-10.0.0-chromeos-armv7l.tar.xz', armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-11.1.0-rc1-chromeos-armv7l.tar.xz',
i686: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-10.0.0-chromeos-i686.tar.xz', i686: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-11.1.0-rc1-chromeos-i686.tar.xz',
x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-10.0.0-chromeos-x86_64.tar.xz', x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/llvm-11.1.0-rc1-chromeos-x86_64.tar.xz',
}) })
binary_sha256 ({ binary_sha256 ({
aarch64: '0498ed55a9d3171c3f523c156822508f1b2a2d506ca87d6961427ae5165f6a34', aarch64: '5ecb72e60483b15c7588446a7ac424d64cdd3f21ca0fa5ffea4737a25dedca89',
armv7l: '0498ed55a9d3171c3f523c156822508f1b2a2d506ca87d6961427ae5165f6a34', armv7l: '5ecb72e60483b15c7588446a7ac424d64cdd3f21ca0fa5ffea4737a25dedca89',
i686: '8c4173f7de0525948ce60fed8d7fef7a3f1cb4632b650e6623eed6b4a0db7cce', i686: '5595ca097aa454bd54b8a336d467ee266f8afd4bd8100d1a3831e3face9b4f43',
x86_64: 'b4751906ff72b3e4e2fcfbf3380bdc17907e3463c86ba059113369c459c7783f', x86_64: '031f6f3510ebbc5a1270fac07934d7efa9126c8e89f98695505b1376d6d233a5',
}) })
# llvm_stage1 is compiled with gcc, without -flto
# Then in stage 2 (llvm.rb) everything is compiled with clang built in stage 1, with -flto=thin
# FYI LLVM 11.1.0 is a tiny rebuild of 11.0.1 fixing ABI compatibility with LLVM 10.0.0 & LLVM 12
depends_on 'ld_default' => :build
depends_on 'graphviz' => :build # for docs
depends_on 'python27' => :build # for test suite
depends_on 'sphinx' => :build
depends_on 'ocaml' => :build depends_on 'ocaml' => :build
depends_on 'libedit' depends_on 'libedit'
depends_on 'libtirpc' depends_on 'libtirpc'
depends_on 'swig' depends_on 'swig'
depends_on 'pygments' => :build
depends_on 'ccache' => :build
depends_on 'llvm_stage1' => :build
depends_on 'binutils' => :build
case ARCH
when 'aarch64','armv7l'
#LLVM_TARGETS_TO_BUILD = 'ARM;AArch64;AMDGPU'
LLVM_TARGETS_TO_BUILD = 'all'
@ARCH_C_FLAGS = "-fPIC -march=armv7-a -mfloat-abi=hard -ccc-gcc-name #{LLVM_DEFAULT_TARGET_TRIPLE}"
@ARCH_CXX_FLAGS = "-fPIC -march=armv7-a -mfloat-abi=hard -ccc-gcc-name #{LLVM_DEFAULT_TARGET_TRIPLE}"
@ARCH_LDFLAGS=''
when 'i686'
LLVM_TARGETS_TO_BUILD = 'X86'
# Because ld.lld: error: undefined 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'
when 'x86_64'
#LLVM_TARGETS_TO_BUILD = 'X86;AMDGPU'
LLVM_TARGETS_TO_BUILD = 'all'
@ARCH_C_FLAGS = '-fPIC'
@ARCH_CXX_FLAGS = '-fPIC'
@ARCH_LDFLAGS=''
end
@ARCH_C_LTO_FLAGS = "#{@ARCH_C_FLAGS} -flto=thin -fuse-ld=lld"
@ARCH_CXX_LTO_FLAGS = "#{@ARCH_CXX_FLAGS} -flto=thin -fuse-ld=lld"
LLVM_PROJECTS_TO_BUILD = 'clang;clang-tools-extra;libcxx;libcxxabi;libunwind;lldb;compiler-rt;lld;polly;openmp'
# 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'
def self.patch
# This keeps system libraries from being linked in as dependencies on a build host image, such as in docker.
# Uncomment the rest of this section if you need to.
#system "sudo rm /lib#{CREW_LIB_SUFFIX}/libncurses.so.5 || true"
#system "sudo rm /usr/lib#{CREW_LIB_SUFFIX}/libform.so || true"
#system "sudo ln -s #{CREW_LIB_PREFIX}/libncurses.so.6 /lib#{CREW_LIB_SUFFIX}/libncurses.so.5 || true"
#system "sudo ln -s #{CREW_LIB_PREFIX}/libform.so /usr/lib#{CREW_LIB_SUFFIX}/libform.so || true"
end
def self.build def self.build
############################# Download clang (tools) ###########################################
url_clang = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/clang-#{version}.src.tar.xz"
uri_clang = URI.parse url_clang
filename_clang = File.basename(uri_clang.path)
sha256sum_clang = '885b062b00e903df72631c5f98b9579ed1ed2790f74e5646b4234fa084eacb21'
if File.exist?(filename_clang) && Digest::SHA256.hexdigest( File.read("./#{filename_clang}") ) == sha256sum_clang
puts "Unpacking clang source code".yellow
else
puts "Downloading clang".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_clang, '-o', filename_clang)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_clang}") ) == sha256sum_clang
puts "Clang archive downloaded".lightgreen
end
system "tar", "xf", "clang-#{version}.src.tar.xz", "-C", "tools"
puts "Clang source code unpacked".lightgreen
system "rm -rf tools/clang" # remove possible existing folder
system "mv -v tools/clang-#{version}.src tools/clang"
############################# Download lld (tools) ###########################################
url_lld = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/lld-#{version}.src.tar.xz"
uri_lld = URI.parse url_lld
filename_lld = File.basename(uri_lld.path)
sha256sum_lld = 'b9a0d7c576eeef05bc06d6e954938a01c5396cee1d1e985891e0b1cf16e3d708'
if File.exist?(filename_lld) && Digest::SHA256.hexdigest( File.read("./#{filename_lld}") ) == sha256sum_lld
puts "Unpacking lld source code".yellow
else
puts "Downloading lld".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_lld, '-o', filename_lld)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_lld}") ) == sha256sum_lld
puts "Lld archive downloaded".lightgreen
end
system "tar", "xf", "lld-#{version}.src.tar.xz", "-C", "tools"
puts "Lld source code unpacked".lightgreen
system "rm -rf tools/lld"
system "mv -v tools/lld-#{version}.src tools/lld"
############################# Download lldb (tools) ###########################################
url_lldb = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/lldb-#{version}.src.tar.xz"
uri_lldb = URI.parse url_lldb
filename_lldb = File.basename(uri_lldb.path)
sha256sum_lldb = 'dd1ffcb42ed033f5167089ec4c6ebe84fbca1db4a9eaebf5c614af09d89eb135'
if File.exist?(filename_lldb) && Digest::SHA256.hexdigest( File.read("./#{filename_lldb}") ) == sha256sum_lldb
puts "Unpacking lldb source code".yellow
else
puts "Downloading lldb".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_lldb, '-o', filename_lldb)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_lldb}") ) == sha256sum_lldb
puts "Lldb archive downloaded".lightgreen
end
system "tar", "xf", "lldb-#{version}.src.tar.xz", "-C", "tools"
puts "Lldb source code unpacked".lightgreen
system "rm -rf tools/lldb"
system "mv -v tools/lldb-#{version}.src tools/lldb"
############################# Download polly (tools) ###########################################
url_polly = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/polly-#{version}.src.tar.xz"
uri_polly = URI.parse url_polly
filename_polly = File.basename(uri_polly.path)
sha256sum_polly = '35fba6ed628896fe529be4c10407f1b1c8a7264d40c76bced212180e701b4d97'
if File.exist?(filename_polly) && Digest::SHA256.hexdigest( File.read("./#{filename_polly}") ) == sha256sum_polly
puts "Unpacking polly source code".yellow
else
puts "Downloading polly".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_polly, '-o', filename_polly)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_polly}") ) == sha256sum_polly
puts "Polly archive downloaded".lightgreen
end
system "tar", "xf", "polly-#{version}.src.tar.xz", "-C", "tools"
puts "Polly source code unpacked".lightgreen
system "rm -rf tools/polly"
system "mv -v tools/polly-#{version}.src tools/polly"
# Due to compilation error, extra clang tools are not included.
############################## Download extra clang tools (tools) ###########################################
#url_extra_tools = "https://releases.llvm.org/#{version}/clang-tools-extra-#{version}.src.tar.xz"
#uri_extra_tools = URI.parse url_extra_tools
#filename_extra_tools = File.basename(uri_extra_tools.path)
#sha256sum_extra_tools = 'ea1c86ce352992d7b6f6649bc622f6a2707b9f8b7153e9f9181a35c76aa3ac10'
#if File.exist?(filename_extra_tools) && Digest::SHA256.hexdigest( File.read("./#{filename_extra_tools}") ) == sha256sum_extra_tools
# puts "Unpacking extra_tools source code".yellow
# system "tar", "xf", "clang-tools-extra-#{version}.src.tar.xz", "-C", "tools"
# puts "Polly source code unpacked".lightgreen
# system "rm -rf tools/extra"
# system "mv -v tools/clang-tools-extra-#{version}.src tools/extra"
#else
# puts "Downloading extra_tools".yellow
# system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_extra_tools, '-o', filename_extra_tools)
# abort 'Checksum mismatch. :/ Try again.'.lightred unless
# Digest::SHA256.hexdigest( File.read("./#{filename_extra_tools}") ) == sha256sum_extra_tools
# puts "Clang extra tools archive downloaded".lightgreen
# system "tar", "xf", "clang-tools-extra-#{version}.src.tar.xz", "-C", "tools"
# puts "Clang extra tools source code unpacked".lightgreen
# system "mv -v tools/clang-tools-extra-#{version}.src tools/extra"
#end
############################# Download compiler-rt (projects) ####################################
url_compiler_rt = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/compiler-rt-#{version}.src.tar.xz"
uri_compiler_rt = URI.parse url_compiler_rt
filename_compiler_rt = File.basename(uri_compiler_rt.path)
sha256sum_compiler_rt = '6a7da64d3a0a7320577b68b9ca4933bdcab676e898b759850e827333c3282c75'
if File.exist?(filename_compiler_rt) && Digest::SHA256.hexdigest( File.read("./#{filename_compiler_rt}") ) == sha256sum_compiler_rt
puts "Unpacking compiler-rt source code".yellow
else
puts "Downloading compiler-rt".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_compiler_rt, '-o', filename_compiler_rt)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_compiler_rt}") ) == sha256sum_compiler_rt
puts "Compiler-rt archive downloaded".lightgreen
end
system "tar", "xf", "compiler-rt-#{version}.src.tar.xz", "-C", "projects"
puts "Compiler-rt source code unpacked".lightgreen
system "rm -rf projects/compiler-rt"
system "mv -v projects/compiler-rt-#{version}.src projects/compiler-rt"
############################# Download libcxx (procjects) ####################################
url_libcxx = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/libcxx-#{version}.src.tar.xz"
uri_libcxx = URI.parse url_libcxx
filename_libcxx = File.basename(uri_libcxx.path)
sha256sum_libcxx = '270f8a3f176f1981b0f6ab8aa556720988872ec2b48ed3b605d0ced8d09156c7'
if File.exist?(filename_libcxx) && Digest::SHA256.hexdigest( File.read("./#{filename_libcxx}") ) == sha256sum_libcxx
puts "Unpacking libcxx source code".yellow
else
puts "Downloading libcxx".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_libcxx, '-o', filename_libcxx)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_libcxx}") ) == sha256sum_libcxx
puts "Libcxx archive downloaded".lightgreen
end
system "tar", "xf", "libcxx-#{version}.src.tar.xz", "-C", "projects"
puts "Libcxx source code unpacked".lightgreen
system "rm -rf projects/libcxx"
system "mv -v projects/libcxx-#{version}.src projects/libcxx"
############################# Download libcxxabi (procjects) ####################################
url_libcxxabi = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/libcxxabi-#{version}.src.tar.xz"
uri_libcxxabi = URI.parse url_libcxxabi
filename_libcxxabi = File.basename(uri_libcxxabi.path)
sha256sum_libcxxabi = 'e71bac75a88c9dde455ad3f2a2b449bf745eafd41d2d8432253b2964e0ca14e1'
if File.exist?(filename_libcxxabi) && Digest::SHA256.hexdigest( File.read("./#{filename_libcxxabi}") ) == sha256sum_libcxxabi
puts "Unpacking libcxxabi source code".yellow
else
puts "Downloading libcxxabi".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_libcxxabi, '-o', filename_libcxxabi)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_libcxxabi}") ) == sha256sum_libcxxabi
puts "Libcxxabi archive downloaded".lightgreen
end
system "tar", "xf", "libcxxabi-#{version}.src.tar.xz", "-C", "projects"
puts "Libcxxabi source code unpacked".lightgreen
system "rm -rf projects/libcxxabi"
system "mv -v projects/libcxxabi-#{version}.src projects/libcxxabi"
############################# Download libomp (procjects) ####################################
url_openmp = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/openmp-#{version}.src.tar.xz"
uri_openmp = URI.parse url_openmp
filename_openmp = File.basename(uri_openmp.path)
sha256sum_openmp = '3b9ff29a45d0509a1e9667a0feb43538ef402ea8cfc7df3758a01f20df08adfa'
if File.exist?(filename_openmp) && Digest::SHA256.hexdigest( File.read("./#{filename_openmp}") ) == sha256sum_openmp
puts "Unpacking openmp source code".yellow
else
puts "Downloading openmp".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_openmp, '-o', filename_openmp)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_openmp}") ) == sha256sum_openmp
puts "Openmp archive downloaded".lightgreen
end
system "tar", "xf", "openmp-#{version}.src.tar.xz", "-C", "projects"
puts "Openmp source code unpacked".lightgreen
system "rm -rf projects/openmp"
system "mv -v projects/openmp-#{version}.src projects/openmp"
############################# Download libunwind (procjects) ####################################
url_libunwind = "https://github.com/llvm/llvm-project/releases/download/llvmorg-#{version}/libunwind-#{version}.src.tar.xz"
uri_libunwind = URI.parse url_libunwind
filename_libunwind = File.basename(uri_libunwind.path)
sha256sum_libunwind = '09dc5ecc4714809ecf62908ae8fe8635ab476880455287036a2730966833c626'
if File.exist?(filename_libunwind) && Digest::SHA256.hexdigest( File.read("./#{filename_libunwind}") ) == sha256sum_libunwind
puts "Unpacking libunwind source code".yellow
else
puts "Downloading libunwind".yellow
system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_libunwind, '-o', filename_libunwind)
abort 'Checksum mismatch. :/ Try again.'.lightred unless
Digest::SHA256.hexdigest( File.read("./#{filename_libunwind}") ) == sha256sum_libunwind
puts "Libunwind archive downloaded".lightgreen
end
system "tar", "xf", "libunwind-#{version}.src.tar.xz", "-C", "projects"
puts "Libunwind source code unpacked".lightgreen
system "rm -rf projects/libunwind"
system "mv -v projects/libunwind-#{version}.src projects/libunwind"
############################# Download test-suite (procjects) ####################################
#url_testsuite = "https://releases.llvm.org/#{version}/test-suite-#{version}.src.tar.xz"
#uri_testsuite = URI.parse url_testsuite
#filename_testsuite = File.basename(uri_testsuite.path)
#sha256sum_testsuite = '2ba3cde840c1c0ef744c93ae6a921207dbb9ccbb39f93f7ace9252e5203307cf'
#if File.exist?(filename_testsuite) && Digest::SHA256.hexdigest( File.read("./#{filename_testsuite}") ) == sha256sum_testsuite
# puts "Unpacking test-suite source code".yellow
#else
# puts "Downloading test suite".yellow
# system('curl', '-s', '-C', '-', '--insecure', '-L', '-#', url_testsuite, '-o', filename_testsuite)
# abort 'Checksum mismatch. :/ Try again.'.lightred unless
# Digest::SHA256.hexdigest( File.read("./#{filename_testsuite}") ) == sha256sum_testsuite
# puts "Test-suite archive downloaded".lightgreen
#end
# system "tar", "xf", "test-suite-#{version}.src.tar.xz", "-C", "projects"
# puts "Test-suite source code unpacked".lightgreen
# system "rm -rf projects/test-suite"
# system "mv -v projects/test-suite-#{version}.src projects/test-suite"
############################################################ ############################################################
puts "Optional packages are ready".lightgreen puts "Building LLVM Targets: #{LLVM_TARGETS_TO_BUILD}".lightgreen
puts "Building LLVM Projects: #{LLVM_PROJECTS_TO_BUILD}".lightgreen
############################################################ ############################################################
############################################################
puts 'Change to GOLD linker.'.orange puts "Setting compile to use python3".lightgreen
original_default = `ld_default g`.chomp ############################################################
system "grep -rl '#!.*python' | xargs sed -i '1s/python$/python3/'"
############################################################
# puts "Downloading binutils #{BINUTILS_BRANCH} src to enable gold plugin build".lightgreen
############################################################
# system "git config --global advice.detachedHead false"
# As per https://github.com/SVF-tools/SVF/wiki/Install-LLVM-Gold-Plugin-on-Ubuntu
# system "git clone --depth 1 --branch #{BINUTILS_BRANCH} git://sourceware.org/git/binutils-gdb.git binutils"
Dir.mkdir 'builddir' Dir.mkdir 'builddir'
Dir.chdir 'builddir' do Dir.chdir 'builddir' do
system "echo '#!/bin/bash system "echo '#!/bin/bash
...@@ -285,52 +108,66 @@ cxx_sys=#{CREW_PREFIX}/include/c++/\${version} ...@@ -285,52 +108,66 @@ cxx_sys=#{CREW_PREFIX}/include/c++/\${version}
cxx_inc=#{CREW_PREFIX}/include/c++/\${version}/\${machine} cxx_inc=#{CREW_PREFIX}/include/c++/\${version}/\${machine}
gnuc_lib=#{CREW_LIB_PREFIX}/gcc/\${machine}/\${version} 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} \"\$@\"' > clc++" clang++ -fPIC -rtlib=compiler-rt -stdlib=libc++ -cxx-isystem \${cxx_sys} -I \${cxx_inc} -B \${gnuc_lib} -L \${gnuc_lib} \"\$@\"' > clc++"
case ARCH system "env PATH=#{CREW_LIB_PREFIX}/ccache/bin:#{CREW_PREFIX}/bin:/usr/bin:/bin LD=ld.lld \
when "x86_64" cmake -G Ninja \
system 'cmake', -DLLVM_ENABLE_LTO=Thin \
"-DCURSES_INCLUDE_PATH='#{CREW_PREFIX}/include/ncursesw'", -DCMAKE_C_COMPILER=$(which clang) \
"-DCMAKE_INSTALL_PREFIX=#{CREW_PREFIX}", -DCMAKE_CXX_COMPILER=$(which clang++) \
'-DCMAKE_CXX_FLAGS="-fPIC"', -DCMAKE_INSTALL_PREFIX=#{CREW_PREFIX} \
'-DCMAKE_BUILD_TYPE=Release', -DLLVM_DEFAULT_TARGET_TRIPLE=#{CREW_BUILD} \
'-DLLVM_LIBDIR_SUFFIX=64', -DCMAKE_C_COMPILER_TARGET=#{CREW_BUILD} \
'-DBUILD_SHARED_LIBS=ON', -DCMAKE_ASM_COMPILER_TARGET=#{CREW_BUILD} \
'-DLLVM_ENABLE_RTTI=ON', -DLLVM_TARGETS_TO_BUILD=\'#{LLVM_TARGETS_TO_BUILD}' \
'-Wno-dev', -DCMAKE_BUILD_TYPE=Release \
'..' -DLLVM_LIBDIR_SUFFIX='#{CREW_LIB_SUFFIX}' \
# Fix for file INSTALL cannot find ".../lib64/python2.7" error. -DCMAKE_LINKER=$(which ld.lld) \
# See http://lists.llvm.org/pipermail/lldb-dev/2015-June/007633.html. -D_CMAKE_TOOLCHAIN_PREFIX=llvm- \
system "sed -i '40,43d' tools/lldb/cmake_install.cmake" -DLLVM_BUILD_LLVM_DYLIB=ON \
else # armv7l, aarch64 or i686 -DLLVM_LINK_LLVM_DYLIB=ON \
system 'cmake', -DLLVM_CCACHE_BUILD=ON \
"-DCURSES_INCLUDE_PATH='#{CREW_PREFIX}/include/ncursesw'", -DLLVM_ENABLE_FFI=ON \
"-DCMAKE_INSTALL_PREFIX=#{CREW_PREFIX}", -DLLVM_ENABLE_RTTI=ON \
'-DCMAKE_CXX_FLAGS="-fPIC"', -DCMAKE_C_FLAGS='#{@ARCH_C_LTO_FLAGS}' \
'-DCMAKE_BUILD_TYPE=Release', -DCMAKE_CXX_FLAGS='#{@ARCH_CXX_LTO_FLAGS}' \
'-DBUILD_SHARED_LIBS=ON', -DCMAKE_EXE_LINKER_FLAGS='#{@ARCH_LDFLAGS}' \
'-DLLVM_ENABLE_RTTI=ON', -DLLVM_PARALLEL_LINK_JOBS=1 \
'-Wno-dev', -DPYTHON_EXECUTABLE=$(which python3) \
'..' -DLLVM_INSTALL_UTILS=ON \
end -DLLVM_BINUTILS_INCDIR='#{CREW_PREFIX}/include' \
system 'make' -DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_ENABLE_TERMINFO=ON \
-DLLVM_ENABLE_PROJECTS='#{LLVM_PROJECTS_TO_BUILD}' \
-DLIBUNWIND_C_FLAGS='-fno-exceptions -funwind-tables' \
-DLIBUNWIND_CXX_FLAGS='-fno-exceptions -funwind-tables' \
-DLIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG=ON \
-DLIBUNWIND_SUPPORTS_FNO_EXCEPTIONS_FLAG=ON \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-Wno-dev \
../llvm"
system 'ninja'
end end
system "ld_default #{original_default}"
end end
def self.install def self.install
Dir.chdir("builddir") do Dir.chdir("builddir") do
system "install -Dm755 clc #{CREW_DEST_PREFIX}/bin/clc" FileUtils.install 'clc', "#{CREW_DEST_PREFIX}/bin/clc", mode: 0755
system "install -Dm755 clc++ #{CREW_DEST_PREFIX}/bin/clc++" FileUtils.install 'clc++', "#{CREW_DEST_PREFIX}/bin/clc++", mode: 0755
system 'make', "DESTDIR=#{CREW_DEST_DIR}", 'install' system "DESTDIR=#{CREW_DEST_DIR} ninja install"
FileUtils.mkdir_p "#{CREW_DEST_LIB_PREFIX}/bfd-plugins"
FileUtils.ln_s "lib#{CREW_LIB_SUFFIX}/LLVMgold.so", "#{CREW_DEST_LIB_PREFIX}/bfd-plugins/"
end end
end end
#def self.check def self.check
# Dir.chdir("builddir") do Dir.chdir("builddir") do
# system "make -k -j#{CREW_NPROC} check-llvm" #system "ninja check-llvm || true"
# system "make -k -j#{CREW_NPROC} check-clang" #system "ninja check-clang || true"
# system "make -k -j#{CREW_NPROC} check-lld" #system "ninja check-lld || true"
# end end
#end end
def self.postinstall def self.postinstall
puts puts
......
require 'package'
class Llvm_stage1 < Package
description 'THIS IS NOT THE LLVM PACKAGE. This is only a Limited Stage 1 compile of LLVM.'
homepage 'http://llvm.org/'
@_ver = '11.1.0-rc1'
version @_ver
compatibility 'all'
source_url "https://github.com/llvm/llvm-project/archive/llvmorg-#{@_ver}.tar.gz"
source_sha256 'e610297041129a5c5b24355a988c99c7452ee7105ee2355334a8c521b988eb3c'
binary_url ({
aarch64: 'https://dl.bintray.com/chromebrew/chromebrew/llvm_stage1-11.1.0-rc1-chromeos-armv7l.tar.xz',
armv7l: 'https://dl.bintray.com/chromebrew/chromebrew/llvm_stage1-11.1.0-rc1-chromeos-armv7l.tar.xz',
i686: 'https://dl.bintray.com/chromebrew/chromebrew/llvm_stage1-11.1.0-rc1-chromeos-i686.tar.xz',
x86_64: 'https://dl.bintray.com/chromebrew/chromebrew/llvm_stage1-11.1.0-rc1-chromeos-x86_64.tar.xz',
})
binary_sha256 ({
aarch64: '863dd7cae43abef88dfe25c60e0dda1f8d59756f8c8fbb111989a3669dca0a16',
armv7l: '863dd7cae43abef88dfe25c60e0dda1f8d59756f8c8fbb111989a3669dca0a16',
i686: '84a5a2a381af8c789fcb895d1ae62dc1932b3ad1ad423e8351e37aa9be5e2490',
x86_64: 'ddb9e88444729174b0c6f4de883910ce78e8fa489e0831acdf92daaf4561e9af',
})
# llvm_stage1 is compiled with gcc, without -flto
# Then in stage 2 (llvm.rb) everything is compiled with clang built in stage 1, with -flto=thin
# FYI LLVM 11.1.0 is a tiny rebuild of 11.0.1 fixing ABI compatibility with LLVM 10.0.0 & LLVM 12
depends_on 'ocaml' => :build
depends_on 'libedit'
depends_on 'libtirpc'
depends_on 'swig'
depends_on 'pygments' => :build
depends_on 'ccache' => :build
case ARCH
when 'aarch64','armv7l'
#LLVM_TARGETS_TO_BUILD = 'ARM;AArch64;AMDGPU'
@ARCH_C_FLAGS = '-march=armv7-a -mfloat-abi=hard'
@ARCH_CXX_FLAGS = '-march=armv7-a -mfloat-abi=hard'
LLVM_PROJECTS_TO_BUILD = 'clang;clang-tools-extra;libcxx;libcxxabi;lld'
when 'i686','x86_64'
#LLVM_TARGETS_TO_BUILD = 'X86;AMDGPU'
@ARCH_C_FLAGS = '-fPIC'
@ARCH_CXX_FLAGS = '-fPIC'
LLVM_PROJECTS_TO_BUILD = 'clang;clang-tools-extra;libcxx;libcxxabi;libunwind;lld'
end
@ARCH_C_LTO_FLAGS = "#{@ARCH_C_FLAGS} -flto"
@ARCH_CXX_LTO_FLAGS = "#{@ARCH_CXX_FLAGS} -flto"
# Using Targets 'all' because otherwise mesa complains.
# This may be patched upstream as per
# https://reviews.llvm.org/rG1de56d6d13c083c996dfd44a32041dacae037d66
LLVM_TARGETS_TO_BUILD = 'all'
LLVM_VERSION = version.split("-")[0]
def self.build
############################################################
puts "Building LLVM Targets: #{LLVM_TARGETS_TO_BUILD}".lightgreen
puts "Building LLVM Projects: #{LLVM_PROJECTS_TO_BUILD}".lightgreen
############################################################
############################################################
puts "Setting compile to use python3".lightgreen
############################################################
system "grep -rl '#!.*python' | xargs sed -i '1s/python$/python3/'"
Dir.mkdir 'builddir'
Dir.chdir 'builddir' do
system "echo '#!/bin/bash
machine=\$(gcc -dumpmachine)
version=\$(gcc -dumpversion)
gnuc_lib=#{CREW_LIB_PREFIX}/gcc/\${machine}/\${version}
clang -B \${gnuc_lib} -L \${gnuc_lib} \"\$@\"' > clc"
system "echo '#!/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} \"\$@\"' > clc++"
system "env PATH=#{CREW_LIB_PREFIX}/ccache/bin:#{CREW_PREFIX}/bin:/usr/bin:/bin FC= \
cmake -G Ninja \
-DCMAKE_INSTALL_PREFIX=#{CREW_PREFIX} \
-DLLVM_DEFAULT_TARGET_TRIPLE=#{CREW_BUILD} \
-DLLVM_TARGETS_TO_BUILD=\'#{LLVM_TARGETS_TO_BUILD}' \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_LIBDIR_SUFFIX='#{CREW_LIB_SUFFIX}' \
-DCMAKE_LINKER=$(which ld.gold) \
-D_CMAKE_TOOLCHAIN_PREFIX=gcc- \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_ENABLE_FFI=ON \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_C_FLAGS='#{@ARCH_C_FLAGS}' \
-DCMAKE_CXX_FLAGS='#{@ARCH_CXX_FLAGS}' \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DPYTHON_EXECUTABLE=$(which python3) \
-DLLVM_BINUTILS_INCDIR='#{CREW_PREFIX}/include' \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_ENABLE_TERMINFO=ON \
-DLLVM_ENABLE_PROJECTS='#{LLVM_PROJECTS_TO_BUILD}' \
-DLIBUNWIND_C_FLAGS='-fno-exceptions -funwind-tables' \
-DLIBUNWIND_CXX_FLAGS='-fno-exceptions -funwind-tables' \
-DLIBUNWIND_SUPPORTS_FUNWIND_TABLES_FLAG=ON \
-DLIBUNWIND_SUPPORTS_FNO_EXCEPTIONS_FLAG=ON \
-DCOMPILER_RT_BUILD_SANITIZERS=OFF \
-DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
-DCOMPILER_RT_BUILD_BUILTINS=ON \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-Wno-dev \
../llvm"
system 'ninja -j1'
end
end
def self.install
Dir.chdir("builddir") do
FileUtils.install 'clc', "#{CREW_DEST_PREFIX}/bin/clc", mode: 0755
FileUtils.install 'clc++', "#{CREW_DEST_PREFIX}/bin/clc++", mode: 0755
system "DESTDIR=#{CREW_DEST_DIR} ninja install"
FileUtils.mkdir_p "#{CREW_DEST_LIB_PREFIX}/bfd-plugins"
FileUtils.ln_s "lib#{CREW_LIB_SUFFIX}/LLVMgold.so", "#{CREW_DEST_LIB_PREFIX}/bfd-plugins/"
end
end
def self.check
Dir.chdir("builddir") do
#system "ninja check-llvm || true"
#system "ninja check-clang || true"
#system "ninja 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 http://llvm.org/pubs/2008-10-04-ACAT-LLVM-Intro.pdf".lightblue
puts
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment