Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add gcc and binutils packages #60

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aee1351
add compiler.tar.gz for osx and linux using cmake 3.9.5
cosmicexplorer Feb 27, 2018
215c1de
refactor packaging to use common function for macos and linux
cosmicexplorer Feb 27, 2018
bcb3062
...osx find doesn't support '+' in -exec
cosmicexplorer Feb 27, 2018
ad67ff4
change package name to clang
cosmicexplorer Feb 28, 2018
7911496
run make with one job due to race conditions
cosmicexplorer Feb 28, 2018
7753893
add comment describing the include/ subdir
cosmicexplorer Feb 28, 2018
423efa4
refactor to add c++ stdlib
cosmicexplorer Mar 1, 2018
e168d63
add linux-only linker packaging script
cosmicexplorer Mar 12, 2018
e63816a
add binutils
cosmicexplorer Mar 13, 2018
4dbe79f
add gcc package script
cosmicexplorer Mar 16, 2018
31b436a
add binaries (REBASED: NO MORE BIG BINARIES HERE)
cosmicexplorer Mar 16, 2018
d45d02a
make gcc script executable
cosmicexplorer Mar 20, 2018
1852bee
update gcc
cosmicexplorer Mar 21, 2018
aaa7eab
make a small update to the gcc packaging script
cosmicexplorer Mar 21, 2018
9b016be
finish recovering a ton of work i lost
cosmicexplorer Mar 21, 2018
a5b67e8
minor comment tweaks
cosmicexplorer Mar 21, 2018
9bf404d
Add buildozer 0.6.0-80c7f0d45d7e40fa1f7362852697d4a03df557b3 (#56)
illicitonion Feb 27, 2018
1598e82
Synchronize docker instructions with pantsbuild/pants. (#58)
Feb 28, 2018
f0ab05c
Add clang (#57)
cosmicexplorer Mar 1, 2018
3a2d27d
tone down the verbosity because i think it's making the build slower
cosmicexplorer Mar 21, 2018
bbc3ae3
made a few docs updates
cosmicexplorer Mar 21, 2018
a7aad2b
gotta figure out why github is telling me the files i had already upl…
cosmicexplorer Mar 21, 2018
662f917
osx gcc doesn't have a libexec dir........
cosmicexplorer Mar 21, 2018
10e4d82
try revamping the toolchain generation for maintainability
cosmicexplorer Mar 23, 2018
5bffa44
change how we generate gzipped packages
cosmicexplorer Mar 23, 2018
c3b9f0a
make populate-native-toolchain.sh work
cosmicexplorer Mar 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ linux
Requires [docker](https://www.docker.com/)

+ Change directories to the root of this repository.
+ `docker run -v "$(pwd):/pantsbuild-binaries" -rm -it --entrypoint /bin/bash python:2.7.13-wheezy && cd /pantsbuild-binaries` to pop yourself in a controlled image back at this repo's root
+ `docker run -v "$(pwd):/pantsbuild-binaries" --rm -it --entrypoint /bin/bash pantsbuild/centos6:latest && cd /pantsbuild-binaries` to pop yourself in a controlled image back at this repo's root
+ Run the build-\*.sh script corresponding to the binary you wish to build
+ Manually move the binary from the build tree to its home in build-support/...

Expand Down
55 changes: 55 additions & 0 deletions build-binutils.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

source ./utils.bash

set_strict_mode

function fetch_extract_binutils_source_release {
local -r extracted_dirname="binutils-${BINUTILS_VERSION}"
local -r archive_filename="${extracted_dirname}.tar.xz"
local -r release_url="https://ftpmirror.gnu.org/binutils/${archive_filename}"

local -r downloaded_archive="$(curl_file_with_fail "$release_url" "$archive_filename")"
extract_for "$downloaded_archive" "$extracted_dirname"
}

function build_binutils_with_configure {
local -a configure_cmd_line=("$@")

"${configure_cmd_line[@]}"

make "-j${MAKE_JOBS}"

make install
}

function build_linux {
local -r source_extracted_abs="$(fetch_extract_binutils_source_release)"

local -r build_dir_abs="$(mkdirp_absolute_path 'binutils-build')"
local -r install_dir_abs="$(mkdirp_absolute_path 'binutils-install')"

with_pushd >&2 "$build_dir_abs" \
build_binutils_with_configure \
"${source_extracted_abs}/configure" \
--prefix="$install_dir_abs"

with_pushd "$install_dir_abs" \
create_gz_package 'binutils' bin
}

## Interpret arguments and execute build.

readonly TARGET_PLATFORM="$1" BINUTILS_VERSION="$2"

MAKE_JOBS="${MAKE_JOBS:-2}"

case "$TARGET_PLATFORM" in
linux)
with_pushd "$(mkdirp_absolute_path "binutils-${BINUTILS_VERSION}-linux")" \
build_linux
;;
*)
die "binutils doesnot support building for '${TARGET_PLATFORM}'"
;;
esac
121 changes: 121 additions & 0 deletions build-clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/bin/bash

source ./utils.bash

set_strict_mode

## Build for OSX from LLVM's binary release package.

function build_osx {

local -r normal_release_dirname="clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin"
# The top-level directory in the release archive is not always the same across
# releases. The `-final-` part may be to signify that this is the last release
# of that major version.
local -r final_release_dirname="clang+llvm-${LLVM_VERSION}-final-x86_64-apple-darwin"

local -r archive_filename="${normal_release_dirname}.tar.xz"
local -r release_url="https://releases.llvm.org/${LLVM_VERSION}/${archive_filename}"

local -r downloaded_archive="$(curl_file_with_fail "$release_url" "$archive_filename")"
local -r extracted_dir="$(extract_for "$downloaded_archive" "$normal_release_dirname" "$final_release_dirname")"

with_pushd "$extracted_dir" \
create_gz_package 'clang'
}


## Build for Linux from LLVM's multi-part source release packages.

function fetch_extract_llvm_source_release {
local -r extracted_dirname="$1"

local -r archive_filename="${extracted_dirname}.tar.xz"
local -r release_url="https://releases.llvm.org/${LLVM_VERSION}/${archive_filename}"

local -r downloaded_archive="$(curl_file_with_fail "$release_url" "$archive_filename")"
extract_for "$downloaded_archive" "$extracted_dirname"
}

function build_llvm_with_cmake {
local -r cmake_exe="$1" install_dir="$2" cfe_dir="$3" llvm_dir="$4"

# This didn't immediately compile right off the bat -- I'd recommend to anyone
# watching that Homebrew formulas are good places to learn about how to provide
# high-quality toolchains on OSX. I found https://llvm.org/docs/CMake.html
# "helpful" for this line as well.
"$cmake_exe" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$install_dir_abs" \
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR="$cfe_dir" \
-DLLVM_EXTERNAL_PROJECTS='clang' \
-DLLVM_TARGETS_TO_BUILD='X86' \
-DBACKEND_PACKAGE_STRING="Pants-packaged LLVM for ${TARGET_PLATFORM}, version ${LLVM_VERSION}" \
"$llvm_dir"

# NB: There appear to be race conditions when running make with any
# parallelism here in a Docker image.
make "-j${MAKE_JOBS}"

make install
}

function build_linux {
local -r cmake_exe="$1"

# Properties of the downloaded release tarball.
local -r llvm_src_dirname="llvm-${LLVM_VERSION}.src"
local -r cfe_src_dirname="cfe-${LLVM_VERSION}.src"

# Set up an out-of-tree build and install
local -r build_dir_abs="$(mkdirp_absolute_path 'clang-llvm-build')"
local -r install_dir_abs="$(mkdirp_absolute_path 'clang-llvm-install')"

# LLVM requires you to download the source for LLVM and the Clang frontend
# separately. One alternative is checking out their SVN repo, but that takes
# much longer.
local -r llvm_src_extracted_abs="$(fetch_extract_llvm_source_release "$llvm_src_dirname")"
local -r cfe_src_extracted_abs="$(fetch_extract_llvm_source_release "$cfe_src_dirname")"

with_pushd >&2 "$build_dir_abs" \
build_llvm_with_cmake "$cmake_exe" "$install_dir_abs" "$cfe_src_extracted_abs" "$llvm_src_extracted_abs"

with_pushd "$install_dir_abs" \
create_gz_package 'clang'
}

function validate_cmake {
if [[ ! -f "$CMAKE_EXE" ]]; then
die_here <<EOF
To build clang for Linux, the environment variable \$CMAKE_EXE=${CMAKE_EXE} must
be an absolute path to a 'cmake' binary that is executable on the current host.
EOF
fi
echo "$CMAKE_EXE"
}


## Interpret arguments and execute build.

# $1 =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete?

# $2 =
# $CMAKE_EXE =
# $MAKE_JOBS =

readonly TARGET_PLATFORM="$1" LLVM_VERSION="$2"

readonly MAKE_JOBS="${MAKE_JOBS:-2}"

case "$TARGET_PLATFORM" in
osx)
with_pushd "$(mkdirp_absolute_path "clang-llvm-${LLVM_VERSION}-osx-binary")" \
build_osx
;;
linux)
with_pushd "$(mkdirp_absolute_path "clang-llvm-${LLVM_VERSION}-linux")" \
build_linux "$(validate_cmake)"
;;
*)
die "clang does not support building for '${TARGET_PLATFORM}'"
;;
esac
2 changes: 1 addition & 1 deletion build-cmake-3.9.5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ for rev in "10.8" "10.9" "10.10" "10.11" "10.12" "10.13"; do
DEST_BASE="build-support/bin/cmake/mac/${rev}"
mkdir -p "${DEST_BASE}"
pushd "${DEST_BASE}" > /dev/null
ln -s "../10.7/3.9.5" "3.9.5"
ln -sf "../10.7/3.9.5" "3.9.5"
popd > /dev/null
done
67 changes: 67 additions & 0 deletions build-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

