Files
chromebrew/packages/binutils.rb
github-actions[bot] 297c7cacfd ruby plus updates built on glibc 2.41 (#11923)
* Add updates of ncurses,readline, bash

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

* Add bash and deps to CREW_ESSENTIAL_PACKAGES to keep ruby from breaking.

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

* Add ruby update

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

* Update gettext

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

* Update mold

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

* Adjust build container for x86_64.

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

* Add gcc_build binaries.

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

* Add gcc build packages.

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

* rebuild binutils for gcc15

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

* bump

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

* lint

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

* git rebuild

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

* Fix const version

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

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: Satadru Pramanik <satadru@gmail.com>
2025-05-21 03:27:32 +00:00

133 lines
4.6 KiB
Ruby

# Adapted in part from Arch Linux binutils PKGBUILD at:
# https://gitlab.archlinux.org/archlinux/packaging/packages/binutils/-/blob/main/PKGBUILD
require 'English'
require 'package'
class Binutils < Package
description 'The GNU Binutils are a collection of binary tools.'
homepage 'https://www.gnu.org/software/binutils/'
version "2.44-#{CREW_GCC_VER}"
license 'GPL-3+'
compatibility 'all'
source_url "https://sourceware.org/pub/binutils/releases/binutils-#{version.split('-').first}.tar.zst"
source_sha256 '79cb120b39a195ad588cd354aed886249bfab36c808e746b30208d15271cc95c'
binary_compression 'tar.zst'
case CREW_GCC_VER
when 'gcc14'
binary_sha256({
aarch64: 'e5c64aca4584a2c275d37e58a9afc6c6c5fdf32d6e2edcff0df2bf38fb7311d2',
armv7l: 'e5c64aca4584a2c275d37e58a9afc6c6c5fdf32d6e2edcff0df2bf38fb7311d2',
i686: '67ce1feb3920893481eca99b0cb2a26a5b3192abdcea8311d3515a8d435e0da9',
x86_64: 'b7397812e623ee019376fe436d839c093ba59afab64d39555457536eeae8fe0e'
})
when 'gcc15'
binary_sha256({
aarch64: '7a245c3f45a525d89204c94b6c0426be522eda1c98e703c46fb89c57a7ac5a66',
armv7l: '7a245c3f45a525d89204c94b6c0426be522eda1c98e703c46fb89c57a7ac5a66',
i686: '191651baffb2152ed544edf3747556ef7f9c4177f3ccecae93c783578b6488f5',
x86_64: 'c93ee7fa7cfc31fdb4a30438fa051ffefab18912fd6a35398dda741bebe25e32'
})
end
depends_on 'elfutils' # R
depends_on 'flex' # R
depends_on 'gcc_lib' # R
depends_on 'glibc' # R
depends_on 'zlib' # R
depends_on 'zstd' # R
def self.prebuild
FileUtils.rm_f "#{CREW_LIB_PREFIX}/libiberty.a"
end
def self.patch
system 'filefix'
# make sure we are using our shell instead of /bin/sh
system "grep -rlZ '/bin/sh ' . | xargs -0 sed -i 's,/bin/sh ,#{CREW_PREFIX}/bin/sh ,g'"
system "grep -rlZ \"/bin/sh\\\"\" . | xargs -0 sed -i 's,/bin/sh\",#{CREW_PREFIX}/bin/sh\",g'"
system "grep -rlZ \"/bin/sh'\" . | xargs -0 sed -i \"s,/bin/sh',#{CREW_PREFIX}/bin/sh',g\""
system "sed -i 's,scriptdir = $(tooldir)/lib,scriptdir = $(tooldir)/#{ARCH_LIB},g' ld/Makefile.am"
Dir.chdir 'ld' do
system 'aclocal && automake'
end
system "sed -i '/^development=/s/true/false/' bfd/development.sh"
end
def self.build
# gprofng is broken on i686 in binutils 2.40
# https://sourceware.org/bugzilla/show_bug.cgi?id=30006
Dir.mkdir 'build'
Dir.chdir 'build' do
system "../configure #{CREW_CONFIGURE_OPTIONS} \
--disable-bootstrap \
--disable-gdb \
--disable-gdbserver \
--disable-maintainer-mode \
--enable-64-bit-bfd \
--enable-colored-disassembly \
--enable-gold \
--enable-install-libiberty \
--enable-ld \
--enable-ld=default \
--enable-lto \
--enable-plugins \
--enable-relro \
--enable-shared \
--enable-threads \
--enable-vtable-verify \
#{ARCH == 'i686' || ARCH == 'x86_64' ? '--disable-gprofng' : ''} \
--with-bugurl=https://github.com/chromebrew/chromebrew/issues/new \
--with-lib-path=#{CREW_LIB_PREFIX} \
--with-pic \
--with-pkgversion=Chromebrew \
--with-system-zlib"
system 'make configure-host'
system "make prefix=#{CREW_PREFIX} tooldir=#{CREW_PREFIX}"
system 'make -j1' if $CHILD_STATUS.exitstatus != 0
end
end
def self.check
Dir.chdir 'build' do
system 'make -O CFLAGS_FOR_TARGET="-O2 -g" \
CXXFLAGS="-O2 -no-pie -fno-PIC" \
CFLAGS="-O2 -no-pie" \
LDFLAGS="" \
check || true'
end
end
def self.install
Dir.chdir 'build' do
system 'make', "DESTDIR=#{CREW_DEST_DIR}", "prefix=#{CREW_PREFIX}",
"tooldir=#{CREW_PREFIX}", 'install'
# install PIC version of libiberty
FileUtils.install 'libiberty/pic/libiberty.a', "#{CREW_DEST_LIB_PREFIX}/", mode: 0o644
# No shared linking to these files outside binutils
FileUtils.rm_f "#{CREW_DEST_LIB_PREFIX}/libbfd.so"
FileUtils.rm_f "#{CREW_DEST_LIB_PREFIX}/libopcodes.so"
File.write "#{CREW_DEST_LIB_PREFIX}/libbfd.so", <<~LIB_BFD_EOF
/* GNU ld script */
INPUT( #{CREW_LIB_PREFIX}/libbfd.a -lsframe -liberty -lz -lzstd -ldl )
LIB_BFD_EOF
File.write "#{CREW_DEST_LIB_PREFIX}/libopcodes.so", <<~LIB_OPCODES_EOF
/* GNU ld script */
INPUT( #{CREW_LIB_PREFIX}/libopcodes.a -lbfd )
LIB_OPCODES_EOF
# Needed for gdb.
@oldlibs = %w[bfd opcodes]
@oldlibs.each do |oldlib|
FileUtils.ln_sf "#{CREW_LIB_PREFIX}/lib#{oldlib}-#{@_ver}.so",
"#{CREW_DEST_LIB_PREFIX}/lib#{oldlib}-2.39.50.so"
end
end
end
end