Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from Gnimuc/fix-windows
Browse files Browse the repository at this point in the history
Windows update
  • Loading branch information
Gnimuc authored Jul 3, 2019
2 parents bc18d0d + 6a1aa98 commit 0d10294
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 163 deletions.
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.DS_Store
build
products
LLVM
JuliaBinary
JuliaSource
dlfcn
downloads
137 changes: 30 additions & 107 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,118 +4,41 @@ This is an experimental repo for exploring how to upgrade Cxx.jl's building syst
## Usage
Pre-built binaries can be found in the release page: https://github.com/Gnimuc/CxxBuilder/releases

### Build for Linux-x86_64
1. Download Julia-v1.1 binary: https://julialang-s3.julialang.org/bin/linux/x64/1.1/julia-1.1.0-linux-x86_64.tar.gz
2. Unzip downloaded tarball, create a directory called `JuliaBinary` and move unzipped contents into it
3. Download Julia-v1.1 source: https://github.com/JuliaLang/julia/releases/download/v1.1.0/julia-1.1.0.tar.gz
4. Unzip downloaded tarball, create a directory called `JuliaSource` and move unzipped contents into it
5. Download LLVM binary: https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-4%2Bnowasm/LLVM.v6.0.1.x86_64-linux-gnu-gcc7.tar.gz
6. Create a directory called `LLVM` and move downloaded tarball into it
7. Now, the file hierarchy should look like this:
### Build for Linux-x86_64(gcc7)
1. Edit build_tarballs.jl
2. Replace corresponding source URL=>SHA pairs with:
```
CxxBuilder +
| libcxxffi
| patches
| build_tarballs.jl
| README.md
+ JuliaBinary +
| juliabin +
| bin
| etc
| include
| lib
| ...
+ JuliaSource +
| julia +
| base
| contrib
| deps
| doc
| etc
| ...
+ LLVM +
| LLVM.v6.0.1.x86_64-linux-gnu-gcc7.tar.gz
# julia binary
"https://github.com/Gnimuc/JuliaBuilder/releases/download/v1.1.1/julia-1.1.1-x86_64-linux-gnu-gcc7.tar.gz" =>
"???",
# LLVM binary
"https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-5%2Bnowasm/LLVM.v6.0.1.x86_64-linux-gnu-gcc7.tar.gz" =>
"6fca2fedc5ae4ead8b2fd62d863e2a556075d4d7de8b8c66cc8feeea6dc33851",
```
8. Uncomment the line `# BinaryProvider.Linux(:x86_64; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),` in `build_tarballs.jl`
9. Run `julia --color=yes build_tarballs.jl --verbose`
10. Find the binary in the `products` folder
3. Run `julia --color=yes build_tarballs.jl --verbose --debug x86_64-linux-gnu-gcc7`

### Build for MacOS
1. Download Julia-v1.1 binary: https://julialang-s3.julialang.org/bin/mac/x64/1.1/julia-1.1.0-mac64.dmg
2. Open the dmg image, right-click Julia-1.1.app, click `Show Package Contents`⁩, copy `⁨Contents⁩/⁨Resources/julia`⁩ to a new directory called `JuliaBinary`
3. Download Julia-v1.1 source: https://github.com/JuliaLang/julia/releases/download/v1.1.0/julia-1.1.0.tar.gz
4. Unzip downloaded tarball, create a directory called `JuliaSource` and move unzipped contents into it
5. Download LLVM binary: https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-4%2Bnowasm/LLVM.v6.0.1.x86_64-apple-darwin14-gcc7.tar.gz
6. Create a directory called `LLVM` and move downloaded tarball into it
7. Now, the file hierarchy should look like this:
### Build for MacOS(gcc7)
1. Edit build_tarballs.jl
2. Replace corresponding source URL=>SHA pairs with:
```
CxxBuilder +
| libcxxffi
| patches
| build_tarballs.jl
| README.md
+ JuliaBinary +
| juliabin +
| bin
| etc
| include
| lib
| ...
+ JuliaSource +
| julia +
| base
| contrib
| deps
| doc
| etc
| ...
+ LLVM +
| LLVM.v6.0.1.x86_64-apple-darwin14-gcc7.tar.gz
# julia binary
"https://github.com/Gnimuc/JuliaBuilder/releases/download/v1.1.1/julia-1.1.1-x86_64-apple-darwin14.tar.gz" =>
"c41d6535bc57bb0f96f69b3c44fdc169ec98dd780f8845f65a4d0bb65a4900ee",
# LLVM binary
"https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-5%2Bnowasm/LLVM.v6.0.1.x86_64-apple-darwin14-gcc7.tar.gz" =>
"12ea772128b9f9306188fd9933ad5c26a247e598578fffd6487d6dc4eb417ec8",
```
8. Uncomment the line `# BinaryProvider.MacOS(:x86_64; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),` in `build_tarballs.jl`
9. Run `julia --color=yes build_tarballs.jl --verbose`
10. Find the binary in the `products` folder
3. Run `julia --color=yes build_tarballs.jl --verbose --debug x86_64-apple-darwin14-gcc7`

