Skip to content

FR: Add ability to generate clang serialized diagnostics files for CC builds #15191

Closed

Description

@brentleyjones

Description of the feature request:

Allow (probably via a feature) the ability for C/C++/Obj-C files to generate clang serialized diagnostics files (--serialized-diagnostics) for each source file. The file should be handled similar to the .d file, and be a declared dependency.

What underlying problem are you trying to solve with this feature?

I have an IDE integration (Xcode) use case where I want --serialized-diagnostics source_file.dia to be applied to each C/C++/Obj-C compilation, as the IDE consumes this file to report warnings, errors, notes, remarks and fix-its. These files need to be fetched from cache as well, so they need to be a declared output.

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

release 5.1.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

I'm willing to contribute this change, if it will be accepted.

Activity

  1. added
    team-Rules-CPP
    untriaged
    on Apr 8, 2022
  2. added
    P2
    and removed
    untriaged
    on Apr 13, 2022
  3. meteorcloudy commented on Apr 13, 2022

    @meteorcloudy
    Member

    @oquenchil Do you think it's possible to implement this as an aspect or a custom C++ toolchain?
    @brentleyjones If we need to change Bazel's C++ rules, we better have a quick design doc for this. Also C++ rules are being starlarkified, maybe it can be implemented in the C++ starlark rule?

  4. DavidGoldman commented on Apr 17, 2022

    @DavidGoldman
    Contributor

    This seems like a reasonable FR - -serialize-diagnostic-file and --serialize-diagnostics are both available in upstream Clang (it's not specific to Apple's fork). This should be implemented by modifying the CC/ObjC rules, not via an aspect, since the additional file should be produced by the original compilation action (not via an additional action) - the overhead of producing it is minimal compared to the time to load the AST/TU. Controlling this with a feature that's disabled by default seems reasonable.

  5. meteorcloudy commented on Apr 19, 2022

    @meteorcloudy
    Member

    @brentleyjones I guess implementing this as a feature is relatively simple, feel free to send a PR.

  6. meteorcloudy commented on Apr 19, 2022

    @meteorcloudy
    Member

    @comius @oquenchil In generally, I think we should have a way to "inject" features for the default cc toolchain so that users don't have to fully maintain their own cc toolchain, and can just say I want to add this feature to the default cc toolchain.

  7. oquenchil commented on Apr 20, 2022

    @oquenchil
    Contributor

    @comius @oquenchil In generally, I think we should have a way to "inject" features for the default cc toolchain so that users don't have to fully maintain their own cc toolchain, and can just say I want to add this feature to the default cc toolchain.

    Totally agree with this and this has been in the back of my mind for years but never had time to work on it. A design doc for functionality that allows this injection would be very welcome.

  8. brentleyjones commented on May 4, 2022

    @brentleyjones
    ContributorAuthor

    Sorry for the delay. I've opened a PR here: #15403. And I have the cherry-pick for 5.2 ready once that lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2team-Rules-CPPtype: feature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions