Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DebugFission with cc_configure #6606

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion tools/cpp/unix_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ def _is_gold_supported(repository_ctx, cc):
])
return result.return_code == 0

def _is_fission_supported(repository_ctx, cc):
"""Checks if `DebugFission` is supported by the C compiler."""
result = repository_ctx.execute([
cc,
"-gsplit-dwarf",
"-g",
"-c",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need to add -o /dev/null to avoid a non-sensical output file in the tools tree.

str(repository_ctx.path("tools/cpp/empty.cc")),
])
return result.return_code == 0

def _add_compiler_option_if_supported(repository_ctx, cc, option):
"""Returns `[option]` if supported, `[]` otherwise. Doesn't %-escape the option."""
return [option] if _is_compiler_option_supported(repository_ctx, cc, option) else []
Expand Down Expand Up @@ -221,6 +232,10 @@ def _get_no_canonical_prefixes_opt(repository_ctx, cc):
def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
"""Return the content for the CROSSTOOL file, in a dictionary."""
supports_gold_linker = _is_gold_supported(repository_ctx, cc)
supports_fission = False
if supports_gold_linker:
supports_fission = _is_fission_supported(repository_ctx, cc)

cc_path = repository_ctx.path(cc)
if not str(cc_path).startswith(str(repository_ctx.path(".")) + "/"):
# cc is outside the repository, set -B
Expand Down Expand Up @@ -254,7 +269,7 @@ def _crosstool_content(repository_ctx, cc, cpu_value, darwin):
"needsPic": True,
"supports_gold_linker": supports_gold_linker,
"supports_incremental_linker": False,
"supports_fission": False,
"supports_fission": supports_fission,
"supports_interface_shared_objects": False,
"supports_normalizing_ar": False,
"supports_start_end_lib": supports_gold_linker,
Expand Down