### Build for Windows-x86_64
1. Download Julia-v1.1 binary: https://julialang-s3.julialang.org/bin/winnt/x64/1.1/julia-1.1.1-win64.exe
2. Install it on a Windows machine, move those installed files into a folder called `juliabin`⁩, create a new directory called `JuliaBinary` on your Linux machine that runs BB2 and move `juliabin`⁩ into it
3. Download Julia-v1.1 source: https://github.com/JuliaLang/julia/releases/download/v1.1.0/julia-1.1.0.tar.gz
4. Unzip downloaded tarball, create a directory called `JuliaSource` and move unzipped contents into it
5. Download LLVM binary: https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-4%2Bnowasm/LLVM.v6.0.1.x86_64-w64-mingw32-gcc7.tar.gz
6. Create a directory called `LLVM` and move downloaded tarball into it
7. Download dlfcn-win32 v1.2.0 source code from https://github.com/dlfcn-win32/dlfcn-win32/archive/v1.2.0.zip
8. Unzip downloaded tarball, create a directory called `dlfcn` and move unzipped code into it
9. Now, the file hierarchy should look like this:
### Build for Windows-x86_64(gcc7)
1. Edit build_tarballs.jl
2. Replace corresponding source URL=>SHA pairs with:
```
CxxBuilder +
| libcxxffi
| patches
| build_tarballs.jl
| README.md
+ dlfcn +
| dlfcn-win32 +
| cmake-test
| visual-studio
| CMakeLists.txt
| ...
+ JuliaBinary +
| juliabin +
| bin
| etc
| include
| lib
| ...
+ JuliaSource +
| julia +
| base
| contrib
| deps
| doc
| etc
| ...
+ LLVM +
| LLVM.v6.0.1.x86_64-w64-mingw32-gcc7.tar.gz
# julia binary
"https://github.com/Gnimuc/JuliaBuilder/releases/download/v1.1.1/julia-1.1.1-x86_64-w64-mingw32.tar.gz" =>
"9446377e8fd7b143f2ed1ea7ec6470d25e463b89828b728b226d9e221e5506a5",
# LLVM binary
"https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-5%2Bnowasm/LLVM.v6.0.1.x86_64-w64-mingw32-gcc7.tar.gz" =>
"998a1932884121f15d7d5b2e75fb977695a4d448dd3888c10a18aafa83faf8c9",
```
10. Uncomment the line `# BinaryProvider.Windows(:x86_64; compiler_abi=CompilerABI(:gcc7)),` in `build_tarballs.jl`
11. Run `julia --color=yes build_tarballs.jl --verbose`
12. Find the binary in the `products` folder
3. Run `julia --color=yes build_tarballs.jl --verbose --debug x86_64-w64-mingw32-gcc7`
91 changes: 52 additions & 39 deletions build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,20 @@ sources = [
"http://releases.llvm.org/$(llvm_ver)/lld-$(llvm_ver).src.tar.xz" =>
"e706745806921cea5c45700e13ebe16d834b5e3c0b7ad83bf6da1f28b0634e11",
"patches",
# Julia source
"JuliaSource",
# Add pre-built Julia tarballs
"JuliaBinary",
# Add pre-built LLVM tarballs
"LLVM",
# Add libcxxffi source
"libcxxffi",
# Add dlfcn-win32 source
"dlfcn"
# julia source
"https://github.com/JuliaLang/julia/releases/download/v1.1.1/julia-1.1.1.tar.gz" =>
"0ea5143b663426720ff0b320a9c46f6e967a2fad3f1026eda3ac46eeeb406942",
# dlfcn-win32 source
"https://github.com/dlfcn-win32/dlfcn-win32/archive/v1.2.0.tar.gz" =>
"f18a412e84d8b701e61a78252411fe8c72587f52417c1ef21ca93604de1b9c55",
# libcxxffi source
"libcxxffi",
# julia binary
"https://github.com/Gnimuc/JuliaBuilder/releases/download/v1.1.1/julia-1.1.1-x86_64-w64-mingw32.tar.gz" =>
"9446377e8fd7b143f2ed1ea7ec6470d25e463b89828b728b226d9e221e5506a5",
# LLVM binary
"https://github.com/staticfloat/LLVMBuilder/releases/download/v6.0.1-5%2Bnowasm/LLVM.v6.0.1.x86_64-w64-mingw32-gcc7.tar.gz" =>
"998a1932884121f15d7d5b2e75fb977695a4d448dd3888c10a18aafa83faf8c9",
]

