Skip to content

Commit 166080b

Browse files
clouds56giordano
andauthored
[LLVMOpenMP] Add initial recipe. (#3271)
* [openmp] Add initial recipe. * fix build for freebsd, disable windows * Apply suggestions from code review Co-authored-by: Mosè Giordano <[email protected]> * Update build_tarballs.jl * Create build_tarballs.jl * Rename O/openmp/build_tarballs.jl to L/LLVMOpenMP/build_tarballs.jl * Update build_tarballs.jl * Update build_tarballs.jl * Create 0901-cast-to-make-gcc-happy.patch * fix build on windows * Update L/LLVMOpenMP/build_tarballs.jl * [LLVMOpenMP] Upgrade to LLVM 13.0.1 * [LLVMOpenMP] Use `LLVMCompilerRT_jll` for aarch64-apple-darwin * [LLVMOpenMP] Use `UASM_jll` for Windows * [LLVMOpenMP] Rollback to v12.0.0 Building v13.0.1 presents lots of new errors. * [LLVMOpenMP] Try building v12.0.1 Co-authored-by: Mosè Giordano <[email protected]>
1 parent 5158eb8 commit 166080b

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

L/LLVMOpenMP/build_tarballs.jl

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--- openmp/runtime/src/kmp_atomic.cpp 2021-05-07 01:45:33.857000200 +0200
2+
+++ openmp/runtime/src/kmp_atomic.cpp 2021-05-07 01:45:38.757999800 +0200
3+
@@ -646,15 +646,15 @@
4+
5+
static inline kmp_cmplx128_a4_t operator+(kmp_cmplx128_a4_t &lhs,
6+
kmp_cmplx128_a4_t &rhs) {
7+
- return lhs.q + rhs.q;
8+
+ return (kmp_cmplx128_a4_t)(lhs.q + rhs.q);
9+
}
10+
static inline kmp_cmplx128_a4_t operator-(kmp_cmplx128_a4_t &lhs,
11+
kmp_cmplx128_a4_t &rhs) {
12+
- return lhs.q - rhs.q;
13+
+ return (kmp_cmplx128_a4_t)(lhs.q - rhs.q);
14+
}
15+
static inline kmp_cmplx128_a4_t operator*(kmp_cmplx128_a4_t &lhs,
16+
kmp_cmplx128_a4_t &rhs) {
17+
- return lhs.q * rhs.q;
18+
+ return (kmp_cmplx128_a4_t)(lhs.q * rhs.q);
19+
}
20+
static inline kmp_cmplx128_a4_t operator/(kmp_cmplx128_a4_t &lhs,
21+
kmp_cmplx128_a4_t &rhs) {
22+
@@ -663,15 +663,15 @@
23+
24+
static inline kmp_cmplx128_a16_t operator+(kmp_cmplx128_a16_t &lhs,
25+
kmp_cmplx128_a16_t &rhs) {
26+
- return lhs.q + rhs.q;
27+
+ return (kmp_cmplx128_a16_t)(lhs.q + rhs.q);
28+
}
29+
static inline kmp_cmplx128_a16_t operator-(kmp_cmplx128_a16_t &lhs,
30+
kmp_cmplx128_a16_t &rhs) {
31+
- return lhs.q - rhs.q;
32+
+ return (kmp_cmplx128_a16_t)(lhs.q - rhs.q);
33+
}
34+
static inline kmp_cmplx128_a16_t operator*(kmp_cmplx128_a16_t &lhs,
35+
kmp_cmplx128_a16_t &rhs) {
36+
- return lhs.q * rhs.q;
37+
+ return kmp_cmplx128_a16_t(lhs.q * rhs.q);
38+
}
39+
static inline kmp_cmplx128_a16_t operator/(kmp_cmplx128_a16_t &lhs,
40+
kmp_cmplx128_a16_t &rhs) {

0 commit comments

Comments
 (0)