Skip to content

Commit 14adde4

Browse files
jwnrtluismarques
authored andcommitted
Pin build and dist directories
1 parent dccfbc8 commit 14adde4

File tree

4 files changed

+41
-45
lines changed

4 files changed

+41
-45
lines changed

.github/workflows/toolchain_build.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ jobs:
2727
- name: rv32imcb
2828
display_name: RV32IMCB toolchains (Ibex)
2929
target: riscv32-unknown-elf
30-
output_dir: /tools/riscv
3130
march: rv32imc_zba_zbb_zbc_zbs
3231
mabi: ilp32
3332
mcmodel: medany
3433
- name: rv64imac
3534
display_name: RV64IMAC toolchains (Muntjac)
3635
target: riscv64-unknown-elf
37-
output_dir: /tools/riscv
3836
march: rv64imac
3937
mabi: lp64
4038
mcmodel: medany
@@ -74,17 +72,14 @@ jobs:
7472
7573
- name: Build Binutils
7674
run: |
77-
./build-binutils.sh \
78-
"${{ matrix.target }}" \
79-
"${{ matrix.output_dir }}"
75+
./build-binutils.sh "${{ matrix.target }}"
8076
8177
- name: Build Clang toolchain
8278
run: |
8379
./build-clang-with-args.sh \
8480
"lowrisc-toolchain-${{ matrix.name }}" \
8581
Release \
8682
"${{ matrix.target }}" \
87-
"${{ matrix.output_dir }}" \
8883
"${{ matrix.march }}" \
8984
"${{ matrix.mabi}}" \
9085
"${{ matrix.mcmodel }}" \
@@ -94,7 +89,6 @@ jobs:
9489
run: |
9590
./create-prefixed-archive.sh \
9691
"lowrisc-toolchain-${{ matrix.name }}-${HOST_ARCH}-${RELEASE_TAG}" \
97-
"${{ matrix.output_dir }}" \
9892
"${ARTIFACT_STAGING_DIR}"
9993
10094
- uses: actions/upload-artifact@v4

