Skip to content

Commit

Permalink
Improve build speed
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDewes committed Jun 30, 2020
1 parent 7250d47 commit 340090e
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 136 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ matrix:
env:
- TARGET_PLATFORM=ubuntu
- GIT_LFS_CHECKSUM=89f5aa2c29800bbb71f5d4550edd69c5f83e3ee9e30f770446436dd7f4ef1d4c
arch: amd64
- os: osx
language: c
env:
Expand All @@ -56,6 +57,7 @@ matrix:
env:
- TARGET_PLATFORM=arm64
- GIT_LFS_CHECKSUM=ea628d95158d5c76d9c7fe9432f28e49cc1a1b7ae3928b7089b1f4f97748d7a0
arch: arm64
compiler:
- gcc
script:
Expand All @@ -64,6 +66,7 @@ branches:
only:
- master
- /^v[0-9]*.[0-9]*.[0.9]*.*$/
cache: ccache
deploy:
provider: releases
api_key: $GITHUB_TOKEN
Expand Down
31 changes: 0 additions & 31 deletions docker/arm64/Dockerfile

This file was deleted.

52 changes: 0 additions & 52 deletions script/build-arm64-git.sh

This file was deleted.

91 changes: 67 additions & 24 deletions script/build-arm64.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/bin/bash -e
#
# Building Git for ARM64 Linux and bundling Git LFS from upstream.
# Compiling Git for Linux and bundling Git LFS from upstream.
#


if [[ -z "${SOURCE}" ]]; then
echo "Required environment variable SOURCE was not set"
exit 1
Expand All @@ -18,29 +19,48 @@ if [[ -z "${CURL_INSTALL_DIR}" ]]; then
exit 1
fi

if [[ -z "${BASEDIR}" ]]; then
echo "Required environment variable BASEDIR was not set"
exit 1
fi


CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# shellcheck source=script/compute-checksum.sh
source "$CURRENT_DIR/compute-checksum.sh"
# shellcheck source=script/check-static-linking.sh
source "$CURRENT_DIR/check-static-linking.sh"

mkdir -p "$DESTINATION"
# Missing on arm64
sudo apt-get install gettext

echo " -- Building vanilla curl at $CURL_INSTALL_DIR instead of distro-specific version"

docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker run -it \
--mount type=bind,source="$BASEDIR",target="$BASEDIR" \
--mount type=bind,source="$DESTINATION",target="$DESTINATION" \
-e "SOURCE=$SOURCE" \
-e "DESTINATION=$DESTINATION" \
-e "CURL_INSTALL_DIR=$CURL_INSTALL_DIR" \
-w="$BASEDIR" \
--rm shiftkey/dugite-native:arm64-jessie-git-with-curl bash "$BASEDIR/script/build-arm64-git.sh"
CURL_FILE_NAME="curl-7.61.1"
CURL_FILE="$CURL_FILE_NAME.tar.gz"

cd /tmp || exit 1
curl -LO "https://curl.haxx.se/download/$CURL_FILE"
tar -xf $CURL_FILE

(
cd $CURL_FILE_NAME || exit 1
./configure --prefix="$CURL_INSTALL_DIR"
make install -j "$(nproc)"
)
echo " -- Building git at $SOURCE to $DESTINATION"

(
cd "$SOURCE" || exit 1
make clean
make configure
CC='gcc' \
CFLAGS='-Wall -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE' \
LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro' \
./configure \
--with-curl="$CURL_INSTALL_DIR" \
--prefix=/
DESTDIR="$DESTINATION" \
NO_TCLTK=1 \
NO_GETTEXT=1 \
NO_INSTALL_HARDLINKS=1 \
NO_R_TO_GCC_LINKER=1 \
make strip install -j "$(nproc)"
)

if [[ "$GIT_LFS_VERSION" ]]; then
echo "-- Bundling Git LFS"
Expand Down Expand Up @@ -82,13 +102,36 @@ if [[ ! -f "$DESTINATION/ssl/cacert.pem" ]]; then
echo "-- Skipped bundling of CA certificates (failed to download them)"
fi

echo "-- Verifying environment"
docker run -it \
--mount type=bind,source="$BASEDIR",target="$BASEDIR" \
--mount type=bind,source="$DESTINATION",target="$DESTINATION" \
-e "DESTINATION=$DESTINATION" \
-w="$BASEDIR" \
--rm shiftkey/dugite-native:arm64-jessie-git-with-curl sh "$BASEDIR/script/verify-arm64-git.sh"

echo "-- Removing server-side programs"
rm "$DESTINATION/bin/git-cvsserver"
rm "$DESTINATION/bin/git-receive-pack"
rm "$DESTINATION/bin/git-upload-archive"
rm "$DESTINATION/bin/git-upload-pack"
rm "$DESTINATION/bin/git-shell"

echo "-- Removing unsupported features"
rm "$DESTINATION/libexec/git-core/git-svn"
rm "$DESTINATION/libexec/git-core/git-remote-testsvn"
rm "$DESTINATION/libexec/git-core/git-p4"

echo "-- Static linking research"
check_static_linking "$DESTINATION"

echo "-- Testing clone operation with generated binary"

rm -rf "$CURL_OUTPUT_DIR"

TEMP_CLONE_DIR=/tmp/clones
mkdir -p $TEMP_CLONE_DIR

(
cd "$DESTINATION/bin" || exit 1
./git --version
GIT_CURL_VERBOSE=1 \
GIT_TEMPLATE_DIR="$DESTINATION/share/git-core/templates" \
GIT_SSL_CAINFO="$DESTINATION/ssl/cacert.pem" \
GIT_EXEC_PATH="$DESTINATION/libexec/git-core" \
PREFIX="$DESTINATION" \
./git clone https://github.com/git/git.github.io "$TEMP_CLONE_DIR/git.github.io"
)
2 changes: 1 addition & 1 deletion script/build-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ GIT_CURL_VERBOSE=1 \
GIT_EXEC_PATH="$DESTINATION/libexec/git-core" \
PREFIX="$DESTINATION" \
./git clone https://github.com/git/git.github.io "$TEMP_CLONE_DIR/git.github.io"
)
)
3 changes: 3 additions & 0 deletions script/generate-travis-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ function getConfig(platform: string, arch: string) {
os: 'linux',
language: 'c',
env: ['TARGET_PLATFORM=ubuntu', `GIT_LFS_CHECKSUM=${lfsFile.checksum}`],
arch: 'amd64',
}
} else if (arch === 'arm64') {
return {
os: 'linux',
language: 'c',
env: ['TARGET_PLATFORM=arm64', `GIT_LFS_CHECKSUM=${lfsFile.checksum}`],
arch: 'arm64',
}
}
}
Expand Down Expand Up @@ -133,6 +135,7 @@ const baseConfig = {
branches: {
only: ['master', '/^v[0-9]*.[0-9]*.[0.9]*.*$/'],
},
cache: 'ccache',
deploy: {
provider: 'releases',
api_key: '$GITHUB_TOKEN',
Expand Down
28 changes: 0 additions & 28 deletions script/verify-arm64-git.sh

This file was deleted.

0 comments on commit 340090e

Please sign in to comment.