Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- ubuntu-latest
bazel:
- 8.x
- 9.x
- latest
- last_rc
- last_green
Expand Down
18 changes: 17 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@ module(

bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "rules_cc", version = "0.2.16")
bazel_dep(name = "rules_python", version = "1.0.0")

# Apply this patch in your project if you want to use shared libraries with mojo
single_version_override(
module_name = "rules_cc",
patch_strip = 1,
patches = [
# https://github.com/bazelbuild/rules_cc/pull/578
"//tools:rules_cc.patch",
],
)

mojo = use_extension("//mojo:extensions.bzl", "mojo")
mojo.toolchain()
mojo.gpu_toolchains()
Expand Down Expand Up @@ -56,3 +66,9 @@ versions(
dev_dependency = True,
python_versions = _PYTHON_VERSIONS,
)

link_hack = use_repo_rule("//mojo/private:link_hack.bzl", "link_hack")

link_hack(
name = "build_bazel_rules_android", # See link_hack.bzl for details
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
https://github.com/bazelbuild/bazel/pull/23838
"""

def _link_hack_impl(rctx):
rctx.file("BUILD.bazel", "")
rctx.file("link_hack.bzl", """\
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")

def link_hack(**kwargs):
return cc_common.link(**kwargs)
""")

link_hack = repository_rule(
implementation = _link_hack_impl,
)
2 changes: 1 addition & 1 deletion mojo/private/mojo_binary_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain")
load("@build_bazel_rules_android//:link_hack.bzl", "link_hack") # See link_hack.bzl for details
load("@rules_cc//cc/common:cc_common.bzl", "cc_common")
load("@rules_cc//cc/common:cc_info.bzl", "CcInfo")
load("@rules_python//python:py_info.bzl", "PyInfo")
load("//mojo:providers.bzl", "MojoInfo")
load("//tools/build_defs/android:link_hack.bzl", "link_hack") # See link_hack.bzl for details
load(":transitions.bzl", "python_version_transition")
load(":utils.bzl", "MOJO_EXTENSIONS", "collect_mojoinfo")

Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions tools/rules_cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/cc/private/cc_common.bzl b/cc/private/cc_common.bzl
index 69d6db11..82e9c49b 100644
--- a/cc/private/cc_common.bzl
+++ b/cc/private/cc_common.bzl
@@ -85,7 +85,7 @@ def _link(
additional_linkstamp_defines = _UNBOUND,
always_link = _UNBOUND,
link_artifact_name_suffix = _UNBOUND,
- main_output = _UNBOUND,
+ main_output = None,
use_shareable_artifact_factory = _UNBOUND,
build_config = _UNBOUND,
emit_interface_shared_library = _UNBOUND):
@@ -103,7 +103,6 @@ def _link(
additional_linkstamp_defines != _UNBOUND or \
always_link != _UNBOUND or \
link_artifact_name_suffix != _UNBOUND or \
- main_output != _UNBOUND or \
use_shareable_artifact_factory != _UNBOUND or \
build_config != _UNBOUND or \
emit_interface_shared_library != _UNBOUND:
@@ -125,8 +124,6 @@ def _link(
always_link = False
if link_artifact_name_suffix == _UNBOUND:
link_artifact_name_suffix = ""
- if main_output == _UNBOUND:
- main_output = None
if use_shareable_artifact_factory == _UNBOUND:
use_shareable_artifact_factory = False
if build_config == _UNBOUND: