Skip to content

Commit 44b4d33

Browse files
jwnrtluismarques
authored andcommitted
Change Clang args to be named
Signed-off-by: James Wainwright <[email protected]>
1 parent b5d4913 commit 44b4d33

File tree

3 files changed

+57
-35
lines changed

3 files changed

+57
-35
lines changed

.github/workflows/toolchain_build.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,11 @@ jobs:
7777
- name: Build Clang toolchain
7878
run: |
7979
./build-clang-with-args.sh \
80-
"lowrisc-toolchain-${{ matrix.name }}" \
81-
Release \
82-
"${{ matrix.target }}" \
83-
"${{ matrix.march }}" \
84-
"${{ matrix.mabi}}" \
85-
"${{ matrix.mcmodel }}" \
86-
"${{ matrix.cflags }}"
80+
--name "lowrisc-toolchain-${{ matrix.name }}" \
81+
--target "${{ matrix.target }}" \
82+
--march "${{ matrix.march }}" \
83+
--mabi "${{ matrix.mabi}}" \
84+
--mcmodel "${{ matrix.mcmodel }}"
8785
8886
- name: Package toolchains
8987
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
@@ -159,7 +183,7 @@ Crosstool-ng version:
159183
(git: ${CROSSTOOL_NG_URL} ${CROSSTOOL_NG_VERSION})
160184
161185
C Flags:
162-
-march=${march} -mabi=${mabi} -mcmodel=${mcmodel} ${toolchain_cflags[@]}
186+
-march=${march} -mabi=${mabi} -mcmodel=${mcmodel}
163187
164188
Built at ${build_date} on $(hostname)
165189
BUILDINFO

contrib/build-opentitan-dist.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ set -ex
55
./build-binutils.sh "riscv32-unknown-elf"
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" \
13+
"$@"
1414

1515
./create-prefixed-archive.sh \
1616
"lowrisc-toolchain-rv32imcb" \

0 commit comments

Comments
 (0)