Skip to content

Commit fc4d978

Browse files
committed
no flavors?
1 parent b28e8ce commit fc4d978

File tree

3 files changed

+16
-32
lines changed

3 files changed

+16
-32
lines changed

rust/private/rustc.bzl

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ def _get_crate_dirname(crate):
19461946
"""
19471947
return crate.output.dirname
19481948

1949-
def _portable_link_flags(lib, use_pic, get_lib_name, for_windows = False, for_darwin = False, flavor_msvc = False):
1949+
def _portable_link_flags(lib, use_pic, for_darwin = False):
19501950
artifact = get_preferred_artifact(lib, use_pic)
19511951
if lib.static_library or lib.pic_static_library:
19521952
# To ensure appropriate linker library argument order, in the presence
@@ -1984,20 +1984,8 @@ def _portable_link_flags(lib, use_pic, get_lib_name, for_windows = False, for_da
19841984
):
19851985
return [] if for_darwin else ["-Clink-arg=%s" % artifact.path]
19861986

1987-
if for_windows:
1988-
if flavor_msvc:
1989-
return [
1990-
"-lstatic=%s" % get_lib_name(artifact),
1991-
"-Clink-arg={}".format(artifact.basename),
1992-
]
1993-
else:
1994-
return [
1995-
"-Clink-arg=%s" % artifact.path,
1996-
]
1997-
else:
1998-
return [
1999-
"-Clink-arg=%s" % artifact.path,
2000-
]
1987+
return ["-Clink-arg=%s" % artifact.path]
1988+
20011989
elif _is_dylib(lib):
20021990
return [
20031991
"-Clink-arg=%s" % artifact.path,
@@ -2022,7 +2010,7 @@ def _make_link_flags_windows(make_link_flags_args, flavor_msvc):
20222010
"-Clink-arg=-Wl,--no-whole-archive",
20232011
])
20242012
elif include_link_flags:
2025-
ret.extend(_portable_link_flags(lib, use_pic, get_lib_name_for_windows, for_windows = True, flavor_msvc = flavor_msvc))
2013+
ret.extend(_portable_link_flags(lib, use_pic))
20262014
_add_user_link_flags(ret, linker_input)
20272015
return ret
20282016

@@ -2039,7 +2027,7 @@ def _make_link_flags_darwin(make_link_flags_args):
20392027
if lib.alwayslink:
20402028
ret.append("-Clink-arg=-Wl,-force_load,%s" % get_preferred_artifact(lib, use_pic).path)
20412029
elif include_link_flags:
2042-
ret.extend(_portable_link_flags(lib, use_pic, get_lib_name_default, for_darwin = True))
2030+
ret.extend(_portable_link_flags(lib, use_pic, for_darwin = True))
20432031
_add_user_link_flags(ret, linker_input)
20442032
return ret
20452033

@@ -2054,7 +2042,7 @@ def _make_link_flags_default(make_link_flags_args):
20542042
"-Clink-arg=-Wl,--no-whole-archive",
20552043
])
20562044
elif include_link_flags:
2057-
ret.extend(_portable_link_flags(lib, use_pic, get_lib_name_default))
2045+
ret.extend(_portable_link_flags(lib, use_pic))
20582046
_add_user_link_flags(ret, linker_input)
20592047
return ret
20602048

test/unit/ambiguous_libs/ambiguous_libs_test.bzl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ def _ambiguous_deps_test_impl(ctx):
2424

2525
# We depend on two C++ libraries named "native_dep", which we need to pass to the command line
2626
# in the form of "-Clink-arg=${pwd}/bazel-out/darwin_arm64-fastbuild/bin/test/unit/ambiguous_libs/first_dep/libnative_dep.a"
27-
for arg in rustc_action.argv:
28-
print("_ambiguous_deps_test_impl", arg)
29-
link_args = [arg for arg in rustc_action.argv if arg.endswith("libnative_dep{}.a".format(pic_suffix))]
27+
if ctx.target_platform_has_constraint(
28+
ctx.attr._windows_constraint[platform_common.ConstraintValueInfo],
29+
):
30+
lib_name = "native_dep{}.lib".format(pic_suffix)
31+
else:
32+
lib_name = "libnative_dep{}.a".format(pic_suffix)
33+
34+
link_args = [arg for arg in rustc_action.argv if arg.endswith(lib_name)]
3035
asserts.equals(env, 2, len(link_args))
3136
asserts.false(env, link_args[0] == link_args[1])
3237

test/unit/proc_macro/leaks_deps/proc_macro_does_not_leak_deps.bzl

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
44
load("//rust:defs.bzl", "rust_library", "rust_proc_macro", "rust_test")
55

6-
def _get_toolchain(ctx):
7-
return ctx.attr._toolchain[platform_common.ToolchainInfo]
8-
96
def _proc_macro_does_not_leak_deps_impl(ctx):
107
env = analysistest.begin(ctx)
118
actions = analysistest.target_under_test(env).actions
@@ -14,7 +11,6 @@ def _proc_macro_does_not_leak_deps_impl(ctx):
1411
if action.mnemonic == "Rustc":
1512
rustc_action = action
1613
break
17-
toolchain = _get_toolchain(ctx)
1814

1915
asserts.false(env, rustc_action == None)
2016

@@ -29,10 +25,7 @@ def _proc_macro_does_not_leak_deps_impl(ctx):
2925
# Our test target depends on proc_macro_dep:native directly, as well as transitively through the
3026
# proc_macro. The proc_macro should not leak its dependency, so we should only get the "native"
3127
# library once on the command line.
32-
if toolchain.target_os == "windows" and toolchain.target_triple.abi == "msvc":
33-
native_deps = [arg for arg in rustc_action.argv if arg == "-Clink-arg=native.lib"]
34-
else:
35-
native_deps = [arg for arg in rustc_action.argv if arg.endswith("test/unit/proc_macro/leaks_deps/native/libnative.a")]
28+
native_deps = [arg for arg in rustc_action.argv if arg.endswith("test/unit/proc_macro/leaks_deps/native/libnative.a")]
3629
asserts.equals(env, 1, len(native_deps))
3730

3831
return analysistest.end(env)
@@ -73,9 +66,7 @@ def _proc_macro_does_not_leak_deps_test():
7366
target_under_test = ":deps_not_leaked",
7467
)
7568

76-
proc_macro_does_not_leak_deps_test = analysistest.make(_proc_macro_does_not_leak_deps_impl, attrs = {
77-
"_toolchain": attr.label(default = Label("//rust/toolchain:current_rust_toolchain")),
78-
})
69+
proc_macro_does_not_leak_deps_test = analysistest.make(_proc_macro_does_not_leak_deps_impl)
7970

8071
# Tests that a lib_a -> proc_macro -> lib_b does not propagate lib_b to the inputs of lib_a
8172
def _proc_macro_does_not_leak_lib_deps_impl(ctx):

0 commit comments

Comments
 (0)