Skip to content

Commit bbbbad5

Browse files
ziuziakowskaluismarques
authored andcommitted
Update Binutils to 2.44
Upstream binutils now supports the ratified 1.0.0 bitmanip extensions, so rather than maintaining patches to add the unratified extensions back in, a fork of binutils was created which we now use, and should allow for easier updates to future versions. The glob and ELF BFD patches are no longer required for this version of binutils to build correctly so they are removed. Since the last version of binutils used, the GMP and MPFR libraries have become required for building GDB. However, the configure step will always prefer the shared library rather than the static one when building, so we have to build our own static-only libraries of these to link. MPFR is clone-able from the official repository, however GMP does not appreciate excessive cloning, so we use a release archive instead for that. The updated binutils contain a change for generating verilog memory (vmem) files that is useful for OpenTitan. See also: https://github.com/lowRISC/binutils Signed-off-by: Alice Ziuziakowska <[email protected]>
1 parent 00f843e commit bbbbad5

File tree

7 files changed

+62
-531
lines changed

7 files changed

+62
-531
lines changed

README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ How to do a release
4040
will be uploaded to
4141
[GitHub releases](https://github.com/lowRISC/lowrisc-toolchains/releases).
4242

43-
How to generate the bitmanip patch
44-
------------------------------------
45-
46-
```
47-
git clone https://github.com/riscv-collab/riscv-binutils-gdb.git
48-
cd riscv-binutils-gdb
49-
# checkout Pirmin's bitmanip 1.00+0.93 PR (https://github.com/riscv-collab/riscv-binutils-gdb/pull/267)
50-
gh pr checkout 267
51-
# 7c9dd840 (riscv-binutils-2.35-rvb) is our baseline
52-
git diff 7c9dd840 > $TOP/patches/lowrisc-toolchain-gcc-rv32imcb/binutils/git-7c9dd840/001-bitmanip.patch
53-
```
5443
How to install pre-built toolchain
5544
------------------------------------
5645
1. Download a tar.gz file from release page.

build-binutils.sh

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ repo_dir="$(git rev-parse --show-toplevel)"
1717
build_dir="${repo_dir}/build"
1818
patch_dir="${repo_dir}/patches"
1919
dist_dir="${build_dir}/dist"
20+
static_libs_dir="${build_dir}/libs"
2021

2122
source "${repo_dir}/sw-versions.sh"
2223

@@ -41,7 +42,9 @@ fi
4142

4243
set -x
4344

45+
mkdir -p "$dist_dir"
4446
mkdir -p "$build_dir"
47+
mkdir -p "$static_libs_dir"
4548
cd "$build_dir"
4649

4750
if [ ! -d binutils ]; then
@@ -50,21 +53,54 @@ if [ ! -d binutils ]; then
5053
--depth 1
5154
fi
5255

53-
cd binutils
54-
git reset --hard
55-
git checkout "$BINUTILS_COMMIT"
56-
git apply "${patch_dir}/binutils/"*
56+
if [ ! -d gmp ]; then
57+
tmp=$(mktemp -d)
58+
mkdir -p ${tmp}/gmp
59+
curl -L "$GMP_URL" -o "${tmp}/gmp.tar.xz"
60+
printf "$GMP_SHA256 ${tmp}/gmp.tar.xz\n" > ${tmp}/gmp.sha256
61+
sha256sum -c ${tmp}/gmp.sha256
62+
xzcat ${tmp}/gmp.tar.xz | tar --strip-components=1 -C ${tmp}/gmp -x -v -f -
63+
mv ${tmp}/gmp gmp
64+
rm ${tmp}/gmp.tar.xz
65+
fi
5766

58-
mkdir -p build
59-
cd build
67+
if [ ! -d mpfr ]; then
68+
git clone "$MPFR_URL" mpfr \
69+
--branch "$MPFR_BRANCH" \
70+
--depth 1
71+
fi
6072

61-
mkdir -p "$dist_dir"
73+
cd gmp
74+
./configure \
75+
--enable-static=yes \
76+
--enable-shared=no \
77+
--prefix=$static_libs_dir
78+
make -j "$(nproc)"
79+
make -j "$(nproc)" check
80+
make install
81+
cd ..
6282

63-
../configure \
64-
--target="$target" \
65-
--program-prefix="$target-" \
66-
--prefix="$dist_dir" \
67-
--with-libexpat-type=static
83+
cd mpfr
84+
./autogen.sh
85+
./configure \
86+
--enable-static=yes \
87+
--enable-shared=no \
88+
--with-gmp=$static_libs_dir \
89+
--prefix=$static_libs_dir
90+
make -j "$(nproc)"
91+
make install
92+
cd ..
6893

94+
cd binutils
95+
mkdir -p build
96+
cd build
97+
../configure \
98+
--target="$target" \
99+
--program-prefix="$target-" \
100+
--prefix="$dist_dir" \
101+
--with-libexpat-type=static \
102+
--with-gmp=$static_libs_dir \
103+
--with-mpfr=$static_libs_dir
69104
make -j "$(nproc)"
105+
make -C gas check
70106
make install

patches/binutils/001-bfd-elf.patch

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)