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

Adjustable outputDirectoryName #7477

Closed
excitoon opened this issue Feb 20, 2019 · 11 comments
Closed

Adjustable outputDirectoryName #7477

excitoon opened this issue Feb 20, 2019 · 11 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions

Comments

@excitoon
Copy link
Contributor

Description of the problem / feature request:

Hi. I wonder if one can make outputDirectoryName (these {cpu}-{compilation_mode} parts of paths) for the build adjustable from command line. It would help to integrate Bazel into other pipelines because it is necessary to know where output files are. I can run bazel info/bazel cquery, but that will involve extracting, loading and/or configuring, I guess, and therefore it looks like extra overhead.

Have you found anything relevant by searching the web?

https://stackoverflow.com/questions/51292429/bazel-how-to-get-path-to-output-binary
https://stackoverflow.com/questions/47859615/bazel-how-do-you-get-the-path-to-a-generated-file

@jin jin added untriaged team-Bazel General Bazel product/strategy issues team-Configurability platforms, toolchains, cquery, select(), config transitions and removed team-Bazel General Bazel product/strategy issues labels Feb 20, 2019
@gregestren
Copy link
Contributor

You can use --platform_suffix to add a customizable string to the end of that. But you can't replace {cpu}-{compilation_mode} with, say, a string literal because Bazel has to support building the same output for different CPUs in the same build, and each needs a distinct path.

Depending on exactly which outputs you need, can you just look at blaze-bin?

Also see #6526 re: plans to change this naming completely. But that's a longer term effort.

@gregestren gregestren added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Feb 21, 2019
@excitoon
Copy link
Contributor Author

excitoon commented Feb 21, 2019

Thank you for pointing to the issue, @gregestren . Will that cover scenario when we gather artifacts from different platforms and place it to some kind of universal archive (in almost cpu-agnostic way, except its' dependencies)?

@gregestren
Copy link
Contributor

Essentially yes.

The basic problem is Bazel's logic predates concern for multi-platform builds, so it just doesn't address that problem very well. The issue I mentioned, as well as other work, recognizes we need better interfaces for these sorts of problems. So that'll happen - but they''ll need to be properly designed.

Out of curiosity, what kind of multi-platform builds are you interested in? We're doing a lot of work to improve multi-platform support and some cool new features are coming down the pipeline even now.

@excitoon
Copy link
Contributor Author

excitoon commented Feb 26, 2019

@gregestren Thank you for asking. In most easiest case we will need to build some C++ target for x64 and x86 and use both versions of it say in C++ program for x64. Would that be possible?

Actually this is a typical scenario in Windows world because often your program has to communicate with both Windows subsystems, Win32 and Win64.

@gregestren
Copy link
Contributor

Essentially yes. You may also want to review https://bazel.build/roadmaps/configuration.html, which explores new ways to support multiple CPUs in the same binaries.

@excitoon
Copy link
Contributor Author

excitoon commented Mar 5, 2019

I leave this hack here as a quick workaround:

--platform_suffix=/..

@moroten
Copy link
Contributor

moroten commented Jan 23, 2020

Just noticed that //command_line_option:output directory name can be used in transitions and platform mappings, but is hidden from the command line.

/**
* This option is used internally to set output directory name of the <i>host</i> configuration to
* a constant, so that the output files for the host are completely independent of those for the
* target, no matter what options are in force (k8/piii, opt/dbg, etc).
*/
@Option(
name = "output directory name",
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {
OptionEffectTag.LOSES_INCREMENTAL_STATE,
OptionEffectTag.AFFECTS_OUTPUTS,
OptionEffectTag.LOADING_AND_ANALYSIS
},
metadataTags = {OptionMetadataTag.INTERNAL})
public String outputDirectoryName;

@aaron-michaux
Copy link

My system supports a combinatorial set of configurations:

[gcc9, gcc10, gcc11, gcc12, clang12, clang13, ...] x [lto, no-lto] x [opt, dbg, asan, ubsan, tsan] + [clang-tidy, coverage, perf].

If bazel had a hook for a function to programatically generate the output directory, that would be a snap. As it is, switching configurations often means rebuilding.

Platform suffix is cute; however, we're talking 50+ platforms? It's madness!

Working with bazel often seems like you're a chef shopping for dinner, and the only thing available is ready cooked meals. You can sell 100 different types of frozen pizza, or 12 ingredients to create any of them.

@moroten
Copy link
Contributor

moroten commented Nov 5, 2022

@aaron-michaux Just wonder, how would you ideally like the directories organized?

@excitoon
Copy link
Contributor Author

excitoon commented Nov 5, 2022 via email

@aaron-michaux
Copy link

Hi @moroten ,

Bazel, at some stage, has to determine the output directory, using things like "platform suffix" etc. It would be nice to be able to supply a function that has the necessary context (all the config_settings) so that you can just programatically return the directory that you want to use (build with the ingredients), obviating the need for pre-baked features like "platform suffix" (providing ready-made meals).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Configurability platforms, toolchains, cquery, select(), config transitions
Projects
None yet
Development

No branches or pull requests

5 participants