-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add missing deps for crossbuilder (#2823)
- Loading branch information
Showing
9 changed files
with
210 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,25 +8,31 @@ MAINTAINER [email protected] | |
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get -qq update && apt-get -qq install -y \ | ||
software-properties-common \ | ||
unzip \ | ||
autoconf \ | ||
automake \ | ||
clang \ | ||
gcc \ | ||
gcc-aarch64-linux-gnu \ | ||
git \ | ||
libtool \ | ||
llvm-dev \ | ||
lzma-dev \ | ||
mingw-w64 \ | ||
mercurial \ | ||
make \ | ||
ruby \ | ||
ruby-dev \ | ||
rpm \ | ||
zip \ | ||
pkg-config \ | ||
python \ | ||
python-setuptools \ | ||
python3 \ | ||
python3-setuptools \ | ||
python3-boto \ | ||
autoconf \ | ||
automake \ | ||
libtool \ | ||
ruby \ | ||
ruby-dev \ | ||
rpm \ | ||
software-properties-common \ | ||
unzip \ | ||
wget \ | ||
git \ | ||
pkg-config | ||
zip | ||
|
||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10 | ||
|
||
|
@@ -54,7 +60,7 @@ ENV PATH $GOPATH/bin:$PATH | |
# | ||
# src: https://github.com/influxdata/edge/blob/4677c285014ac27727e5a1ae9bf2c1633afc6ea6/dockerfiles/cross-builder/install-rust.sh#L7 | ||
# | ||
ENV RUST_LATEST_VERSION=1.78.0 | ||
ENV RUST_LATEST_VERSION=1.63.0 | ||
# For security, we specify a particular rustup version and a SHA256 hash, computed | ||
# ourselves and hardcoded here. When updating `RUSTUP_LATEST_VERSION`: | ||
# 1. Download the new rustup script from https://github.com/rust-lang/rustup/releases. | ||
|
@@ -78,6 +84,58 @@ RUN . $HOME/.cargo/env && rustup target add \ | |
x86_64-unknown-linux-musl | ||
ENV PATH=/root/.cargo/bin:${PATH} | ||
|
||
# | ||
# src: https://github.com/influxdata/edge/blob/4677c285014ac27727e5a1ae9bf2c1633afc6ea6/dockerfiles/cross-builder/Dockerfile#L53 | ||
# | ||
COPY fs/ / | ||
|
||
RUN git clone git://git.musl-libc.org/musl /tmp/musl \ | ||
--branch v1.2.3 --depth 1 | ||
|
||
# Enable "-static-pie" Compiler Flag | ||
RUN patch /tmp/musl/tools/musl-gcc.specs.sh \ | ||
/usr/local/src/musl-gcc/musl-gcc.specs.sh.patch | ||
|
||
# | ||
# Build MUSL AMD64 Compiler | ||
# | ||
# src: https://github.com/influxdata/edge/blob/4677c285014ac27727e5a1ae9bf2c1633afc6ea6/dockerfiles/cross-builder/Dockerfile#L62 | ||
# | ||
RUN cd /tmp/musl && \ | ||
export CC=gcc && \ | ||
export AR=ar && \ | ||
export RANLIB=ranlib && \ | ||
./configure \ | ||
--enable-wrapper=gcc \ | ||
--prefix=/musl/x86_64 \ | ||
--target=x86_64-linux-musl && \ | ||
make -j"$(nprocs)" install && \ | ||
make clean | ||
# BUILD MUSL ARM64 Compiler | ||
RUN cd /tmp/musl && \ | ||
export CC=aarch64-linux-gnu-gcc && \ | ||
export AR=aarch64-linux-gnu-ar && \ | ||
export RANLIB=aarch64-linux-gnu-ranlib && \ | ||
./configure \ | ||
--enable-wrapper=gcc \ | ||
--prefix=/musl/aarch64 \ | ||
--target=aarch64-linux-musl && \ | ||
make -j"$(nprocs)" install && \ | ||
make clean | ||
|
||
# | ||
# Install osxcross | ||
# | ||
# src: https://github.com/influxdata/edge/blob/cb1343dd74ecba8ec07fe810195530a0b9055aa9/dockerfiles/cross-builder/Dockerfile#L85 | ||
# | ||
ENV OSXCROSS_VERSION=5771a847950abefed9a37e2d16ee10e0dd90c641 | ||
ENV OSXCROSS_BUILD_TIME=20220412215428 | ||
RUN OSXCROSS_ARCHIVE=osxcross-${OSXCROSS_VERSION}-${OSXCROSS_BUILD_TIME}.tar.gz && \ | ||
wget https://edge-xcc-archives.s3-us-west-2.amazonaws.com/${OSXCROSS_ARCHIVE} && \ | ||
tar xzf ${OSXCROSS_ARCHIVE} -C /usr/local && \ | ||
rm ${OSXCROSS_ARCHIVE} | ||
ENV PATH=/usr/local/osxcross/target/bin:${PATH} | ||
|
||
# | ||
# Install protobuf3 runtime and protoc binary | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Eventually rust might support cross compilation out of the box, but until then | ||
# we have to tell it which external linker to use: | ||
# https://rust-lang.github.io/rustup/cross-compilation.html | ||
[target.x86_64-apple-darwin] | ||
linker = "x86_64-apple-darwin18-clang" | ||
ar = "x86_64-apple-darwin18-ar" | ||
|
||
[target.x86_64-pc-windows-gnu] | ||
linker = "x86_64-w64-mingw32-gcc" | ||
|
||
[target.aarch64-unknown-linux-musl] | ||
linker = "/musl/aarch64/bin/musl-gcc" | ||
|
||
[target.x86_64-unknown-linux-musl] | ||
linker = "/musl/x86_64/bin/musl-gcc" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
function main () { | ||
if [[ $# != 1 ]]; then | ||
>&2 echo Usage: $0 '<build-type>' | ||
>&2 echo "Valid build types are 'release', 'nightly', and 'snapshot'" | ||
exit 1 | ||
fi | ||
local -r build_type=$1 | ||
|
||
local version | ||
case "$build_type" in | ||
release) | ||
if [ -n "$CIRCLE_TAG" ]; then | ||
version="$CIRCLE_TAG" | ||
else | ||
version=$(git describe --tags --abbrev=0 --exact-match) | ||
fi | ||
;; | ||
nightly) | ||
version=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.0)+nightly.$(date +%Y.%m.%d) | ||
;; | ||
snapshot) | ||
version=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.0)+SNAPSHOT.$(git rev-parse --short HEAD) | ||
;; | ||
*) | ||
>&2 echo "Error: unknown build type '$build_type'" | ||
>&2 echo "Valid build types are 'release', 'nightly', and 'snapshot'" | ||
;; | ||
esac | ||
if [ -z "$version" ]; then | ||
>&2 echo "Error: couldn't compute version for build type '$build_type'" | ||
exit 1 | ||
fi | ||
|
||
echo "$version" | ||
} | ||
|
||
main ${@} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
tmpdir=$(mktemp -d) | ||
trap "{ rm -rf ${tmpdir}; }" EXIT | ||
|
||
# "go build" can be noisy, and when Go invokes pkg-config (by calling this script) it will merge stdout and stderr. | ||
# Discard any output unless "go build" terminates with an error. | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ${tmpdir}/pkg-config github.com/influxdata/pkg-config &> ${tmpdir}/go_build_output | ||
if [ "$?" -ne 0 ]; then | ||
cat ${tmpdir}/go_build_output 1>&2 | ||
exit 1 | ||
fi | ||
|
||
${tmpdir}/pkg-config "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
set -o errexit \ | ||
-o nounset \ | ||
-o pipefail | ||
|
||
# ${1} -> platform | ||
# ${2} -> architecture | ||
|
||
case "${1:-}" in | ||
linux) | ||
case "${2:-}" in | ||
x86_64) | ||
printf '/musl/x86_64/bin/musl-gcc\n' | ||
exit 0 | ||
;; | ||
aarch64) | ||
printf '/musl/aarch64/bin/musl-gcc\n' | ||
exit 0 | ||
;; | ||
esac | ||
;; | ||
darwin) | ||
printf 'x86_64-apple-darwin18-clang\n' | ||
exit 0 | ||
;; | ||
windows) | ||
printf 'x86_64-w64-mingw32-gcc\n' | ||
exit 0 | ||
;; | ||
esac | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
This patch was sourced from NVIDIA: | ||
https://github.com/NVIDIA/enroot/blob/07b2288997a89f0278d049ece3ea3d4323a71abc/deps/musl.patch | ||
|
||
index 30492574..7206cb25 100644 | ||
--- a/tools/musl-gcc.specs.sh | ||
+++ b/tools/musl-gcc.specs.sh | ||
@@ -17,13 +17,13 @@ cat <<EOF | ||
libgcc.a%s %:if-exists(libgcc_eh.a%s) | ||
|
||
*startfile: | ||
-%{!shared: $libdir/Scrt1.o} $libdir/crti.o crtbeginS.o%s | ||
+%{static-pie: $libdir/rcrt1.o} %{!static-pie: %{!shared: $libdir/Scrt1.o}} $libdir/crti.o crtbeginS.o%s | ||
|
||
*endfile: | ||
crtendS.o%s $libdir/crtn.o | ||
|
||
*link: | ||
--dynamic-linker $ldso -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic} | ||
+%{static-pie:-no-dynamic-linker -static -pie} %{!static-pie:-dynamic-linker $ldso} -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic} | ||
|
||
*esp_link: |