Skip to content

Commit 53d37ac

Browse files
committed
Change Clang args to be named
Signed-off-by: James Wainwright <james.wainwright@lowrisc.org>
1 parent f81c645 commit 53d37ac

File tree

3 files changed

+56
-35
lines changed

3 files changed

+56
-35
lines changed

.github/workflows/toolchain_build.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,11 @@ jobs:
7979
- name: Build Clang toolchain
8080
run: |
8181
./build-clang-with-args.sh \
82-
"lowrisc-toolchain-${{ matrix.name }}" \
83-
Release \
84-
"${{ matrix.target }}" \
85-
"${{ matrix.march }}" \
86-
"${{ matrix.mabi}}" \
87-
"${{ matrix.mcmodel }}" \
88-
"${{ matrix.cflags }}"
82+
--name "lowrisc-toolchain-${{ matrix.name }}" \
83+
--target "${{ matrix.target }}" \
84+
--march "${{ matrix.march }}" \
85+
--mabi "${{ matrix.mabi}}" \
86+
--mcmodel "${{ matrix.mcmodel }}"
8987
9088
- name: Package toolchains
9189
run: |

build-clang-with-args.sh

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,57 @@
1414
# - Creates a tar file of the whole install directory
1515

1616
set -e
17-
set -x
1817
set -o pipefail
1918

20-
if ! [ "$#" -ge 3 ]; then
21-
echo "Usage: $0 <config_name> <target> <dest_dir> <march> <mabi> <mcmodel> <cflags...>"
22-
exit 2
23-
fi;
24-
2519
repo_dir="$(git rev-parse --show-toplevel)"
2620
build_dir="${repo_dir}/build"
2721
dist_dir="${build_dir}/dist"
2822

29-
## Take configuration from arguments
30-
# This is the name for the tar file.
31-
toolchain_name="${1}"
32-
# This is the CMake build type (e.g. Release, Debug, RelWithDebInfo)
33-
build_type="${2}"
34-
# This is the expected target triple (so we can set a default)
35-
toolchain_target="${3}"
36-
# -march option default value
37-
march="${4}"
38-
# -mabi option default value
39-
mabi="${5}"
40-
# -mcmodel option default value
41-
mcmodel="${6}"
42-
# Remaining cflags for build configurations
43-
toolchain_cflags=("${@:7}")
23+
usage="\
24+
USAGE: ${0} [options] <args>
25+
26+
OPTIONS:
27+
-h,--help Print this message
28+
--debug Build with assertions and debug info
29+
30+
ARGS:
31+
--name <name> Name of the toolchain
32+
--target <target> Default target triple
33+
--march <march> Default -march
34+
--mabi <mabi> Default -mabi
35+
--mcmodel <mcmodel> Default -mcmodel
36+
"
37+
options="$(getopt -a -o '-h' -l 'help,name:,target:,march:,mabi:,mcmodel:,debug' -- "$@")"
38+
39+
err() {
40+
echo "ERROR ${1}" >&2
41+
echo >&2
42+
echo "$usage" >&2
43+
exit 2
44+
}
45+
[[ "$options" == *"--name"* ]] || err 'Missing argument `--name`'
46+
[[ "$options" == *"--target"* ]] || err 'Missing argument `--target`'
47+
[[ "$options" == *"--march"* ]] || err 'Missing argument `--march`'
48+
[[ "$options" == *"--mabi"* ]] || err 'Missing argument `--mabi`'
49+
[[ "$options" == *"--mcmodel"* ]] || err 'Missing argument `--mcmodel`'
50+
51+
build_type=Release
52+
53+
eval set -- "$options"
54+
while true; do
55+
case "$1" in
56+
-h,--help) echo "$usage" && exit 0;;
57+
--name) toolchain_name="$2"; shift 2;;
58+
--target) toolchain_target="$2"; shift 2;;
59+
--march) march="$2"; shift 2;;
60+
--mabi) mabi="$2"; shift 2;;
61+
--mcmodel) mcmodel="$2"; shift 2;;
62+
--debug) build_type=Debug; shift 1;;
63+
--) shift; break;;
64+
esac
65+
done
66+
67+
set -x
4468

4569
# For *_VERSION variables
4670
# shellcheck source=sw-versions.sh
@@ -166,7 +190,7 @@ Crosstool-ng version:
166190
(git: ${CROSSTOOL_NG_URL} ${CROSSTOOL_NG_VERSION})
167191
168192
C Flags:
169-
-march=${march} -mabi=${mabi} -mcmodel=${mcmodel} ${toolchain_cflags[@]}
193+
-march=${march} -mabi=${mabi} -mcmodel=${mcmodel}
170194
171195
Built at ${build_date} on $(hostname)
172196
BUILDINFO

contrib/build-opentitan-dist.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ set -ex
55
./build-binutils.sh "riscv32"
66

77
./build-clang-with-args.sh \
8-
"lowrisc-toolchain-rv32imcb" \
9-
"Release" \
10-
"riscv32-unknown-elf" \
11-
"rv32imc_zba_zbb_zbc_zbs" \
12-
"ilp32" \
13-
"medany"
8+
--name "lowrisc-toolchain-rv32imcb" \
9+
--target "riscv32-unknown-elf" \
10+
--march "rv32imc_zba_zbb_zbc_zbs" \
11+
--mabi "ilp32" \
12+
--mcmodel "medany"
1413

1514
./create-prefixed-archive.sh \
1615
"lowrisc-toolchain-rv32imcb" \

0 commit comments

Comments
 (0)