Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cgo_exports from GoSource #4051

Merged
merged 1 commit into from
Aug 17, 2024
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
5 changes: 1 addition & 4 deletions go/private/actions/archive.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
_copts = as_tuple(source.copts),
_cxxopts = as_tuple(source.cxxopts),
_clinkopts = as_tuple(source.clinkopts),
_cgo_exports = as_tuple(source.cgo_exports),

# Information on dependencies
_dep_labels = tuple([d.data.label for d in direct]),
Expand All @@ -198,13 +197,11 @@ def emit_archive(go, source = None, _recompile_suffix = "", recompile_internal_d
x_defs = dict(source.x_defs)
for a in direct:
x_defs.update(a.x_defs)
cgo_exports_direct = list(source.cgo_exports)

# Ensure that the _cgo_export.h of the current target comes first when cgo_exports is iterated
# by prepending it and specifying the order explicitly. This is required as the CcInfo attached
# to the archive only exposes a single header rather than combining all headers.
if out_cgo_export_h:
cgo_exports_direct.insert(0, out_cgo_export_h)
cgo_exports_direct = [out_cgo_export_h] if out_cgo_export_h else []
cgo_exports = depset(direct = cgo_exports_direct, transitive = [a.cgo_exports for a in direct], order = "preorder")
return GoArchive(
source = source,
Expand Down
2 changes: 0 additions & 2 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def _merge_embed(source, embed):
source["copts"] = source["copts"] or s.copts
source["cxxopts"] = source["cxxopts"] or s.cxxopts
source["clinkopts"] = source["clinkopts"] or s.clinkopts
source["cgo_exports"] = source["cgo_exports"] + s.cgo_exports

def _dedup_archives(archives):
"""Returns a list of archives without duplicate import paths.
Expand Down Expand Up @@ -278,7 +277,6 @@ def _library_to_source(go, attr, library, coverage_instrumented):
"copts": _expand_opts(go, "copts", getattr(attr, "copts", [])),
"cxxopts": _expand_opts(go, "cxxopts", getattr(attr, "cxxopts", [])),
"clinkopts": _expand_opts(go, "clinkopts", getattr(attr, "clinkopts", [])),
"cgo_exports": [],
"pgoprofile": getattr(attr, "pgoprofile", None),
}

Expand Down
3 changes: 1 addition & 2 deletions go/private/rules/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,6 @@ def _recompile_external_deps(go, external_source, internal_archive, library_labe
copts = as_list(arc_data._copts),
cxxopts = as_list(arc_data._cxxopts),
clinkopts = as_list(arc_data._clinkopts),
cgo_exports = as_list(arc_data._cgo_exports),
)

# If this archive needs to be recompiled, use go.archive.
Expand All @@ -701,7 +700,7 @@ def _recompile_external_deps(go, external_source, internal_archive, library_labe
transitive = depset(direct = [arc_data], transitive = [a.transitive for a in deps]),
x_defs = source.x_defs,
cgo_deps = depset(direct = arc_data._cgo_deps, transitive = [a.cgo_deps for a in deps]),
cgo_exports = depset(direct = list(source.cgo_exports), transitive = [a.cgo_exports for a in deps]),
cgo_exports = depset(transitive = [a.cgo_exports for a in deps]),
runfiles = source.runfiles,
mode = go.mode,
)
Expand Down
6 changes: 1 addition & 5 deletions go/providers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ method. In general, only rules_go should need to build or handle these.
+--------------------------------+-----------------------------------------------------------------+
| List of additional flags to pass to the external linker. |
+--------------------------------+-----------------------------------------------------------------+
| :param:`cgo_exports` | :type:`list of File` |
+--------------------------------+-----------------------------------------------------------------+
| The exposed cc headers for these sources. |
+--------------------------------+-----------------------------------------------------------------+
| :param:`cc_info` | :type:`CcInfo` |
+--------------------------------+-----------------------------------------------------------------+
| The result of merging the ``CcInfo``s of all `deps` and `cdeps` |
Expand Down Expand Up @@ -312,7 +308,7 @@ which is available through the :param:`data` field.
+--------------------------------+-----------------------------------------------------------------+
| :param:`cgo_exports` | :type:`depset of GoSource` |
+--------------------------------+-----------------------------------------------------------------+
| The the transitive set of c headers needed to reference exports of this archive. |
| The transitive set of c headers needed to reference exports of this archive. |
+--------------------------------+-----------------------------------------------------------------+
| :param:`runfiles` | runfiles_ |
+--------------------------------+-----------------------------------------------------------------+
Expand Down