# Adapted from Arch Linux mold PKGBUILD at: # https://github.com/archlinux/svntogit-community/raw/packages/mold/trunk/PKGBUILD require 'buildsystems/cmake' class Mold < CMake description 'A Modern Linker' homepage 'https://github.com/rui314/mold' version '2.39.0' license 'MIT' compatibility 'all' source_url 'https://github.com/rui314/mold.git' git_hashtag "v#{version}" binary_compression 'tar.zst' binary_sha256({ aarch64: '5c64e668a2610ea698ef565f94a2ffa9725afbb6fbb41bd97f5359a4f7903886', armv7l: '5c64e668a2610ea698ef565f94a2ffa9725afbb6fbb41bd97f5359a4f7903886', i686: 'b61d24c7867d469a1cb0d4f4d543040ef768dc520c62df51ee6f91594a1b91c5', x86_64: '2603980fe13adfc97b2997bf0162368adf76787e565ac3da71770b1c84a540da' }) depends_on 'gcc_lib' # R depends_on 'glibc' # R depends_on 'openssl' # R depends_on 'xxhash' => :build depends_on 'zlib' # R depends_on 'zstd' # R no_env_options no_shrink print_source_bashrc cmake_options "-DBUILD_TESTING=OFF \ -DMOLD_LTO=ON \ -DMOLD_USE_MOLD=ON \ -DTBB_WARNING_LEVEL='-Wno-error=stringop-overflow'" def self.install system "DESTDIR=#{CREW_DEST_DIR} #{CREW_NINJA} -C builddir install" 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 FileUtils.install 'moldenv', "#{CREW_DEST_PREFIX}/etc/env.d/mold", mode: 0o644 end end