Skip to content

Commit

Permalink
fix: lld-link (MSVC) fix flags including -l prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
rickvanprim committed May 5, 2023
1 parent a2a1109 commit 2d8e69b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,7 @@ def _portable_link_flags(lib, use_pic, ambiguous_libs, get_lib_name, for_windows
return [] if for_darwin else ["-lstatic=%s" % get_lib_name(artifact)]
return [
"-lstatic=%s" % get_lib_name(artifact),
"-Clink-arg=-l%s" % (get_lib_name(artifact) if not for_windows else artifact.basename),
"-Clink-arg=-l{}".format(get_lib_name(artifact)) if not for_windows else "-Clink-arg={}".format(artifact.basename),
]
elif _is_dylib(lib):
return [
Expand Down
8 changes: 4 additions & 4 deletions test/unit/native_deps/native_deps_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _cdylib_has_native_libs_test_impl(ctx):
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
assert_argv_contains(env, action, "--crate-type=cdylib")
assert_argv_contains(env, action, "-lstatic=native_dep{}".format(pic_suffix))
native_link_arg = "-Clink-arg=-lnative_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep{}".format(pic_suffix)
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep{}".format(pic_suffix)
assert_argv_contains(env, action, native_link_arg)
assert_argv_contains_prefix(env, action, "--codegen=linker=")
return analysistest.end(env)
Expand All @@ -51,7 +51,7 @@ def _staticlib_has_native_libs_test_impl(ctx):
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
assert_argv_contains(env, action, "--crate-type=staticlib")
assert_argv_contains(env, action, "-lstatic=native_dep")
native_link_arg = "-Clink-arg=-lnative_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
assert_argv_contains(env, action, native_link_arg)
assert_argv_contains_prefix(env, action, "--codegen=linker=")
return analysistest.end(env)
Expand All @@ -65,7 +65,7 @@ def _proc_macro_has_native_libs_test_impl(ctx):
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
assert_argv_contains(env, action, "--crate-type=proc-macro")
assert_argv_contains(env, action, "-lstatic=native_dep{}".format(pic_suffix))
native_link_arg = "-Clink-arg=-lnative_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep{}".format(pic_suffix)
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep{}".format(pic_suffix)
assert_argv_contains(env, action, native_link_arg)
assert_argv_contains_prefix(env, action, "--codegen=linker=")
return analysistest.end(env)
Expand All @@ -76,7 +76,7 @@ def _bin_has_native_libs_test_impl(ctx):
action = tut.actions[0]
assert_argv_contains_prefix_suffix(env, action, "-Lnative=", "/native_deps")
assert_argv_contains(env, action, "-lstatic=native_dep")
native_link_arg = "-Clink-arg=-lnative_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
native_link_arg = "-Clink-arg=native_dep.lib" if ctx.target_platform_has_constraint(ctx.attr._windows_constraint[platform_common.ConstraintValueInfo]) else "-Clink-arg=-lnative_dep"
assert_argv_contains(env, action, native_link_arg)
assert_argv_contains_prefix(env, action, "--codegen=linker=")
return analysistest.end(env)
Expand Down

0 comments on commit 2d8e69b

Please sign in to comment.