-
Notifications
You must be signed in to change notification settings - Fork 37
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 compiler package script #57
Merged
stuhood
merged 7 commits into
pantsbuild:gh-pages
from
cosmicexplorer:cosmicexplorer/add-compiler-package-script
Mar 1, 2018
Merged
Changes from 3 commits
Commits
Show all changes
7 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 215c1de
refactor packaging to use common function for macos and linux
cosmicexplorer bcb3062
...osx find doesn't support '+' in -exec
cosmicexplorer ad67ff4
change package name to clang
cosmicexplorer 7911496
run make with one job due to race conditions
cosmicexplorer 7753893
add comment describing the include/ subdir
cosmicexplorer f702868
add binary packages
cosmicexplorer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
#!/bin/bash | ||
|
||
if ! hash xz; then | ||
cat >&2 <<EOF | ||
'xz' is required to run this script. You may have to install it using your | ||
operating system's package manager. | ||
EOF | ||
exit 1 | ||
fi | ||
|
||
set -euxo pipefail | ||
|
||
LLVM_VERSION='5.0.1' | ||
CORRESPONDING_CLANG_BIN_VERSION='5.0' | ||
LLVM_RELEASE_BUILD_DIRNAME='llvm-tmp' | ||
LLVM_PANTS_ARCHIVE_NAME='compiler.tar.gz' | ||
COMPILER_SUPPORTDIR='build-support/bin/compiler' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed to |
||
|
||
# default to -j2 | ||
MAKE_JOBS="${MAKE_JOBS:-2}" | ||
|
||
mkdir -p "$LLVM_RELEASE_BUILD_DIRNAME" | ||
|
||
CLANG_BINARIES=( | ||
clang | ||
clang++ | ||
clang-"${CORRESPONDING_CLANG_BIN_VERSION}" | ||
) | ||
|
||
function extract-required-files-from-unpacked-llvm { | ||
local -r unpacked_llvm_dir="$1" | ||
local -r pants_output_archive_name="$2" | ||
|
||
mkdir -p bin/ include/ | ||
|
||
for bin_path in ${CLANG_BINARIES[@]}; do | ||
cp "${unpacked_llvm_dir}/bin/${bin_path}" bin/ | ||
done | ||
|
||
find "$unpacked_llvm_dir"/lib/clang/"$LLVM_VERSION"/include \ | ||
-type f \ | ||
-name '*.h' \ | ||
-exec cp '{}' include/ ';' | ||
|
||
tar czf "$pants_output_archive_name" bin/ include/ | ||
} | ||
|
||
|
||
## MacOS (LLVM-packaged release binaries) | ||
MACOS_REVS=( | ||
10.7 | ||
10.8 | ||
10.9 | ||
10.10 | ||
10.11 | ||
10.12 | ||
10.13 | ||
) | ||
LLVM_TMP_MACOS_PKG_DIR='llvm-macos-pkg' | ||
|
||
pushd "$LLVM_RELEASE_BUILD_DIRNAME" | ||
|
||
curl -L -O "https://releases.llvm.org/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin.tar.xz" | ||
tar xf "clang+llvm-${LLVM_VERSION}-x86_64-apple-darwin.tar.xz" | ||
llvm_macos_bin_release_dir_abs="$(pwd)/clang+llvm-${LLVM_VERSION}-final-x86_64-apple-darwin" | ||
|
||
mkdir -p "$LLVM_TMP_MACOS_PKG_DIR" | ||
pushd "$LLVM_TMP_MACOS_PKG_DIR" | ||
|
||
extract-required-files-from-unpacked-llvm \ | ||
"$llvm_macos_bin_release_dir_abs" \ | ||
"$LLVM_PANTS_ARCHIVE_NAME" | ||
|
||
llvm_macos_packaged_abs="$(pwd)/${LLVM_PANTS_ARCHIVE_NAME}" | ||
popd | ||
|
||
popd | ||
|
||
for rev in ${MACOS_REVS[@]}; do | ||
dest_base="${COMPILER_SUPPORTDIR}/mac/${rev}/${LLVM_VERSION}" | ||
mkdir -p "$dest_base" | ||
cp "$llvm_macos_packaged_abs" "${dest_base}/${LLVM_PANTS_ARCHIVE_NAME}" | ||
done | ||
|
||
|
||
## Linux (from source release) | ||
# We need cmake >= 3.4, so use the one we already build for pants. | ||
CMAKE_VERSION='3.9.5' | ||
CMAKE_BUILD_TMP_DIR='cmake-build-tmp' | ||
LLVM_BUILD_TMP_DIR='llvm-build' | ||
LLVM_TMP_LINUX_PKG_DIR='llvm-linux-pkg' | ||
|
||
"./build-cmake-${CMAKE_VERSION}.sh" | ||
cmake_linux_packaged_abs="$(pwd)/build-support/bin/cmake/linux/x86_64/${CMAKE_VERSION}/cmake.tar.gz" | ||
|
||
mkdir -p "$CMAKE_BUILD_TMP_DIR" | ||
pushd "$CMAKE_BUILD_TMP_DIR" | ||
tar zxf "$cmake_linux_packaged_abs" | ||
cmake_linux_bin_abs="$(pwd)/bin/cmake" | ||
popd | ||
|
||
pushd "$LLVM_RELEASE_BUILD_DIRNAME" | ||
|
||
# LLVM requires you to download the source for LLVM and the Clang frontend | ||
# separately. The alternative is checking out their SVN repo, which takes much | ||
# longer. | ||
curl -L -O "https://releases.llvm.org/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz" | ||
curl -L -O "https://releases.llvm.org/${LLVM_VERSION}/cfe-${LLVM_VERSION}.src.tar.xz" | ||
tar xf "llvm-${LLVM_VERSION}.src.tar.xz" | ||
tar xf "cfe-${LLVM_VERSION}.src.tar.xz" | ||
|
||
mkdir -p "$LLVM_BUILD_TMP_DIR" | ||
pushd "$LLVM_BUILD_TMP_DIR" | ||
|
||
"$cmake_linux_bin_abs" \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR="../cfe-${LLVM_VERSION}.src" \ | ||
-DLLVM_EXTERNAL_PROJECTS='clang' \ | ||
"../llvm-${LLVM_VERSION}.src" | ||
|
||
make -j"$MAKE_JOBS" | ||
|
||
llvm_linux_source_release_dir_abs="$(pwd)" | ||
|
||
popd | ||
|
||
mkdir -p "$LLVM_TMP_LINUX_PKG_DIR" | ||
pushd "$LLVM_TMP_LINUX_PKG_DIR" | ||
|
||
extract-required-files-from-unpacked-llvm \ | ||
"$llvm_linux_source_release_dir_abs" \ | ||
"$LLVM_PANTS_ARCHIVE_NAME" | ||
|
||
llvm_linux_packaged_abs="$(pwd)/${LLVM_PANTS_ARCHIVE_NAME}" | ||
|
||
popd | ||
|
||
popd | ||
|
||
mkdir -p "${COMPILER_SUPPORTDIR}/linux/x86_64/${LLVM_VERSION}" | ||
cp "$llvm_linux_packaged_abs" "${COMPILER_SUPPORTDIR}/linux/x86_64/${LLVM_VERSION}/${LLVM_PANTS_ARCHIVE_NAME}" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler
is too generic a name...clang
, probably?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang
is definitely better thancompiler
, but thinking about it now I might actually suggest to call itclang-llvm
, or evenclang+llvm
, because the LLVM version (5.0.1
) is what's used in the release download url from the LLVM downloads page, not the clang version. Also, the MacOS binary release download unpacks into an archive namedclang+llvm-5.0.1-<platform>.tar.xz
, so calling itclang+llvm
would match that convention. It could beclang-llvm
too, but I preferclang+llvm
because that makes it clear which part ofclang+llvm-5.0.1.tar.gz
is the package name and which part is the version.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you planning to package something in here other than
clang
itself?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the C and C++ standard library headers. The C standard library headers are already included -- I hadn't tested the C++ standard library headers because we don't have a
python_dist()
target with C++ code intestprojects/
yet in the pants repo. These would be provided with the compiler so that they are compatible with the compiler, and so we don't have to rely on headers existing in standard locations (which is a requirement for an internal consumer ofpython_dist()
with native code).I'm not planning to package anything that's not considered part of clang, however. It might make sense to just call it
clang
, by that logic. Since we're not packaging any other LLVM tools, it might be confusing/surprising to call itclang+llvm
.After concentrating on this for a bit, my vote goes to just calling it
clang
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to
build-clang-5.0.1.sh
, producingclang.tar.gz
in supportdirbuild-support/bin/clang
in ad67ff4.