mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:00:12 +01:00
Use the driver to link. (#3987)
Rather than cc_binary, try using link from #3922
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
"""Provides rules for building Carbon files using the toolchain."""
|
||||
|
||||
load("@bazel_skylib//rules:run_binary.bzl", "run_binary")
|
||||
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import")
|
||||
|
||||
def carbon_binary(name, srcs):
|
||||
"""Compiles a Carbon binary.
|
||||
@@ -34,14 +33,21 @@ def carbon_binary(name, srcs):
|
||||
srcs = srcs,
|
||||
outs = [out],
|
||||
)
|
||||
cc_import(
|
||||
name = "%s.objs" % name,
|
||||
objects = [src + ".compile" for src in srcs],
|
||||
)
|
||||
|
||||
# For now, we assume that the prelude doesn't produce any necessary object
|
||||
# code, and don't include the .o files for //core/prelude... in the final
|
||||
# linked binary.
|
||||
#
|
||||
# TODO: This will need to be revisited eventually.
|
||||
cc_binary(name = name, deps = ["%s.objs" % name])
|
||||
objs = [s + ".o" for s in srcs]
|
||||
run_binary(
|
||||
name = name + ".link",
|
||||
tool = "//toolchain/driver:carbon",
|
||||
args = (["link"] +
|
||||
["$(location %s)" % s for s in objs] +
|
||||
["--output=$(location %s)" % name]),
|
||||
srcs = objs,
|
||||
outs = [name],
|
||||
# `link` has a dependency on ld, which should be in /usr/bin.
|
||||
env = {"PATH": "/usr/bin"},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user