-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathget_binutils.sh
More file actions
executable file
·48 lines (38 loc) · 1.19 KB
/
get_binutils.sh
File metadata and controls
executable file
·48 lines (38 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -ex
BINUTILS_VERSION="${BINUTILS_VERSION:-2.42}"
BINUTILS_PREFIX="${BINUTILS_PREFIX:-/opt/gcc-14}"
cd /tmp
# Download binutils source
wget -nv https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz
tar -xf binutils-${BINUTILS_VERSION}.tar.xz
cd binutils-${BINUTILS_VERSION}
# Build with optimization flags
export CFLAGS="-O2 -pipe"
export CXXFLAGS="-O2 -pipe"
./configure \
--prefix=${BINUTILS_PREFIX} \
--disable-nls \
--disable-werror \
--disable-gdb \
--disable-gdbserver \
--disable-libdecnumber \
--disable-readline \
--disable-sim \
--enable-deterministic-archives \
--with-system-zlib
make -j$(nproc)
make install-strip
# Remove unnecessary files to reduce size
rm -rf ${BINUTILS_PREFIX}/share/info
rm -rf ${BINUTILS_PREFIX}/share/man
rm -rf ${BINUTILS_PREFIX}/share/locale
find ${BINUTILS_PREFIX} -name '*.la' -delete
find ${BINUTILS_PREFIX}/lib* -name '*.a' -exec strip --strip-debug {} \; 2>/dev/null || true
# Verify
${BINUTILS_PREFIX}/bin/ld --version
${BINUTILS_PREFIX}/bin/as --version
# Cleanup
cd /tmp
rm -rf binutils-${BINUTILS_VERSION}*
echo "Binutils ${BINUTILS_VERSION} installed successfully to ${BINUTILS_PREFIX}"