source ./utils.bash

set_strict_mode

readonly CMAKE_VERSION_PATTERN='^([0-9]+\.[0-9]+)\.[0-9]+$'

function extract_minor_version {
local -r version_string="$1"

echo "$version_string" | sed -re "s#${CMAKE_VERSION_PATTERN}#\\1#g"
}

function fetch_extract_cmake_binary_release {
local -r extracted_dirname="$1"

local -r cmake_minor_version="$(extract_minor_version "$CMAKE_VERSION")"

local -r archive_filename="${extracted_dirname}.tar.gz"
local -r release_url="https://cmake.org/files/v${cmake_minor_version}/${archive_filename}"

local -r downloaded_archive="$(curl_file_with_fail "$release_url" "$archive_filename")"
extract_for "$downloaded_archive" "$extracted_dirname"
}

function package_cmake {
local -r installed_dir_abs="$1"

with_pushd "$installed_dir_abs" \
create_gz_package 'cmake' bin share
}

function build_osx {
local -r cmake_platform_description="cmake-${CMAKE_VERSION}-Darwin-x86_64"

local -r extracted_dir="$(fetch_extract_cmake_binary_release "$cmake_platform_description")"

package_cmake "${extracted_dir}/CMake.app/Contents"
}

function build_linux {
local -r cmake_platform_description="cmake-${CMAKE_VERSION}-Linux-x86_64"

local -r extracted_dir="$(fetch_extract_cmake_binary_release "$cmake_platform_description")"

package_cmake "$extracted_dir"
}