# Since we kind of do this LLVM setup twice, this is the shared setup start:
Expand Down Expand Up @@ -77,59 +81,67 @@ for f in $WORKSPACE/srcdir/llvm_patches/*.patch; do
done
"""

# Next, we will Bash recipe for building across all platforms
# Next, build libcxxffi
script = script_setup * raw"""
# build libcxxffi
cd $WORKSPACE/srcdir/
if [[ ${target} == *mingw32* ]]; then
cd $WORKSPACE/srcdir/dlfcn-win32
cd $WORKSPACE/srcdir/dlfcn-win32-1.2.0
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=/opt/$target/$target.toolchain
make -j${nproc} VERBOSE=1
make install VERBOSE=1
fi
cd $WORKSPACE/srcdir/
mkdir LLVMBinary
tar -C LLVMBinary --strip-components=1 -xf *LLVM*.tar.gz
# use CMake on all platforms except Windows
if [[ "${target}" == *linux* ]] || [[ "${target}" == *apple* ]] || [[ "${target}" == *freebsd* ]]; then
mkdir build && cd build
CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=/opt/$target/$target.toolchain"
CMAKE_FLAGS="${CMAKE_FLAGS} -DJULIA_SOURCE_PREFIX=$WORKSPACE/srcdir/julia-1.1.1"
CMAKE_FLAGS="${CMAKE_FLAGS} -DJULIA_BINARY_PREFIX=$WORKSPACE/srcdir/juliabin"
CMAKE_FLAGS="${CMAKE_FLAGS} -DLLVMBUILDER_PREFIX=$WORKSPACE/srcdir"
cmake .. ${CMAKE_FLAGS}
make -j${nproc} VERBOSE=1
make install VERBOSE=1
fi
cd $WORKSPACE/srcdir/
mkdir build && cd build
CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_TOOLCHAIN_FILE=/opt/$target/$target.toolchain"
CMAKE_FLAGS="${CMAKE_FLAGS} -DJULIA_SOURCE_PREFIX=$WORKSPACE/srcdir/julia"
CMAKE_FLAGS="${CMAKE_FLAGS} -DJULIA_BINARY_PREFIX=$WORKSPACE/srcdir/juliabin"
CMAKE_FLAGS="${CMAKE_FLAGS} -DLLVMBUILDER_PREFIX=$WORKSPACE/srcdir/LLVMBinary"
cmake .. ${CMAKE_FLAGS}
make -j${nproc} VERBOSE=1
make install VERBOSE=1
# use Make on Windows
if [[ ${target} == *mingw32* ]]; then
cd $WORKSPACE/srcdir/
make -j${nproc} VERBOSE=1 -f Windows.Makefile JULIA_SOURCE_PREFIX=$WORKSPACE/srcdir/julia-1.1.1 JULIA_BINARY_PREFIX=$WORKSPACE/srcdir/juliabin LLVMBUILDER_PREFIX=$WORKSPACE/srcdir
cp -r ./build/* /workspace/destdir/bin/
fi
# copy LLVM/Clang assets
mkdir -p ${prefix}/src/clang-6.0.1/include
mkdir -p ${prefix}/src/llvm-6.0.1/include
mkdir -p ${prefix}/build/clang-6.0.1/lib/clang/6.0.1/include
mkdir -p ${prefix}/build/clang-6.0.1/include
mkdir -p ${prefix}/build/llvm-6.0.1/include
cp -r $WORKSPACE/srcdir/llvm-6.0.1.src/tools/clang/include/* ${prefix}/src/clang-6.0.1/include/
cp -r $WORKSPACE/srcdir/llvm-6.0.1.src/include/* ${prefix}/src/llvm-6.0.1/include/
cp -r $WORKSPACE/srcdir/LLVMBinary/include/* ${prefix}/build/llvm-6.0.1/include/
cp -r $WORKSPACE/srcdir/LLVMBinary/lib/* ${prefix}/lib/
cp -r $WORKSPACE/srcdir/LLVMBinary/lib/clang/6.0.1/include/* ${prefix}/build/clang-6.0.1/lib/clang/6.0.1/include/
cp -r $WORKSPACE/srcdir/include/* ${prefix}/build/llvm-6.0.1/include/
cp -r $WORKSPACE/srcdir/lib/* ${prefix}/lib/
cp -r $WORKSPACE/srcdir/lib/clang/6.0.1/include/* ${prefix}/build/clang-6.0.1/lib/clang/6.0.1/include/
cp -r ${prefix}/build/llvm-6.0.1/include/* ${prefix}/build/clang-6.0.1/include/
# generate clang_constants.jl
cd $WORKSPACE/srcdir
make -f GenerateConstants.Makefile BASE_LLVM_BIN=$WORKSPACE/srcdir/LLVMBinary BASE_JULIA_BIN=$WORKSPACE/srcdir/juliabin BASE_JULIA_SRC=$WORKSPACE/srcdir/julia LLVM_VERSION=6.0.1
make -f GenerateConstants.Makefile BASE_LLVM_BIN=$WORKSPACE/srcdir BASE_JULIA_BIN=$WORKSPACE/srcdir/juliabin BASE_JULIA_SRC=$WORKSPACE/srcdir/julia LLVM_VERSION=6.0.1
cp $WORKSPACE/srcdir/clang_constants.jl ${prefix}/build/
# copy mingw headers
if [[ ${target} == *mingw32* ]] && [[ ${nbits} == 64 ]]; then
cp -r $WORKSPACE/srcdir/LLVMBinary/bin/* ${prefix}/bin
cp -r $WORKSPACE/srcdir/bin/* ${prefix}/bin
mkdir -p ${prefix}/mingw/include
mkdir -p ${prefix}/mingw/sys-root/include
cp -r /opt/x86_64-w64-mingw32/x86_64-w64-mingw32/include/* ${prefix}/mingw/include/
cp -r /opt/x86_64-w64-mingw32/x86_64-w64-mingw32/sys-root/include/* ${prefix}/mingw/sys-root/include/
fi
if [[ ${target} == *mingw32* ]] && [[ ${nbits} == 32 ]]; then
cp -r $WORKSPACE/srcdir/LLVMBinary/bin/* ${prefix}/bin
cp -r $WORKSPACE/srcdir/bin/* ${prefix}/bin
mkdir -p ${prefix}/mingw/include
mkdir -p ${prefix}/mingw/sys-root/include
cp -r /opt/i686-w64-mingw32/i686-w64-mingw32/include/* ${prefix}/mingw/include/
Expand All @@ -139,15 +151,16 @@ fi
"""

platforms = [
# BinaryProvider.Linux(:i686; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
# BinaryProvider.Linux(:x86_64; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
# BinaryProvider.Linux(:aarch64; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
# BinaryProvider.Linux(:armv7l; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
# BinaryProvider.MacOS(:x86_64; compiler_abi=CompilerABI(:gcc7)),
# BinaryProvider.Windows(:i686; compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.Windows(:x86_64; compiler_abi=CompilerABI(:gcc7)),
# BinaryProvider.FreeBSD(:x86_64; compiler_abi=CompilerABI(:gcc7)),
]
BinaryProvider.Linux(:i686; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.Linux(:x86_64; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.Linux(:aarch64; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.Linux(:armv7l; libc=:glibc, compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.MacOS(:x86_64; compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.Windows(:i686; compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.Windows(:x86_64; compiler_abi=CompilerABI(:gcc7)),
BinaryProvider.FreeBSD(:x86_64; compiler_abi=CompilerABI(:gcc7)),
]
# platforms = expand_gcc_versions(platforms)

# The products that we will ensure are always built
products(prefix) = [
Expand Down
26 changes: 13 additions & 13 deletions libcxxffi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
cmake_minimum_required(VERSION 3.8.0)
project(cxxjl)

if(WIN32)
message(FATAL_ERROR "Binary-build for Windows using CMake is NOT supported, please use `Windows.Makefile` instead.")
endif()

if(JULIA_SOURCE_PREFIX)
set(JULIA_SOURCE_INCLUDE_DIRS ${JULIA_SOURCE_PREFIX}/src/support)
message(STATUS "JULIA_SOURCE_INCLUDE_DIRS: " ${JULIA_SOURCE_INCLUDE_DIRS})
Expand Down Expand Up @@ -51,26 +55,27 @@ endif()
if(WIN32)
find_package(dlfcn-win32 REQUIRED)
set(CMAKE_DL_LIBS dlfcn-win32::dl)
message(STATUS "CMAKE_DL_LIBS: " ${CMAKE_DL_LIBS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
message(STATUS "CMAKE_DL_LIBS: " ${CMAKE_DL_LIBS})
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti")

set(CXXJL_TARGET cxxffi)

link_directories(${CLANG_LIB_DIRS} ${JULIA_LIB_DIRS})

add_library(${CXXJL_TARGET} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/bootstrap.cpp)

target_include_directories(${CXXJL_TARGET} PUBLIC ${CLANG_INCLUDE_DIRS} ${CLANG_SOURCE_INCLUDE_DIRS} ${JULIA_INCLUDE_DIRS} ${JULIA_SOURCE_INCLUDE_DIRS})
target_compile_options(${CXXJL_TARGET} PUBLIC -DLLVM_NDEBUG -DLIBRARY_EXPORTS -fno-rtti)
target_compile_options(${CXXJL_TARGET} PUBLIC -DLLVM_NDEBUG -DLIBRARY_EXPORTS)

set(CLANG_LIBS clangFrontendTool
clangBasic
clangBasic
clangLex
clangDriver
clangFrontend
clangParse
clangAST
clangAST
clangASTMatchers
clangSema
clangAnalysis
Expand All @@ -79,7 +84,7 @@ set(CLANG_LIBS clangFrontendTool
clangRewrite
clangSerialization
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangStaticAnalyzerCore
clangStaticAnalyzerFrontend
clangTooling
clangToolingCore
Expand All @@ -97,13 +102,8 @@ if(APPLE)
target_link_libraries(${CXXJL_TARGET} ${JULIA_LIBS} ${LLVM_LIBS})
target_link_libraries(${CXXJL_TARGET} -Xlinker -all_load ${CLANG_LIBS})
else()
target_link_libraries(${CXXJL_TARGET} ${JULIA_LIBS} ${LLVM_LIBS})
if(WIN32)
target_link_libraries(${CXXJL_TARGET} ${CMAKE_DL_LIBS})
target_link_libraries(${CXXJL_TARGET} -Wl,--whole-archive ${CLANG_LIBS} -Wl,--no-whole-archive -lversion)
else()
target_link_libraries(${CXXJL_TARGET} -Wl,--whole-archive ${CLANG_LIBS} -Wl,--no-whole-archive)
endif()
target_link_libraries(${CXXJL_TARGET} ${JULIA_LIBS} ${LLVM_LIBS})
target_link_libraries(${CXXJL_TARGET} -Wl,--whole-archive ${CLANG_LIBS} -Wl,--no-whole-archive)
endif()

install(TARGETS ${CXXJL_TARGET}
Expand Down
Loading

0 comments on commit 0d10294

Please sign in to comment.