bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.71k stars 3.98k forks source link

Possibility to add extra outputs for cc_common.compile and cc_common.link #12843

Open blaizard opened 3 years ago

blaizard commented 3 years ago

Description of the feature request:

This is a feature request to add the possibility to gather extra outputs for the compile and linking actions of the cc toolchain via cc_common.compile and cc_common.link. The interface could be as simple as adding an attribute extra_outputs to these 2 functions.

Feature requests: what underlying problem are you trying to solve with this feature?

This would enable gathering artifacts like map file (-Wl,-Map=...) or stack usage files (-fstack-usage) for example.

As a workaround, one can use cc_common.create_link_variables + cc_common.get_memory_inefficient_command_line + ctx.actions.run but there seem to be a significant amount of code needed to achieve the same result (see here for example),

This would solve https://github.com/bazelbuild/bazel/issues/6718

emusand commented 2 years ago

This feature would be very useful for my work group as well.

I think that we should add this support to the cc_library and cc_binaryrules as well, to keep the cc_libraryand cc_common.compile, and the cc_binary and cc_common.link, interfaces aligned and to avoid forcing users to write custom rules if they want to save additional compile and link artifacts in their build chains.

emusand commented 2 years ago

(This feature was also mentioned in the following thread: https://groups.google.com/g/bazel-discuss/c/ZlB7gjfTd7c)

torgil commented 2 years ago

For cc_common.link, this is already implemented, see https://github.com/bazelbuild/bazel/pull/12883 for commit information and example how to extract the map file

lisaonduty commented 2 years ago

Hi @torgil, I wrote a similar issue for cc_binary long time ago, https://github.com/bazelbuild/bazel/issues/6718. But if I got it right your implementation will not impact cc_binary rule? Is it something you plan to do (add the new attribute to cc_binary)?

DhanalakshmiDurairaj commented 1 year ago

Hi Greetings to all, I am working on GHS toolchain. Ccarm compiler generates “per object debug info file” by providing the flag -G and the extension of the file is .dbo. Debug info file for the archive is .dba. GCC toolchain generates per object debug info file with the extension of .dwo and .dwp (for archive) by providing the flag -gsplit-dwarf. Moreover, I am trying to produce .map file also. How to get these outputs (.dbo,.dba and .map)? Please guide me, is there any way to achieve this without using custom rules?

DhanalakshmiDurairaj commented 1 year ago

hello @torgil and @oquenchil Can you please let me know how to produce additional outputs like .dbo,.dba and .map Does Bazel support without using custom rules.

github-actions[bot] commented 1 month ago

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

brentleyjones commented 1 month ago

We still need this to be able to declare additional compile outputs, like .indexstore directories or other custom single-file outputs.