Skip to content

Commit abdb706

Browse files
committed
build: add OpenMP as dependency
1 parent cfcffbf commit abdb706

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

WORKSPACE.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
workspace(name = "zkir")
1616

17+
load("//bazel:zkir_deps.bzl", "zkir_deps")
18+
19+
zkir_deps()
20+
1721
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
1822

1923
LLVM_COMMIT = "f8287f6c373fcf993643dd6f0e30dde304c1be73"

bazel/zkir_deps.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""
2+
This module configures dependencies for the ZKIR project.
3+
"""
4+
5+
load("//third_party/omp:omp_configure.bzl", "omp_configure")
6+
7+
def zkir_deps():
8+
omp_configure(name = "local_config_omp")

third_party/omp/BUILD.bazel

Whitespace-only changes.

third_party/omp/omp.BUILD

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
HEADERS = [
6+
"omp.h",
7+
"ompx.h",
8+
"omp-tools.h",
9+
"ompt.h",
10+
]
11+
12+
# NOTE: This is only for macos.
13+
# On other platforms openmp should work without local config.
14+
genrule(
15+
name = "link_headers",
16+
outs = HEADERS,
17+
cmd = """
18+
mkdir -p $(@D)/
19+
for file in $(OUTS); do
20+
file=$${file##*/}
21+
ln -sf /opt/homebrew/opt/libomp/include/$$file $(@D)/$$file
22+
done
23+
""",
24+
)
25+
26+
cc_library(
27+
name = "omp",
28+
hdrs = HEADERS,
29+
include_prefix = "third_party/omp/include",
30+
includes = ["."],
31+
linkopts = [
32+
"-L/opt/homebrew/opt/libomp/lib",
33+
"-lomp",
34+
],
35+
)

third_party/omp/omp_configure.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
This module configures OpenMP for use with Bazel.
3+
"""
4+
5+
def _omp_configure_impl(repository_ctx):
6+
repository_ctx.symlink(Label("//third_party/omp:omp.BUILD"), "BUILD.bazel")
7+
8+
omp_configure = repository_rule(
9+
implementation = _omp_configure_impl,
10+
)

0 commit comments

Comments
 (0)