|
| 1 | +# Note that this script can accept some limited command-line arguments, run |
| 2 | +# `julia build_tarballs.jl --help` to see a usage message. |
| 3 | +using BinaryBuilder, Pkg |
| 4 | + |
| 5 | +name = "LLVMOpenMP" |
| 6 | +version = v"12.0.1" |
| 7 | + |
| 8 | +sources = [ |
| 9 | + ArchiveSource( |
| 10 | + "https://github.com/llvm/llvm-project/releases/download/llvmorg-$(version)/openmp-$(version).src.tar.xz", |
| 11 | + "60fe79440eaa9ebf583a6ea7f81501310388c02754dbe7dc210776014d06b091" |
| 12 | + ), |
| 13 | + DirectorySource("./bundled"), |
| 14 | +] |
| 15 | + |
| 16 | +# Bash recipe for building across all platforms |
| 17 | +script = raw""" |
| 18 | +cd $WORKSPACE/srcdir/openmp-*/ |
| 19 | +# https://github.com/msys2/MINGW-packages/blob/d440dcb738/mingw-w64-clang/0901-cast-to-make-gcc-happy.patch |
| 20 | +atomic_patch -p1 ../patches/0901-cast-to-make-gcc-happy.patch |
| 21 | +
|
| 22 | +platform_config=() |
| 23 | +if [[ "${target}" == *-freebsd* ]]; then |
| 24 | + platform_config+=(-DCMAKE_SHARED_LINKER_FLAGS="-Wl,--version-script=$(pwd)/runtime/src/exports_so.txt") |
| 25 | +elif [[ "${target}" == *-mingw* ]]; then |
| 26 | + # backport https://gitlab.kitware.com/cmake/cmake/-/commit/78f758a463516a78a9ec8d472080c6e61cb89c7f |
| 27 | + sed -i "s@/c */Fo@-c -Fo@" /usr/share/cmake/Modules/CMakeASM_MASMInformation.cmake |
| 28 | + sed -i "s@libomp_append(asmflags_local /@libomp_append(asmflags_local -@" runtime/cmake/LibompHandleFlags.cmake |
| 29 | + if [[ "${target}" == *x86_64* ]]; then |
| 30 | + platform_config+=(-DLIBOMP_ASMFLAGS="-win64") |
| 31 | + fi |
| 32 | + platform_config+=(-DCMAKE_ASM_MASM_COMPILER="uasm") |
| 33 | +elif [[ "${target}" == aarch64-apple-* ]]; then |
| 34 | + # Linking libomp requires the function `__divdc3`, which is implemented in |
| 35 | + # `libclang_rt.osx.a` from LLVM compiler-rt. |
| 36 | + platform_config+=(-DCMAKE_SHARED_LINKER_FLAGS="-L${libdir}/darwin -lclang_rt.osx") |
| 37 | +fi |
| 38 | +mkdir build && cd build |
| 39 | +cmake -DCMAKE_INSTALL_PREFIX=${prefix} \ |
| 40 | + -DCMAKE_TOOLCHAIN_FILE="${CMAKE_TARGET_TOOLCHAIN}" \ |
| 41 | + -DLIBOMP_INSTALL_ALIASES=OFF \ |
| 42 | + "${platform_config[@]}" \ |
| 43 | + .. |
| 44 | +make -j${nproc} |
| 45 | +make install |
| 46 | +""" |
| 47 | + |
| 48 | +# These are the platforms we will build for by default, unless further |
| 49 | +# platforms are passed in on the command line |
| 50 | +platforms = expand_cxxstring_abis(supported_platforms()) |
| 51 | + |
| 52 | +# The products that we will ensure are always built |
| 53 | +products = [ |
| 54 | + LibraryProduct("libomp", :libomp), |
| 55 | +] |
| 56 | + |
| 57 | +# Dependencies that must be installed before this package can be built |
| 58 | +dependencies = [ |
| 59 | + # We use UASM only for Windows |
| 60 | + HostBuildDependency(PackageSpec(name="UASM_jll", uuid="bbf38c07-751d-5a2b-a7fc-5c0acd9bd57e")), |
| 61 | + # We need libclang_rt.osx.a for linking libomp, because this library provides the |
| 62 | + # implementation of `__divdc3`. |
| 63 | + BuildDependency(PackageSpec(name="LLVMCompilerRT_jll", uuid="4e17d02c-6bf5-513e-be62-445f41c75a11", version=v"12.0.0"); platforms=[Platform("aarch64", "macos")]), |
| 64 | +] |
| 65 | + |
| 66 | +# Build the tarballs, and possibly a `build.jl` as well. |
| 67 | +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; julia_compat="1.6", preferred_gcc_version=v"8") |
0 commit comments