Skip to content

Commit 3aa6de3

Browse files
authored
remove experimental_use_whole_archive_for_native_deps (#1338)
This isn't needed anymore after #1333 I believe. This is part of the work on #1268.
1 parent a066bfe commit 3aa6de3

File tree

7 files changed

+44
-96
lines changed

7 files changed

+44
-96
lines changed

docs/defs.md

+11-18
Large diffs are not rendered by default.

docs/flatten.md

+13-23
Large diffs are not rendered by default.

docs/rust_doc.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
## rust_doc
1010

1111
<pre>
12-
rust_doc(<a href="#rust_doc-name">name</a>, <a href="#rust_doc-crate">crate</a>, <a href="#rust_doc-experimental_use_whole_archive_for_native_deps">experimental_use_whole_archive_for_native_deps</a>, <a href="#rust_doc-html_after_content">html_after_content</a>,
13-
<a href="#rust_doc-html_before_content">html_before_content</a>, <a href="#rust_doc-html_in_header">html_in_header</a>, <a href="#rust_doc-markdown_css">markdown_css</a>)
12+
rust_doc(<a href="#rust_doc-name">name</a>, <a href="#rust_doc-crate">crate</a>, <a href="#rust_doc-html_after_content">html_after_content</a>, <a href="#rust_doc-html_before_content">html_before_content</a>, <a href="#rust_doc-html_in_header">html_in_header</a>, <a href="#rust_doc-markdown_css">markdown_css</a>)
1413
</pre>
1514

1615
Generates code documentation.
@@ -57,7 +56,6 @@ Running `bazel build //hello_lib:hello_lib_doc` will build a zip file containing
5756
| :------------- | :------------- | :------------- | :------------- | :------------- |
5857
| <a id="rust_doc-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
5958
| <a id="rust_doc-crate"></a>crate | The label of the target to generate code documentation for.<br><br><code>rust_doc</code> can generate HTML code documentation for the source files of <code>rust_library</code> or <code>rust_binary</code> targets. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
60-
| <a id="rust_doc-experimental_use_whole_archive_for_native_deps"></a>experimental_use_whole_archive_for_native_deps | Whether to use +whole-archive linking modifier for native dependencies.<br><br>TODO: This is a stopgap feature and will be removed, see https://github.com/bazelbuild/rules_rust/issues/1268. | Boolean | optional | False |
6159
| <a id="rust_doc-html_after_content"></a>html_after_content | File to add in <code>&lt;body&gt;</code>, after content. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
6260
| <a id="rust_doc-html_before_content"></a>html_before_content | File to add in <code>&lt;body&gt;</code>, before content. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
6361
| <a id="rust_doc-html_in_header"></a>html_in_header | File to add to <code>&lt;head&gt;</code>. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
@@ -69,7 +67,7 @@ Running `bazel build //hello_lib:hello_lib_doc` will build a zip file containing
6967
## rust_doc_test
7068

7169
<pre>
72-
rust_doc_test(<a href="#rust_doc_test-name">name</a>, <a href="#rust_doc_test-crate">crate</a>, <a href="#rust_doc_test-deps">deps</a>, <a href="#rust_doc_test-experimental_use_whole_archive_for_native_deps">experimental_use_whole_archive_for_native_deps</a>)
70+
rust_doc_test(<a href="#rust_doc_test-name">name</a>, <a href="#rust_doc_test-crate">crate</a>, <a href="#rust_doc_test-deps">deps</a>)
7371
</pre>
7472

7573
Runs Rust documentation tests.
@@ -118,6 +116,5 @@ Running `bazel test //hello_lib:hello_lib_doc_test` will run all documentation t
118116
| <a id="rust_doc_test-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
119117
| <a id="rust_doc_test-crate"></a>crate | The label of the target to generate code documentation for. <code>rust_doc_test</code> can generate HTML code documentation for the source files of <code>rust_library</code> or <code>rust_binary</code> targets. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
120118
| <a id="rust_doc_test-deps"></a>deps | List of other libraries to be linked to this library target.<br><br>These can be either other <code>rust_library</code> targets or <code>cc_library</code> targets if linking a native library. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
121-
| <a id="rust_doc_test-experimental_use_whole_archive_for_native_deps"></a>experimental_use_whole_archive_for_native_deps | Whether to use +whole-archive linking modifier for native dependencies.<br><br>TODO: This is a stopgap feature and will be removed, see https://github.com/bazelbuild/rules_rust/issues/1268. | Boolean | optional | False |
122119

123120

rust/private/rust.bzl

-9
Original file line numberDiff line numberDiff line change
@@ -497,15 +497,6 @@ _common_attrs = {
497497
"edition": attr.string(
498498
doc = "The rust edition to use for this crate. Defaults to the edition specified in the rust_toolchain.",
499499
),
500-
"experimental_use_whole_archive_for_native_deps": attr.bool(
501-
doc = dedent("""\
502-
Whether to use +whole-archive linking modifier for native dependencies.
503-
504-
TODO: This is a stopgap feature and will be removed,
505-
see https://github.com/bazelbuild/rules_rust/issues/1268.
506-
"""),
507-
default = False,
508-
),
509500
# Previously `proc_macro_deps` were a part of `deps`, and then proc_macro_host_transition was
510501
# used into cfg="host" using `@local_config_platform//:host`.
511502
# This fails for remote execution, which needs cfg="exec", and there isn't anything like

rust/private/rustc.bzl

+18-23
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ def construct_arguments(
780780
rustc_flags.add("--codegen=linker=" + ld)
781781
rustc_flags.add_joined("--codegen", link_args, join_with = " ", format_joined = "link-args=%s")
782782

783-
_add_native_link_flags(rustc_flags, dep_info, linkstamp_outs, ambiguous_libs, crate_info.type, toolchain, cc_toolchain, feature_configuration, attr.experimental_use_whole_archive_for_native_deps)
783+
_add_native_link_flags(rustc_flags, dep_info, linkstamp_outs, ambiguous_libs, crate_info.type, toolchain, cc_toolchain, feature_configuration)
784784

785785
# These always need to be added, even if not linking this crate.
786786
add_crate_link_flags(rustc_flags, dep_info, force_all_deps_direct)
@@ -1293,15 +1293,11 @@ def _get_crate_dirname(crate):
12931293
"""
12941294
return crate.output.dirname
12951295

1296-
def _portable_link_flags(lib, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps):
1296+
def _portable_link_flags(lib, use_pic, ambiguous_libs):
12971297
artifact = get_preferred_artifact(lib, use_pic)
12981298
if ambiguous_libs and artifact.path in ambiguous_libs:
12991299
artifact = ambiguous_libs[artifact.path]
13001300
if lib.static_library or lib.pic_static_library:
1301-
modifiers = ""
1302-
if experimental_use_whole_archive_for_native_deps:
1303-
modifiers = ":+whole-archive"
1304-
13051301
# To ensure appropriate linker library argument order, in the presence
13061302
# of both native libraries that depend on rlibs and rlibs that depend
13071303
# on native libraries, we use an approach where we "sandwich" the
@@ -1319,7 +1315,7 @@ def _portable_link_flags(lib, use_pic, ambiguous_libs, experimental_use_whole_ar
13191315
# We rely in the behavior of -Clink-arg to put the linker args
13201316
# at the end of the linker invocation constructed by rustc.
13211317
return [
1322-
"-lstatic%s=%s" % (modifiers, get_lib_name(artifact)),
1318+
"-lstatic=%s" % get_lib_name(artifact),
13231319
"-Clink-arg=-l%s" % get_lib_name(artifact),
13241320
]
13251321
elif _is_dylib(lib):
@@ -1329,18 +1325,18 @@ def _portable_link_flags(lib, use_pic, ambiguous_libs, experimental_use_whole_ar
13291325

13301326
return []
13311327

1332-
def _make_link_flags_windows(linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps):
1333-
linker_input, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps = linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps
1328+
def _make_link_flags_windows(linker_input_and_use_pic_and_ambiguous_libs):
1329+
linker_input, use_pic, ambiguous_libs = linker_input_and_use_pic_and_ambiguous_libs
13341330
ret = []
13351331
for lib in linker_input.libraries:
13361332
if lib.alwayslink:
13371333
ret.extend(["-C", "link-arg=/WHOLEARCHIVE:%s" % get_preferred_artifact(lib, use_pic).path])
13381334
else:
1339-
ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps))
1335+
ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs))
13401336
return ret
13411337

1342-
def _make_link_flags_darwin(linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps):
1343-
linker_input, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps = linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps
1338+
def _make_link_flags_darwin(linker_input_and_use_pic_and_ambiguous_libs):
1339+
linker_input, use_pic, ambiguous_libs = linker_input_and_use_pic_and_ambiguous_libs
13441340
ret = []
13451341
for lib in linker_input.libraries:
13461342
if lib.alwayslink:
@@ -1349,11 +1345,11 @@ def _make_link_flags_darwin(linker_input_and_use_pic_and_ambiguous_libs_and_expe
13491345
("link-arg=-Wl,-force_load,%s" % get_preferred_artifact(lib, use_pic).path),
13501346
])
13511347
else:
1352-
ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps))
1348+
ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs))
13531349
return ret
13541350

1355-
def _make_link_flags_default(linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps):
1356-
linker_input, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps = linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps
1351+
def _make_link_flags_default(linker_input_and_use_pic_and_ambiguous_libs):
1352+
linker_input, use_pic, ambiguous_libs = linker_input_and_use_pic_and_ambiguous_libs
13571353
ret = []
13581354
for lib in linker_input.libraries:
13591355
if lib.alwayslink:
@@ -1366,16 +1362,16 @@ def _make_link_flags_default(linker_input_and_use_pic_and_ambiguous_libs_and_exp
13661362
"link-arg=-Wl,--no-whole-archive",
13671363
])
13681364
else:
1369-
ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps))
1365+
ret.extend(_portable_link_flags(lib, use_pic, ambiguous_libs))
13701366
return ret
13711367

1372-
def _libraries_dirnames(linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps):
1373-
link_input, use_pic, _, _ = linker_input_and_use_pic_and_ambiguous_libs_and_experimental_use_whole_archive_for_native_deps
1368+
def _libraries_dirnames(linker_input_and_use_pic_and_ambiguous_libs):
1369+
link_input, use_pic, _ = linker_input_and_use_pic_and_ambiguous_libs
13741370

13751371
# De-duplicate names.
13761372
return depset([get_preferred_artifact(lib, use_pic).dirname for lib in link_input.libraries]).to_list()
13771373

1378-
def _add_native_link_flags(args, dep_info, linkstamp_outs, ambiguous_libs, crate_type, toolchain, cc_toolchain, feature_configuration, experimental_use_whole_archive_for_native_deps):
1374+
def _add_native_link_flags(args, dep_info, linkstamp_outs, ambiguous_libs, crate_type, toolchain, cc_toolchain, feature_configuration):
13791375
"""Adds linker flags for all dependencies of the current target.
13801376
13811377
Args:
@@ -1387,7 +1383,6 @@ def _add_native_link_flags(args, dep_info, linkstamp_outs, ambiguous_libs, crate
13871383
toolchain (rust_toolchain): The current `rust_toolchain`
13881384
cc_toolchain (CcToolchainInfo): The current `cc_toolchain`
13891385
feature_configuration (FeatureConfiguration): feature configuration to use with cc_toolchain
1390-
experimental_use_whole_archive_for_native_deps (bool): Whether to use the whole-archive link modifier for native deps, see https://github.com/bazelbuild/rules_rust/issues/1268
13911386
"""
13921387
if crate_type in ["lib", "rlib"]:
13931388
return
@@ -1402,15 +1397,15 @@ def _add_native_link_flags(args, dep_info, linkstamp_outs, ambiguous_libs, crate
14021397
make_link_flags = _make_link_flags_default
14031398

14041399
# TODO(hlopko): Remove depset flattening by using lambdas once we are on >=Bazel 5.0
1405-
args_and_pic_and_ambiguous_libs_and_use_whole_archive_for_native_deps = [(arg, use_pic, ambiguous_libs, experimental_use_whole_archive_for_native_deps) for arg in dep_info.transitive_noncrates.to_list()]
1406-
args.add_all(args_and_pic_and_ambiguous_libs_and_use_whole_archive_for_native_deps, map_each = _libraries_dirnames, uniquify = True, format_each = "-Lnative=%s")
1400+
args_and_pic_and_ambiguous_libs = [(arg, use_pic, ambiguous_libs) for arg in dep_info.transitive_noncrates.to_list()]
1401+
args.add_all(args_and_pic_and_ambiguous_libs, map_each = _libraries_dirnames, uniquify = True, format_each = "-Lnative=%s")
14071402
if ambiguous_libs:
14081403
# If there are ambiguous libs, the disambiguation symlinks to them are
14091404
# all created in the same directory. Add it to the library search path.
14101405
ambiguous_libs_dirname = ambiguous_libs.values()[0].dirname
14111406
args.add("-Lnative={}".format(ambiguous_libs_dirname))
14121407

1413-
args.add_all(args_and_pic_and_ambiguous_libs_and_use_whole_archive_for_native_deps, map_each = make_link_flags)
1408+
args.add_all(args_and_pic_and_ambiguous_libs, map_each = make_link_flags)
14141409

14151410
for linkstamp_out in linkstamp_outs:
14161411
args.add_all(["-C", "link-arg=%s" % linkstamp_out.path])

rust/private/rustdoc.bzl

-9
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,6 @@ rust_doc = rule(
265265
providers = [rust_common.crate_info],
266266
mandatory = True,
267267
),
268-
"experimental_use_whole_archive_for_native_deps": attr.bool(
269-
doc = dedent("""\
270-
Whether to use +whole-archive linking modifier for native dependencies.
271-
272-
TODO: This is a stopgap feature and will be removed,
273-
see https://github.com/bazelbuild/rules_rust/issues/1268.
274-
"""),
275-
default = False,
276-
),
277268
"html_after_content": attr.label(
278269
doc = "File to add in `<body>`, after content.",
279270
allow_single_file = [".html", ".md"],

rust/private/rustdoc_test.bzl

-9
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,6 @@ rust_doc_test = rule(
181181
"""),
182182
providers = [CrateInfo, CcInfo],
183183
),
184-
"experimental_use_whole_archive_for_native_deps": attr.bool(
185-
doc = dedent("""\
186-
Whether to use +whole-archive linking modifier for native dependencies.
187-
188-
TODO: This is a stopgap feature and will be removed,
189-
see https://github.com/bazelbuild/rules_rust/issues/1268.
190-
"""),
191-
default = False,
192-
),
193184
"_cc_toolchain": attr.label(
194185
doc = (
195186
"In order to use find_cc_toolchain, your rule has to depend " +

0 commit comments

Comments
 (0)