Skip to content

Commit 7d906be

Browse files
authored
Add vendored lld to build invocations (#4)
In some cases Mojo expects to be able to run lld internally
1 parent 024e62c commit 7d906be

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

mojo/private/mojo_binary_test.bzl

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ def _mojo_binary_test_implementation(ctx):
104104
progress_message = "%{label} compiling mojo object",
105105
env = {
106106
"MODULAR_CRASH_REPORTING_ENABLED": "false",
107+
"MODULAR_MOJO_MAX_COMPILERRT_PATH": "/dev/null", # Make sure this fails if accessed
107108
"MODULAR_MOJO_MAX_LINKER_DRIVER": "/dev/null", # Make sure this fails if accessed
108-
"MODULAR_MOJO_MAX_LLD_PATH": "/dev/null", # Make sure this fails if accessed
109+
"MODULAR_MOJO_MAX_LLD_PATH": mojo_toolchain.lld.path,
109110
"MODULAR_MOJO_MAX_ORCRT_PATH": "/dev/null", # Make sure this fails if accessed
110111
"TEST_TMPDIR": ".",
111112
},

mojo/private/toolchain.BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ mojo_toolchain(
4343
name
4444
for name, _ in _INTERNAL_LIBRARIES
4545
] + ([":all_mojopkgs"] if "{INCLUDE_MOJOPKGS}" else []),
46+
lld = "bin/lld",
4647
mojo = "bin/mojo",
4748
visibility = ["//visibility:public"],
4849
)

mojo/providers.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ MojoToolchainInfo = provider(
1313
fields = {
1414
"all_tools": "All the files that must be available in actions in order for the toolchain to work.",
1515
"copts": "Additional compiler options to pass to the Mojo compiler.",
16+
"lld": "The lld compiler executable to link with",
1617
"mojo": "The mojo compiler executable to build with",
1718
"implicit_deps": "Implicit dependencies that every target should depend on, providing either CcInfo, or MojoInfo",
1819
},

mojo/toolchain.bzl

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load("//mojo:providers.bzl", "MojoInfo", "MojoToolchainInfo")
44

55
def _mojo_toolchain_impl(ctx):
66
tool_files = [ctx.attr.mojo[DefaultInfo].files]
7-
for dep in ctx.attr.implicit_deps:
7+
for dep in ctx.attr.implicit_deps + [ctx.attr.lld]:
88
tool_files.append(dep[DefaultInfo].default_runfiles.files)
99
tool_files.append(dep[DefaultInfo].files_to_run)
1010

@@ -13,6 +13,7 @@ def _mojo_toolchain_impl(ctx):
1313
mojo_toolchain_info = MojoToolchainInfo(
1414
all_tools = tool_files,
1515
copts = ctx.attr.copts,
16+
lld = ctx.executable.lld,
1617
mojo = ctx.executable.mojo,
1718
implicit_deps = ctx.attr.implicit_deps,
1819
),
@@ -26,6 +27,13 @@ mojo_toolchain = rule(
2627
mandatory = False,
2728
doc = "Additional compiler options to pass to the Mojo compiler.",
2829
),
30+
"lld": attr.label(
31+
allow_files = True,
32+
mandatory = True,
33+
executable = True,
34+
cfg = "exec",
35+
doc = "The lld executable to link with.",
36+
),
2937
"mojo": attr.label(
3038
allow_files = True,
3139
mandatory = True,

0 commit comments

Comments
 (0)