Skip to content

--fission=yes alone does not generate real .dwp files #109

Open
@rrbutani

Description

@rrbutani

My understanding is that --fission is supposed to be a cross-platform way to generate separate debug info files for C/C++ rules (this is definitely stretching it a bit; I think --fission is intended to be .dwo/.dwp specific – that is, it's not supposed to generate .dSYMs on macOS and .pdbs on Windows).

In practice, --fission=yes alone does not generate non-empty .dwp files; --features=per_object_debug_info must also be specified.

This is because unix_cc_toolchain_config.bzl's cc_toolchain_config does not enable the per_object_debug_info feature by default.

Passing in --features=per_object_debug_info to enable it manually (i.e. in a .bazelrc) is sub-optimal because this breaks compilation on other platforms like macOS where -gsplit-dwarf has different behavior and will not produce .dwo files (on macOS debug info lives in the .o files – as in there is no .dwo equivalent – and running with -gsplit-dwarf when producing a binary will produce a .dSYM file, the .dwp equivalent).

It seems better to have the toolchain – which knows the platform it targets and has enough information to choose to enable this feature – handle this rather than to foist this onto users (afaik there isn't a create way to deal with this outside of the toolchain anyways; best I can come up with is build:linux --features=per_object_debug_info and then requiring --config=linux when building for Linux, etc.).

I think it's actually safe for us to enable the per_object_debug_info feature by default on Linux because it's effectively gated on fission:

steps

While we're still using unix_cc_toolchain_config.bzl there's not much we can do about this. These are notes for what to do when we eventually vendor in a version of unix_cc_toolchain_config.bzl (and potentially macOS and Windows host counterparts as well).

It's not clear yet whether this is doable/sensible but it'd be nice to have --fission (or some flag like it) cause rules_cc to generate split debug info for all the targets that support it. This would mean:

All in all, probably not pursuing. We should do the first thing though.

open questions

  • I'm confused about what the features associated with a cc_toolchain actually do.
    • they definitely don't enable those features by default for the associated toolchain
    • they don't seem to indicate what features a toolchain supports (i.e. the per_object_debug_info feature is not associated with the toolchains unix_cc_toolchain_config.bzl produces for macOS but if I enable the feature manually with --features=per_object_debug_info I can see that feature's flags being added to the commands executed)
    • they definitely do not influence toolchain resolution
    • cc_common.create_cc_toolchain_config_info ultimately is backed by ccToolchainConfigInfoFromStarlark but other than getting stored here I haven't really been able to tell what the features that are passed in get used for. I'll look into this more later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions