Skip to content

Commit

Permalink
Fix linking build errors with for.
Browse files Browse the repository at this point in the history
This fixes two errors found when trying to build the new Starlark linking stuff:
- In link_action, in cpp_link_action.bzl, it referenced NODEPS_DYNAMIC_LIBRARY without importing the definition of it (undefined reference).
- In _can_split_command_line, in finalize_link_action.bzl, it referenced interface_output without passing it into the function (undefined reference).

PiperOrigin-RevId: 694557197
Change-Id: Iaf98ab6c69f350002722e4197ab21656af771178
  • Loading branch information
Googler authored and copybara-github committed Nov 8, 2024
1 parent 8de2fb2 commit df84f4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
load(":common/cc/cc_helper_internal.bzl", "artifact_category")
load(":common/cc/link/finalize_link_action.bzl", "finalize_link_action")
load(":common/cc/link/link_build_variables.bzl", "setup_linking_variables")
load(":common/cc/link/target_types.bzl", "USE_ARCHIVER", "USE_LINKER", "is_dynamic_library")
load(":common/cc/link/target_types.bzl", "LINK_TARGET_TYPE", "USE_ARCHIVER", "USE_LINKER", "is_dynamic_library")
load(":common/paths.bzl", "paths")

cc_common_internal = _builtins.internal.cc_common
Expand Down Expand Up @@ -200,7 +200,7 @@ def link_action(
cc_internal.dynamic_library_soname(
actions,
output.short_path,
link_type != NODEPS_DYNAMIC_LIBRARY,
link_type != LINK_TARGET_TYPE.NODEPS_DYNAMIC_LIBRARY,
),
interface_output.path if interface_output else None,
thinlto_param_file.path if thinlto_param_file else None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def finalize_link_action(
action_outputs,
progress_message,
link_type,
interface_output,
)

def _create_action(
Expand All @@ -277,7 +278,8 @@ def _create_action(
inputs,
outputs,
progress_message,
link_type):
link_type,
interface_output):
"""
Creates C++ linking or LTO indexing action.
Expand All @@ -296,7 +298,12 @@ def _create_action(
"""

parameter_file_type = None
if _can_split_command_line(link_type, cc_toolchain, feature_configuration):
if _can_split_command_line(
link_type,
cc_toolchain,
feature_configuration,
interface_output,
):
if feature_configuration.is_enabled("gcc_quoting_for_param_files"):
parameter_file_type = "GCC_QUOTED"
elif feature_configuration.is_enabled("windows_quoting_for_param_files"):
Expand Down Expand Up @@ -352,7 +359,11 @@ def _create_action(
exec_group = exec_group,
)

def _can_split_command_line(link_type, cc_toolchain, feature_configuration):
def _can_split_command_line(
link_type,
cc_toolchain,
feature_configuration,
interface_output):
if not cc_toolchain._supports_param_files:
return False
elif is_dynamic_library(link_type):
Expand Down

0 comments on commit df84f4e

Please sign in to comment.