## Interpret arguments and execute build.

readonly TARGET_PLATFORM="$1" CMAKE_VERSION="$2"

case "$TARGET_PLATFORM" in
osx)
with_pushd "$(mkdirp_absolute_path "cmake-${CMAKE_VERSION}-osx")" \
build_osx
;;
linux)
with_pushd "$(mkdirp_absolute_path "cmake-${CMAKE_VERSION}-linux")" \
build_linux
;;
*)
die "cmake does not support building for '${TARGET_PLATFORM}'"
;;
esac
88 changes: 88 additions & 0 deletions build-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/bash

source ./utils.bash

set_strict_mode

function fetch_extract_gcc_source_release {
local -r extracted_dirname="gcc-${GCC_VERSION}"
local -r archive_filename="${extracted_dirname}.tar.gz"
local -r release_url="https://ftpmirror.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/${archive_filename}"

local -r downloaded_archive="$(curl_file_with_fail "$release_url" "$archive_filename")"
extract_for "$downloaded_archive" "$extracted_dirname"
}

function build_gcc_with_configure {
local -a configure_cmd_line=("$@")

"${configure_cmd_line[@]}"

make "-j${MAKE_JOBS}"

make install
}

function build_gcc_out_of_tree {
local -a configure_args=("$@")

local -r source_extracted_abs="$(fetch_extract_gcc_source_release)"

with_pushd >&2 "$source_extracted_abs" \
./contrib/download_prerequisites

local -r build_dir_abs="$(mkdirp_absolute_path 'gcc-build')"
local -r install_dir_abs="$(mkdirp_absolute_path 'gcc-install')"

with_pushd >&2 "$build_dir_abs" \
build_gcc_with_configure \
"${source_extracted_abs}/configure" \
--prefix="$install_dir_abs" \
"${configure_args[@]}"

with_pushd "$install_dir_abs" \
create_gz_package 'gcc'
}

function build_osx {
build_gcc_out_of_tree \
--host='x86_64-apple-darwin' \
--target='x86_64-apple-darwin' \
AR="$(which ar)" \
"${CONFIGURE_BASE_ARGS[@]}"
}

function build_linux {
build_gcc_out_of_tree \
"${CONFIGURE_BASE_ARGS[@]}"
}

## Interpret arguments and execute build.

readonly TARGET_PLATFORM="$1" GCC_VERSION="$2"

readonly MAKE_JOBS="${MAKE_JOBS:-2}"

readonly SUPPORTED_LANGS='c,c++,objc,obj-c++,fortran'

readonly -a CONFIGURE_BASE_ARGS=(
--disable-multilib
--enable-languages="${SUPPORTED_LANGS}"
--enable-checking='release'
--with-pkgversion="Pants-packaged GCC (${GCC_VERSION})"
--with-bugurl='https://github.com/pantsbuild/pants/issues'
)

case "$TARGET_PLATFORM" in
osx)
with_pushd "$(mkdirp_absolute_path "gcc-${GCC_VERSION}-osx")" \
build_osx
;;
linux)
with_pushd "$(mkdirp_absolute_path "gcc-${GCC_VERSION}-linux")" \
build_linux
;;
*)
die "gcc does not support building for '${TARGET_PLATFORM}'"
;;
esac
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified build-support/bin/cmake/linux/x86_64/3.9.5/cmake.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions build-support/bin/cmake/mac/10.7/3.9.5/3.9.5
Binary file modified build-support/bin/cmake/mac/10.7/3.9.5/cmake.tar.gz
Binary file not shown.
Loading