diff --git a/README.md b/README.md index f56ee7ad..51f11e86 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Note that Windows support is still in its early stage, so feel free to submit fe ### Build from source #### Build requirements -In addition to the [system requirements](https://github.com/JuliaLang/julia#required-build-tools-and-external-libraries) to build julia itself(note you need to build julia with `USE_BINARYBUILDER=0`), the following are required: +In addition to the [system requirements](https://github.com/JuliaLang/julia#required-build-tools-and-external-libraries) to build julia itself, the following are required: - *Debian/Ubuntu*: `libedit-dev`, `libncurses5-dev` - *RedHat/CentOS*: `libedit-devel` diff --git a/deps/BuildBootstrap.Makefile b/deps/BuildBootstrap.Makefile index 2d1731cf..3b7b1a3b 100644 --- a/deps/BuildBootstrap.Makefile +++ b/deps/BuildBootstrap.Makefile @@ -1,35 +1,69 @@ -JULIA_SRC := $(subst \,/,$(BASE_JULIA_SRC)) -JULIA_BIN := $(subst \,/,$(BASE_JULIA_BIN)) +# Cxx source build +# download sources +LLVM_VER := 6.0.1 +LLVM_URL_PREFIX := http://releases.llvm.org/$(LLVM_VER) +LLVM_TAR := llvm-$(LLVM_VER).src.tar.xz +CLANG_TAR := cfe-$(LLVM_VER).src.tar.xz +COMPILER_RT_TAR := compiler-rt-$(LLVM_VER).src.tar.xz +LIBCXX_TAR := libcxx-$(LLVM_VER).src.tar.xz +LIBCXXABI_TAR := libcxxabi-$(LLVM_VER).src.tar.xz +POLLY_TAR := polly-$(LLVM_VER).src.tar.xz +LIBUNWIND_TAR := libunwind-$(LLVM_VER).src.tar.xz +LLD_TAR := lld-$(LLVM_VER).src.tar.xz + +TIMEOUT := 180 +CURL := curl -fkL --connect-timeout $(TIMEOUT) -y $(TIMEOUT) + +usr/download: + @[ -d usr ] || mkdir usr + mkdir $@ -ifeq ($(LLVM_VER),) -BUILDROOT=$(JULIA_BIN)/../.. -include $(JULIA_SRC)/deps/Versions.make -ifeq (exists, $(shell [ -e $(BUILDROOT)/Make.user ] && echo exists )) -include $(BUILDROOT)/Make.user -endif -endif -include Make.inc +LLVM_TARS := $(LLVM_TAR) $(CLANG_TAR) $(COMPILER_RT_TAR) $(LIBCXX_TAR) $(LIBCXXABI_TAR) $(POLLY_TAR) $(LIBUNWIND_TAR) $(LLD_TAR) -LLVM_VER_MAJ:=$(word 1, $(subst ., ,$(LLVM_VER))) -LLVM_VER_MIN:=$(word 2, $(subst ., ,$(LLVM_VER))) -# define a "short" LLVM version for easy comparisons -ifeq ($(LLVM_VER),svn) -LLVM_VER_SHORT:=svn -else -LLVM_VER_SHORT:=$(LLVM_VER_MAJ).$(LLVM_VER_MIN) -endif -LLVM_VER_PATCH:=$(word 3, $(subst ., ,$(LLVM_VER))) -ifeq ($(LLVM_VER_PATCH),) -LLVM_VER_PATCH := 0 -endif +llvm_tars: usr/download + @for tar in $(LLVM_TARS); do \ + if [[ -e $ $@) diff --git a/deps/build.jl b/deps/build.jl index ff1d3f1d..6f501d95 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -1,22 +1,11 @@ using Libdl -if haskey(ENV, "PREBUILT_CI_BINARIES") && ENV["PREBUILT_CI_BINARIES"] == "1" - # Try to download pre-built binaries - if !isdir("build") || length(readdir("build")) == 0 - os_tag = Sys.isapple() ? "osx" : "linux" - run(`rm -rf build/ src/`) - filename = "llvm-$(os_tag)-$(Base.libllvm_version).tgz" - run(`wget https://s3.amazonaws.com/julia-cxx/$filename`) - run(`tar xzf $filename --strip-components=1`) - end -end - -#in case we have specified the path to the julia installation -#that contains the headers etc, use that -BASE_JULIA_BIN = get(ENV, "BASE_JULIA_BIN", Sys.BINDIR) -BASE_JULIA_SRC = get(ENV, "BASE_JULIA_SRC", joinpath(BASE_JULIA_BIN, "..", "..")) +# in case we have specified the path to the julia installation +# that contains the headers etc, use that +BASE_JULIA_BIN = get(ENV, "BASE_JULIA_BIN", Sys.BINDIR) |> normpath +BASE_JULIA_SRC = get(ENV, "BASE_JULIA_SRC", joinpath(BASE_JULIA_BIN, "..", "..")) |> normpath -#write a simple include file with that path +# write a simple include file with that path println("writing path.jl file") s = """ const BASE_JULIA_BIN=$(sprint(show, BASE_JULIA_BIN)) @@ -28,21 +17,20 @@ export BASE_JULIA_SRC println("Tuning for julia installation at $BASE_JULIA_BIN with sources possibly at $BASE_JULIA_SRC") -# Try to autodetect C++ ABI in use +# try to autodetect C++ ABI in use llvm_path = Sys.iswindows() ? "LLVM" : - (Sys.isapple() && Base.libllvm_version >= v"3.8") ? "libLLVM" : "libLLVM-$(Base.libllvm_version)" - + Sys.isapple() ? "libLLVM" : "libLLVM-$(Base.libllvm_version)" llvm_lib_path = Libdl.dlpath(llvm_path) old_cxx_abi = findfirst("_ZN4llvm3sys16getProcessTripleEv", String(open(read, llvm_lib_path))) !== nothing old_cxx_abi && (ENV["OLD_CXX_ABI"] = "1") -llvm_config_path = joinpath(BASE_JULIA_BIN,"..","tools","llvm-config") +llvm_config_path = joinpath(BASE_JULIA_BIN, "..", "tools", "llvm-config") if isfile(llvm_config_path) @info "Building julia source build" ENV["LLVM_CONFIG"] = llvm_config_path delete!(ENV,"LLVM_VER") make = Sys.isbsd() && !Sys.isapple() ? `gmake` : `make` - run(`$make -j$(Sys.CPU_THREADS) -f BuildBootstrap.Makefile BASE_JULIA_BIN=$BASE_JULIA_BIN BASE_JULIA_SRC=$BASE_JULIA_SRC`) + run(`$make all -j$(Sys.CPU_THREADS) -f BuildBootstrap.Makefile BASE_JULIA_BIN=$BASE_JULIA_BIN BASE_JULIA_SRC=$BASE_JULIA_SRC`) s = s * "\n const IS_BINARYBUILD = false" else @info "Building julia binary build" diff --git a/src/CxxREPL/replpane.jl b/src/CxxREPL/replpane.jl index 93e97019..28ae09f4 100644 --- a/src/CxxREPL/replpane.jl +++ b/src/CxxREPL/replpane.jl @@ -62,15 +62,16 @@ module CxxREPL addHeaderDir(joinpath(@__DIR__, "..", "..", "deps", "usr", "build", "llvm-$ver_str", "include")) end else - cxxclangdir = joinpath(@__DIR__, "..", "..", "deps", "src", "clang-$ver_str", "include") - cxxllvmdir = joinpath(@__DIR__, "..", "..", "deps", "src", "llvm-$ver_str", "include") + llvmsrcdir = joinpath(@__DIR__, "..", "..", "deps", "usr", "src", "llvm-$ver_str") + cxxclangdir = joinpath(llvmsrcdir, "tools", "clang", "include") + cxxllvmdir = joinpath(llvmsrcdir, "include") if isdir(cxxclangdir) addHeaderDir(cxxclangdir) - addHeaderDir(joinpath(@__DIR__, "..", "..", "deps", "build", "clang-$ver_str", "include")) + addHeaderDir(joinpath(BASE_JULIA_SRC, "usr", "include", "clang")) end if isdir(cxxllvmdir) addHeaderDir(cxxllvmdir) - addHeaderDir(joinpath(@__DIR__, "..", "..", "deps", "build", "llvm-$ver_str", "include")) + addHeaderDir(joinpath(BASE_JULIA_SRC, "usr", "include", "llvm")) end end diff --git a/src/initialization.jl b/src/initialization.jl index 62ae0b6a..da4e4db8 100644 --- a/src/initialization.jl +++ b/src/initialization.jl @@ -10,8 +10,7 @@ binpath = BASE_JULIA_BIN srcpath = BASE_JULIA_SRC depspath = joinpath(BASE_JULIA_SRC, "deps", "srccache") -# Load the Cxx.jl bootstrap library (in debug version if we're running the Julia -# debug version) +# Load the Cxx.jl bootstrap library (in debug version if we're running the Julia debug version) lib_suffix = ccall(:jl_is_debugbuild, Cint, ()) != 0 ? "-debug" : "" @static if Sys.iswindows() const libcxxffi = joinpath(@__DIR__, "..", "deps", "usr", "bin", "libcxxffi"*lib_suffix) @@ -374,7 +373,7 @@ function collectClangHeaders!(headers) llvmver = string(Base.libllvm_version) baseclangdir = joinpath(BASE_JULIA_BIN, "..", "lib", "clang", llvmver, "include") cxxclangdir = @static IS_BINARYBUILD ? joinpath(@__DIR__, "..", "deps", "usr", "build", "clang-$llvmver", "lib", "clang", llvmver, "include") : - joinpath(@__DIR__, "..", "deps", "build", "clang-$llvmver", "lib", "clang", llvmver, "include") + baseclangdir if isdir(baseclangdir) push!(headers, (baseclangdir, C_ExternCSystem)) else diff --git a/src/typetranslation.jl b/src/typetranslation.jl index afc6e04e..35039fad 100644 --- a/src/typetranslation.jl +++ b/src/typetranslation.jl @@ -436,11 +436,7 @@ function getTemplateParameters(cxxd,quoted = false,typeargs = Dict{Int64,Cvoid}( return quoted ? Expr(:curly,:Tuple,args...) : Tuple{args...} end -@static if IS_BINARYBUILD - include(joinpath(@__DIR__, "..", "deps", "usr", "build", "clang_constants.jl")) -else - include(joinpath(@__DIR__, "..", "deps", "build", "clang_constants.jl")) -end +include(joinpath(@__DIR__, "..", "deps", "usr", "clang_constants.jl")) # TODO: Autogenerate this from the appropriate header # Decl::Kind