Skip to content

Commit

Permalink
buck2: add a buck2-only linker wrapper rule that preserves exe / flag…
Browse files Browse the repository at this point in the history
…s difference

Summary:
Doing this to help D48329688. For the Go rules, they want to be able to separate linker cmd and linker flags, but here we
have a bunch of linker flags that actually come via the linker cmd!

This fixes that by allowing the linker wrappers in fbcode to expose the separation between cmd and flags, and then the
toolchain implementation can place the flags where they belong.

Reviewed By: cjhopman

Differential Revision: D48899332

fbshipit-source-id: fdfd117996ae556d70b845b569ca1d6bb1ecb965
  • Loading branch information
krallin authored and facebook-github-bot committed Sep 7, 2023
1 parent db4c3d5 commit 9fe37d2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion prelude/cxx/cxx_link_utility.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def executable_shared_lib_arguments(

return (extra_args, runtime_files, shared_libs_symlink_tree)

def cxx_link_cmd_parts(ctx: AnalysisContext) -> (RunInfo.type, cmd_args):
def cxx_link_cmd_parts(ctx: AnalysisContext) -> ((RunInfo.type | cmd_args), cmd_args):
toolchain = get_cxx_toolchain_info(ctx)

# `toolchain_linker_flags` can either be a list of strings, `cmd_args` or `None`,
Expand Down
6 changes: 6 additions & 0 deletions prelude/cxx/cxx_toolchain_types.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

load("@prelude//cxx:debug.bzl", "SplitDebugMode")

# For cases where our `ld` dependency provides more than an executable and
# would like to give us flags too. We use this to place the flags in the proper
# field (linker_flags), so that things that want ldflags without the linker
# executable can access those.
RichLinkerRunInfo = provider(fields = ["exe", "flags"])

LinkerType = ["gnu", "darwin", "windows"]

ShlibInterfacesMode = enum("disabled", "enabled", "defined_only")
Expand Down

0 comments on commit 9fe37d2

Please sign in to comment.