build-binutils.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ set -e -o pipefail
1616
repo_dir="$(git rev-parse --show-toplevel)"
1717
build_dir="${repo_dir}/build"
1818
patch_dir="${repo_dir}/patches"
19+
dist_dir="${build_dir}/dist"
1920

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

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
23+
if [ "$#" -ne 1 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
24+
echo "USAGE: $0 <target>" >&2
25+
echo >&2
26+
echo "EXAMPLE:" >&2
27+
echo " $0 riscv32" >&2
2728
exit 1
2829
fi
2930

@@ -40,9 +41,6 @@ fi
4041

4142
set -x
4243

43-
dist_dir="$(realpath "$2")"
44-
mkdir -p "$dist_dir"
45-
4644
mkdir -p "$build_dir"
4745
cd "$build_dir"
4846

@@ -60,6 +58,8 @@ git apply "${patch_dir}/binutils/"*
6058
mkdir -p build
6159
cd build
6260

61+
mkdir -p "$dist_dir"
62+
6363
# NOTE: We don't want to require `libexpat` to be dynamically linked.
6464
# It turns out to be quite hard to statically link *only* `libexpat`.
6565
../configure \

build-clang-with-args.sh

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,36 @@ if ! [ "$#" -ge 3 ]; then
2222
exit 2
2323
fi;
2424

25+
repo_dir="$(git rev-parse --show-toplevel)"
26+
build_dir="${repo_dir}/build"
27+
dist_dir="${build_dir}/dist"
28+
2529
## Take configuration from arguments
2630
# This is the name for the tar file.
2731
toolchain_name="${1}"
2832
# This is the CMake build type (e.g. Release, Debug, RelWithDebInfo)
2933
build_type="${2}"
3034
# This is the expected target triple (so we can set a default)
3135
toolchain_target="${3}"
32-
# This is the directory where we want the toolchain to added to
33-
toolchain_dest="${4}"
3436
# -march option default value
35-
march="${5}"
37+
march="${4}"
3638
# -mabi option default value
37-
mabi="${6}"
39+
mabi="${5}"
3840
# -mcmodel option default value
39-
mcmodel="${7}"
41+
mcmodel="${6}"
4042
# Remaining cflags for build configurations
41-
toolchain_cflags=("${@:8}")
42-
43-
build_top_dir="${PWD}"
43+
toolchain_cflags=("${@:7}")
4444

4545
# For *_VERSION variables
4646
# shellcheck source=sw-versions.sh
47-
source "${build_top_dir}/sw-versions.sh"
47+
source "${repo_dir}/sw-versions.sh"
4848

4949
tag_name="${RELEASE_TAG:-HEAD}"
5050

51-
mkdir -p "${build_top_dir}/build"
52-
cd "${build_top_dir}/build"
53-
51+
mkdir -p "$build_dir"
52+
cd "$build_dir"
5453

55-
llvm_dir="${build_top_dir}/build/llvm-project"
54+
llvm_dir="${build_dir}/llvm-project"
5655
if [ ! -d "$llvm_dir" ]; then
5756
git clone "$LLVM_URL" "$llvm_dir" \
5857
--branch "$LLVM_BRANCH" \
@@ -69,7 +68,7 @@ clang_links_to_create+=";${toolchain_target}-clang;${toolchain_target}-clang++"
6968
lld_links_to_create="ld.lld;ld64.lld"
7069
lld_links_to_create+=";${toolchain_target}-ld.lld;${toolchain_target}-ld64.lld"
7170

72-
llvm_build_dir="${build_top_dir}/build/llvm-build"
71+
llvm_build_dir="${build_dir}/llvm-project/build"
7372

7473
# Delete old build artifacts (if they exist)
7574
rm -rf "${llvm_build_dir}"
@@ -109,7 +108,7 @@ llvm_distribution_components+=";${llvm_tools}"
109108
cmake "${llvm_dir}/llvm" \
110109
-Wno-dev \
111110
-DCMAKE_BUILD_TYPE="${build_type}" \
112-
-DCMAKE_INSTALL_PREFIX="${toolchain_dest}" \
111+
-DCMAKE_INSTALL_PREFIX="${dist_dir}" \
113112
-DLLVM_TARGETS_TO_BUILD="RISCV" \
114113
-DLLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra" \
115114
-DLLVM_ENABLE_BACKTRACES=Off \
@@ -130,22 +129,22 @@ cmake --build "${llvm_build_dir}" \
130129
--parallel $(( $(nproc) + 2 )) \
131130
--target install-distribution
132131

133-
cd "${build_top_dir}"
132+
cd "${repo_dir}"
134133

135134
# Copy LLVM licenses into toolchain
136-
mkdir -p "${toolchain_dest}/share/licenses/llvm"
137-
cp "${llvm_dir}/llvm/LICENSE.TXT" "${toolchain_dest}/share/licenses/llvm"
135+
mkdir -p "${dist_dir}/share/licenses/llvm"
136+
cp "${llvm_dir}/llvm/LICENSE.TXT" "${dist_dir}/share/licenses/llvm"
138137

139-
ls -l "${toolchain_dest}"
138+
ls -l "${dist_dir}"
140139

141140
# Write out build info
142141
set +o pipefail # head causes pipe failures, so we have to switch off pipefail while we use it.
143142
ct_ng_version_string="$( (set +o pipefail; ct-ng version | head -n1) )"
144-
clang_version_string="$("${toolchain_dest}/bin/clang" --version | head -n1)"
143+
clang_version_string="$("${dist_dir}/bin/clang" --version | head -n1)"
145144
build_date="$(date -u)"
146145
set -o pipefail
147146

148-
tee "${toolchain_dest}/buildinfo" <<BUILDINFO
147+
tee "${dist_dir}/buildinfo" <<BUILDINFO
149148
Report toolchain bugs to [email protected] (include this file)
150149
151150
lowRISC toolchain config: ${toolchain_name}
@@ -165,7 +164,7 @@ C Flags:
165164
Built at ${build_date} on $(hostname)
166165
BUILDINFO
167166

168-
tee "${toolchain_dest}/buildinfo.json" <<BUILDINFO_JSON
167+
tee "${dist_dir}/buildinfo.json" <<BUILDINFO_JSON
169168
{
170169
"toolchain_config": "${toolchain_name}",
171170
"kind": "combined",

create-prefixed-archive.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ set -e
1212
set -x
1313
set -o pipefail
1414

15-
if ! [ "$#" = 3 ]; then
16-
echo "Usage: $0 <toolchain_name> <toolchain_dest> <artifact_dir>"
15+
if ! [ "$#" = 2 ]; then
16+
echo "Usage: $0 <toolchain_name> <artifact_dir>"
1717
exit 2
1818
fi;
1919

20+
repo_dir="$(git rev-parse --show-toplevel)"
21+
build_dir="${repo_dir}/build"
22+
dist_dir="${build_dir}/dist"
23+
2024
# These arguments are provided by `./build-*-with-args.sh`
2125
toolchain_full_name="$1"
22-
toolchain_dest="$2"
23-
artifact_dir="${3:-.}"
26+
artifact_dir="${2:-.}"
2427

2528
tar -cJ \
2629
--show-transformed-names --verbose \
27-
--directory="$(dirname "${toolchain_dest}")" \
28-
-f "${artifact_dir}/$toolchain_full_name.tar.xz" \
29-
--transform="flags=rhS;s@^$(basename "${toolchain_dest}")@$toolchain_full_name@" \
30+
--directory="$(dirname "$dist_dir")" \
31+
-f "${artifact_dir}/${toolchain_full_name}.tar.xz" \
32+
--transform="flags=rhS;s@^$(basename "$dist_dir")@${toolchain_full_name}@" \
3033
--owner=0 --group=0 \
31-
"$(basename "${toolchain_dest}")"
34+
"$(basename "$dist_dir")"

0 commit comments

Comments
 (0)