Files
chromebrew/packages/mold.rb
Satadru Pramanik, DO, MPH, MEng 6ced1baf0a mold => 2.4.0 (#9051)
2023-12-06 12:14:45 -06:00

64 lines
2.3 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.4.0'
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.4.0_armv7l/mold-2.4.0-chromeos-armv7l.tar.zst',
armv7l: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/mold/2.4.0_armv7l/mold-2.4.0-chromeos-armv7l.tar.zst',
i686: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/mold/2.4.0_i686/mold-2.4.0-chromeos-i686.tar.zst',
x86_64: 'https://gitlab.com/api/v4/projects/26210301/packages/generic/mold/2.4.0_x86_64/mold-2.4.0-chromeos-x86_64.tar.zst'
})
binary_sha256({
aarch64: '0bce500014118f5d55dad3d41a8dbdc8c2806b8203426a15f088f8d2b28e6b88',
armv7l: '0bce500014118f5d55dad3d41a8dbdc8c2806b8203426a15f088f8d2b28e6b88',
i686: 'c3e6f963dff77a8c1b0466ddb06a7055ba868dfafb524ce99e3e436802d3209a',
x86_64: 'ca15ebacc507f7ce643675f1f763a7086b5f507d4f0dbcf6b9fdb31a4f503d50'
})
depends_on 'gcc_lib' # R
depends_on 'glibc' # R
depends_on 'openssl' # R
depends_on 'xxhash' => :build
depends_on 'zlibpkg' # R
depends_on 'zstd' # R
no_env_options
print_source_bashrc
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
end