Skip to content

Commit cd1e510

Browse files
jwnrtluismarques
authored andcommitted
Build binutils without crosstool-ng
1 parent 04a97fc commit cd1e510

File tree

9 files changed

+88
-69
lines changed

9 files changed

+88
-69
lines changed

.github/workflows/toolchain_build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ jobs:
7373
echo Creating artifact staging directory...
7474
mkdir "$ARTIFACT_STAGING_DIR"
7575
76+
- name: Build Binutils
77+
run: |
78+
./build-binutils.sh \
79+
"${{ matrix.target }}" \
80+
"${{ matrix.output_dir }}"
81+
7682
- name: Build GCC toolchain
7783
run: |
7884
./build-gcc-with-args.sh \

build-binutils.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
# Copyright lowRISC contributors.
3+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
## build-binutils.sh
7+
#
8+
# Builds:
9+
# - GNU Binutils, GDB
10+
#
11+
# Then:
12+
# - Creates a tar file of the whole install directory
13+
14+
set -e -o pipefail
15+
16+
repo_dir="$(git rev-parse --show-toplevel)"
17+
build_dir="${repo_dir}/build"
18+
patch_dir="${repo_dir}/patches"
19+
20+
source "${repo_dir}/sw-versions.sh"
21+
22+
if [ "$#" -ne 2 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
23+
echo "USAGE: $0 <target> <dist dir>" >&2
24+
echo >&2
25+
echo "EXAMPLE:" >&2
26+
echo " $0 riscv32 dist/" >&2
27+
exit 1
28+
fi
29+
30+
target="$1"
31+
32+
# Double check the arch part of the target tuple.
33+
target_arch="${target/%-*}"
34+
if [ "$target_arch" != "riscv32" ] && [ "$target_arch" != "riscv64" ]; then
35+
echo "Error: unsupported target '${target}'" >&2
36+
echo >&2
37+
echo "Supported arches are: riscv32, riscv64" >&2
38+
exit 1
39+
fi
40+
41+
set -x
42+
43+
dist_dir="$(realpath "$2")"
44+
mkdir -p "$dist_dir"
45+
46+
mkdir -p "$build_dir"
47+
cd "$build_dir"
48+
49+
if [ ! -d binutils ]; then
50+
git clone "$BINUTILS_URL" binutils \
51+
--branch "$BINUTILS_BRANCH" \
52+
--depth 1
53+
fi
54+
55+
cd binutils
56+
git reset --hard
57+
git checkout "$BINUTILS_COMMIT"
58+
git apply "${patch_dir}/binutils/"*
59+
60+
mkdir -p build
61+
cd build
62+
63+
# NOTE: We don't want to require `libexpat` to be dynamically linked.
64+
# It turns out to be quite hard to statically link *only* `libexpat`.
65+
../configure \
66+
--target "$target" \
67+
--program-prefix="$target-" \
68+
--prefix "$dist_dir" \
69+
--with-expat=no
70+
71+
make -j "$(nproc)"
72+
make install

lowrisc-toolchain-gcc-rv32imcb.config

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,6 @@ CT_PREFIX_DIR="/tools/riscv"
5858
# Don't chmod the CT_PREFIX_DIR read-only after the install.
5959
# CT_PREFIX_DIR_RO is not set
6060

61-
# Binutils 2.35, RISC-V bitmanip fork (branch riscv-binutils-2.35-rvb,
62-
# commit 7c9dd840fb from 2021-03-10).
63-
# A bitmanip 1.0+0.93 patch will be applied on top.
64-
CT_BINUTILS_SRC_DEVEL=y
65-
CT_BINUTILS_DEVEL_VCS_git=y
66-
CT_BINUTILS_DEVEL_URL="https://github.com/riscv-collab/riscv-binutils-gdb.git"
67-
CT_BINUTILS_DEVEL_REVISION="7c9dd840fbb6a1171a51feb08afb859288615137"
68-
6961
# GCC 10.2.0, RISC-V bitmanip fork (branch riscv-gcc-10.2.0-rvb,
7062
# commit 73055647d33 from 2021-07-09)
7163
CT_GCC_SRC_DEVEL=y

lowrisc-toolchain-gcc-rv64imac.config

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ CT_PREFIX_DIR="/tools/riscv"
4646
# Don't chmod the CT_PREFIX_DIR read-only after the install.
4747
# CT_PREFIX_DIR_RO is not set
4848

49-
# Binutils 2.35 (tag binutils-2_35, commit 2cb5c79dad3)
50-
CT_BINUTILS_SRC_DEVEL=y
51-
CT_BINUTILS_DEVEL_VCS_git=y
52-
CT_BINUTILS_DEVEL_URL="https://github.com/bminor/binutils-gdb.git"
53-
CT_BINUTILS_DEVEL_REVISION="2cb5c79dad39dd438fb0f7372ac04cf5aa2a7db7"
54-
5549
# GCC 10.2.0 (tag releases/gcc-10.2.0, commit ee5c3db6c5b)
5650
CT_GCC_SRC_DEVEL=y
5751
CT_GCC_DEVEL_VCS_git=y

patches/lowrisc-toolchain-gcc-rv32imcb/binutils/git-7c9dd840/001-bitmanip.patch renamed to patches/binutils/001-bitmanip.patch

File renamed without changes.

patches/lowrisc-toolchain-gcc-rv32imc/gdb/11.1/001-glob-libc-config.patch renamed to patches/binutils/001-glob-libc-config.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/gnulib/import/glob.c b/gnulib/import/glob.c
2-
index 1bfcafb..9947f24 100644
2+
index f1b20d4869..b10bea1d9f 100644
33
--- a/gnulib/import/glob.c
44
+++ b/gnulib/import/glob.c
55
@@ -21,7 +21,7 @@
@@ -12,13 +12,13 @@ index 1bfcafb..9947f24 100644
1212
#endif
1313

1414
diff --git a/gnulib/import/libc-config.h b/gnulib/import/libc-config.h
15-
index e3571ee..44c3d0f 100644
15+
index 124f1d77e0..f1e9f59c81 100644
1616
--- a/gnulib/import/libc-config.h
1717
+++ b/gnulib/import/libc-config.h
18-
@@ -189,3 +189,7 @@
18+
@@ -181,3 +181,7 @@
19+
/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
1920
#define SHLIB_COMPAT(lib, introduced, obsoleted) 0
20-
#define compat_symbol(lib, local, symbol, version) extern int dummy
21-
#define versioned_symbol(lib, local, symbol, version) extern int dummy
21+
#define versioned_symbol(lib, local, symbol, version)
2222
+
2323
+#ifndef __THROWNL
2424
+#define __THROWNL __THROW

patches/lowrisc-toolchain-gcc-rv32imcb/gdb/11.1/001-glob-libc-config.patch

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

patches/lowrisc-toolchain-gcc-rv64imac/gdb/11.1/001-glob-libc-config.patch

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

sw-versions.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ export QEMU_VERSION=23967e5b2a6c6d04b8db766a8a149f3631a7b899
1717
export LLVM_URL=https://github.com/lowRISC/llvm-project.git
1818
export LLVM_BRANCH=ot-llvm-16-hardening
1919
export LLVM_VERSION=dec908d48facb6041c12b95b8ade64719a894917
20+
21+
# RISC-V fork of Binutils 2.35 with bitmanip instruction support
22+
export BINUTILS_URL=https://github.com/riscv-collab/riscv-binutils-gdb.git
23+
export BINUTILS_BRANCH=riscv-binutils-2.35-rvb
24+
export BINUTILS_COMMIT=7c9dd840fbb6a1171a51feb08afb859288615137

0 commit comments

Comments
 (0)