Files
chromebrew/packages/mold.rb
Satadru Pramanik, DO, MPH, MEng d3260f0df3 mold => 2.3.1 (#8812)
2023-10-20 23:31:48 -05:00

68 lines
2.4 KiB
Ruby

# Adapted from Arch Linux mold PKGBUILD at:
# https://github.com/archlinux/svntogit-community/raw/packages/mold/trunk/PKGBUILD
require 'package'
class Mold < Package
description 'A Modern Linker'
homepage 'https://github.com/rui314/mold'
version '2.3.1'
license 'MIT'
compatibility 'all'
source_url 'https://github.com/rui314/mold.git'
git_hashtag "v#{version}"
binary_url({
aarch64: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/mold/2.3.1_armv7l/mold-2.3.1-chromeos-armv7l.tar.zst',
armv7l: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/mold/2.3.1_armv7l/mold-2.3.1-chromeos-armv7l.tar.zst',
i686: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/mold/2.3.1_i686/mold-2.3.1-chromeos-i686.tar.zst',
x86_64: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/mold/2.3.1_x86_64/mold-2.3.1-chromeos-x86_64.tar.zst'
})
binary_sha256({
aarch64: '5b7966e94dab6666e1e86ec0128209c26689fb306f98fb53e9463af99c5802c4',
armv7l: '5b7966e94dab6666e1e86ec0128209c26689fb306f98fb53e9463af99c5802c4',
i686: '9c588afe02c221a9e69806f2226308ea5bf6a7a8b7318f9d85a6bbc79bab688b',
x86_64: '7ab15db9f31bbe7b24168e9aff48e74c0e6d78d0e1080c41f9238fcfdf1882bf'
})
depends_on 'zlibpkg' # R
depends_on 'glibc' # R
depends_on 'openssl' # R
depends_on 'gcc_lib' # R
depends_on 'xxhash' => :build
depends_on 'zstd' # R
no_env_options
def self.build
# TBB build option due to
# https://github.com/oneapi-src/oneTBB/issues/843#issuecomment-1152646035
system "cmake -B builddir #{CREW_CMAKE_OPTIONS} \
-DBUILD_TESTING=OFF \
-DMOLD_LTO=ON \
-DMOLD_USE_MOLD=ON \
-DTBB_WARNING_LEVEL='-Wno-error=stringop-overflow' \
-Wno-dev \
-G Ninja"
system "#{CREW_NINJA} -C builddir"
File.write 'moldenv', <<~MOLD_ENV_EOF
# See https://github.com/rui314/mold/commit/36fc0655489eb96e1be15b03b3f5e227cd97a22e
if [[ $(free | head -n 2 | tail -n 1 | awk '{print $4}') -gt '4096000' ]]; then
unset MOLD_JOBS
else
MOLD_JOBS=1
fi
MOLD_ENV_EOF
end
def self.install
system "DESTDIR=#{CREW_DEST_DIR} #{CREW_NINJA} -C builddir install"
FileUtils.install 'moldenv', "#{CREW_DEST_PREFIX}/etc/env.d/mold", mode: 0o644
end
def self.postinstall
puts "\nTo finish the installation, execute the following:".lightblue
puts "source ~/.bashrc\n".lightblue
end
end