Skip to content

Commit 155acf3

Browse files
authored
VAULT-34477: Add s390x multilib compiler to build-vault action (#29837)
Install and configure an s390x C toolchain when building Vault editions that need CGO on s390x. x86_64 and aarch64 need no special handling as it is assumed that those binaries are compiled on runners with matching architecture. Signed-off-by: Ryan Cragun <[email protected]>
1 parent 04bd44b commit 155acf3

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

.github/actions/build-vault/action.yml

+10
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,16 @@ runs:
8787
with:
8888
github-token: ${{ inputs.github-token }}
8989
- uses: ./.github/actions/install-external-tools
90+
- if: inputs.goarch == 's390x' && inputs.vault-edition == 'ent.hsm'
91+
name: Configure CGO compiler for HSM edition on s390x
92+
shell: bash
93+
run: |
94+
sudo apt-get update
95+
sudo apt-get install -y gcc-multilib-s390x-linux-gnu
96+
{
97+
echo "CC=s390x-linux-gnu-gcc"
98+
echo "CC_FOR_TARGET=s390x-linux-gnu-gcc"
99+
} | tee -a "$GITHUB_ENV"
90100
- if: inputs.vault-edition != 'ce'
91101
name: Configure Git
92102
shell: bash

scripts/ci-helper.sh

+19-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# Copyright (c) HashiCorp, Inc.
33
# SPDX-License-Identifier: BUSL-1.1
44

5-
65
# The ci-helper is used to determine build metadata, build Vault binaries,
76
# package those binaries into artifacts, and execute tests with those artifacts.
87

@@ -92,7 +91,14 @@ function build() {
9291
: "${GO_TAGS:=""}"
9392
: "${REMOVE_SYMBOLS:=""}"
9493

95-
(unset GOOS; unset GOARCH; go generate ./...)
94+
# Generate code but make sure we don't slurp in cross compilation env vars
95+
(
96+
unset GOOS
97+
unset GOARCH
98+
unset CC
99+
unset CC_FOR_TARGET
100+
go generate ./...
101+
)
96102

97103
# Build our ldflags
98104
msg="--> Building Vault revision $revision, built $build_date..."
@@ -155,43 +161,43 @@ function prepare_ce_legal() {
155161
# Package version converts a vault version string into a compatible representation for system
156162
# packages.
157163
function version_package() {
158-
awk '{ gsub("-","~",$1); print $1 }' <<< "$VAULT_VERSION"
164+
awk '{ gsub("-","~",$1); print $1 }' <<<"$VAULT_VERSION"
159165
}
160166

161167
# Run the CI Helper
162168
function main() {
163169
case $1 in
164170
artifact-basename)
165171
artifact_basename
166-
;;
172+
;;
167173
build)
168174
build
169-
;;
175+
;;
170176
build-ui)
171177
build_ui
172-
;;
178+
;;
173179
bundle)
174180
bundle
175-
;;
181+
;;
176182
date)
177183
build_date
178-
;;
184+
;;
179185
prepare-ent-legal)
180186
prepare_ent_legal
181-
;;
187+
;;
182188
prepare-ce-legal)
183189
prepare_ce_legal
184-
;;
190+
;;
185191
revision)
186192
build_revision
187-
;;
193+
;;
188194
version-package)
189195
version_package
190-
;;
196+
;;
191197
*)
192198
echo "unknown sub-command" >&2
193199
exit 1
194-
;;
200+
;;
195201
esac
196202
}
197203

0 commit comments

Comments
 (0)