-
Notifications
You must be signed in to change notification settings - Fork 568
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
New: Cling interactive C++ REPL #5937
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
12d2836
Cling is an interactive C++ interpreter,
notinaboat 3d63a4f
try building for other platforms
notinaboat 113b1bc
disable platforms where build failed
notinaboat d85603a
expand_cxxstring_abis(platforms)
notinaboat df1c2e8
Apply suggestions from code review
giordano ad34b33
Update build_tarballs.jl
giordano f69b4eb
Update build_tarballs.jl
giordano 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
# Note that this script can accept some limited command-line arguments, run | ||
# `julia build_tarballs.jl --help` to see a usage message. | ||
using BinaryBuilder, Pkg | ||
|
||
# Cling is an interactive C++ interpreter, | ||
# built on the top of LLVM and Clang libraries. | ||
# https://root.cern/cling | ||
|
||
name = "Cling" | ||
version = v"0.9.0" | ||
|
||
# Collection of sources required to complete build | ||
# Cling requires CERN's patched versions of llvm and clang. | ||
sources = [ | ||
GitSource("http://root.cern/git/llvm.git", | ||
"859a19cc70aba64df3a20f1b91c84b81547bbf24"), # tag: cling-v0.9 | ||
GitSource("http://root.cern/git/clang.git", | ||
"0e0d27eb409f64af84cc6a85c2fb48d2b5ce8122"), # tag: cling-v0.9 | ||
GitSource("http://root.cern/git/cling.git", | ||
"646e3f59550b6a24d81edde5694844a1a8c3fdf4"), # tag: v0.9 | ||
DirectorySource("./bundled"), | ||
] | ||
|
||
# Bash recipe for building across all platforms | ||
# Cling Build Instructions: https://root.cern/cling/cling_build_instructions/ | ||
# Cling Homebrew Formula: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/cling.rb | ||
script = raw""" | ||
cd $WORKSPACE/srcdir | ||
mv llvm/ src | ||
mv clang/ src/tools/ | ||
mv cling/ src/tools/ | ||
|
||
LLVM_SRCDIR=$(pwd)/src | ||
|
||
# Patch to work-around missing clang runtime lib | ||
# (undefined symbol ___isPlatformVersionAtLeast). | ||
# See: https://github.com/JuliaPackaging/Yggdrasil/pull/5937#issuecomment-1334463175 | ||
pushd ${LLVM_SRCDIR} | ||
atomic_patch -p1 ${WORKSPACE}/srcdir/patches/* | ||
popd | ||
|
||
cp src/LICENSE.TXT LICENSE_LLVM.TXT | ||
cp src/tools/clang/LICENSE.TXT LICENSE_CLANG.TXT | ||
cp src/tools/cling/LICENSE.TXT LICENSE_CLING.TXT | ||
install_license LICENSE_LLVM.TXT | ||
install_license LICENSE_CLANG.TXT | ||
install_license LICENSE_CLING.TXT | ||
|
||
# The very first thing we need to do is to build llvm-tblgen for x86_64-linux-muslc | ||
# This is because LLVM's cross-compile setup is kind of borked, so we just | ||
# build the tools natively ourselves, directly. :/ | ||
# See: https://github.com/JuliaPackaging/Yggdrasil/blob/86a4221f71ee8ca5c0fd1056829a1fe2b28c879b/M/Metal_LLVM_Tools/build_tarballs.jl#L35 | ||
|
||
# Build llvm-tblgen and llvm-config | ||
mkdir ${WORKSPACE}/bootstrap | ||
pushd ${WORKSPACE}/bootstrap | ||
CMAKE_FLAGS=() | ||
CMAKE_FLAGS+=(-DLLVM_HOST_TRIPLE=${MACHTYPE}) | ||
CMAKE_FLAGS+=(-DCMAKE_BUILD_TYPE=Release) | ||
CMAKE_FLAGS+=(-DLLVM_TARGETS_TO_BUILD="host;NVPTX") | ||
CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_HOST_TOOLCHAIN}) | ||
CMAKE_FLAGS+=(-DCMAKE_CROSSCOMPILING=OFF) | ||
cmake -GNinja ${LLVM_SRCDIR} ${CMAKE_FLAGS[@]} | ||
ninja -j${nproc} llvm-tblgen clang-tblgen llvm-config | ||
popd | ||
|
||
# Let's do the actual build within the `build` subdirectory | ||
mkdir ${WORKSPACE}/build | ||
cd ${WORKSPACE}/build | ||
|
||
CMAKE_FLAGS=() | ||
|
||
# Tell LLVM where our pre-built tblgen tools are | ||
CMAKE_FLAGS+=(-DLLVM_TABLEGEN=${WORKSPACE}/bootstrap/bin/llvm-tblgen) | ||
CMAKE_FLAGS+=(-DCLANG_TABLEGEN=${WORKSPACE}/bootstrap/bin/clang-tblgen) | ||
CMAKE_FLAGS+=(-DLLVM_CONFIG_PATH=${WORKSPACE}/bootstrap/bin/llvm-config) | ||
|
||
# Install things into $prefix | ||
CMAKE_FLAGS+=(-DCMAKE_INSTALL_PREFIX=${prefix}) | ||
|
||
# Explicitly use our cmake toolchain file and tell CMake we're cross-compiling | ||
CMAKE_FLAGS+=(-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN}) | ||
CMAKE_FLAGS+=(-DCMAKE_CROSSCOMPILING=ON) | ||
|
||
if [[ "${target}" == *apple* ]]; then | ||
# Without this, cling will try to call `x86_64-apple-darwin14-clang++` | ||
# on the macOS machine to find C++ header locations. | ||
CMAKE_FLAGS+=(-DCLING_CXX_PATH=clang++) | ||
fi | ||
|
||
# Release build for best performance | ||
CMAKE_FLAGS+=(-DCMAKE_BUILD_TYPE=Release) | ||
|
||
cmake -GNinja ${LLVM_SRCDIR} ${CMAKE_FLAGS[@]} | ||
ninja -j${nproc} \ | ||
tools/cling/install \ | ||
install-clang-resource-headers | ||
""" | ||
|
||
# These are the platforms we will build for by default, unless further | ||
# platforms are passed in on the command line | ||
platforms = [ | ||
Platform("x86_64", "linux"; libc = "glibc"), | ||
Platform("x86_64", "macOS"), | ||
Platform("aarch64", "linux"; libc = "glibc") | ||
] | ||
|
||
|
||
notinaboat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# The products that we will ensure are always built | ||
products = [ | ||
LibraryProduct("libcling", :libcling), | ||
ExecutableProduct("cling", :cling) | ||
] | ||
|
||
# Dependencies that must be installed before this package can be built | ||
dependencies = Dependency[ | ||
] | ||
|
||
# Build the tarballs, and possibly a `build.jl` as well. | ||
# Compiler versions taken from here: | ||
# https://github.com/JuliaPackaging/Yggdrasil/blob/master/L/LLVM/LLVM_full%409.0.1/build_tarballs.jl | ||
build_tarballs( | ||
ARGS, name, version, sources, script, platforms, products, dependencies; | ||
julia_compat="1.6", | ||
preferred_gcc_version=v"7", | ||
preferred_llvm_version=v"8") |
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,13 @@ | ||
diff --git a/lib/Support/Unix/Path.inc b/lib/Support/Unix/Path.inc | ||
index 27c8a1bc9b7..11f2cc518d0 100644 | ||
--- a/lib/Support/Unix/Path.inc | ||
+++ b/lib/Support/Unix/Path.inc | ||
@@ -1201,7 +1201,7 @@ namespace fs { | ||
std::error_code copy_file(const Twine &From, const Twine &To) { | ||
uint32_t Flag = COPYFILE_DATA; | ||
#if __has_builtin(__builtin_available) && defined(COPYFILE_CLONE) | ||
- if (__builtin_available(macos 10.12, *)) { | ||
+ { | ||
bool IsSymlink; | ||
if (std::error_code Error = is_symlink_file(From, IsSymlink)) | ||
return Error; |
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.
Can maybe also try aarch64 darwin?
And what about other platforms?