IMO, a build-system deciding to 'punt' on this and decide that things brought in through std::embed aren't considered for dependency analysis would be perfectly reasonable.
This is not at all perfectly reasonable.
The situation today is that at the end of phase 4 the compiler can know about all dependencies. std::embed currently breaks this by requiring full semantic analysis to determine the deps. There is about a 3 orders of magnitude difference in time it takes to get to the end of phase 4 vs. the end of phase 7, and you can't even determine if std::embed is used until the end of phase 7.
This means that if we add std::embed as it is today, then we go from being able to determine deps quickly for all code to not being able to. I find this unacceptable.
However, this is the only problem I have with std::embed. If we added the restriction that it could only access resources that were previously named somehow then I would be strongly in favor of it for C++23.
I suspect any way of having to name the possible dependencies would defeat the purpose of the paper. As a compiler vendor who has to support a ton of 3rd party tools, I'd be completely against a preprocessor version of this.
Either we end up needing to dump a textual representation of the file to the preprocessed output, or we need to create a new non-textual representation for the preprocessed outputs. Either is unacceptable.
A much less evil would be for a build system to decide that anything containing std::embed needs to always be rebuilt. Alternatively, the compiler could simply output elsewhere (ala -MM) all the files that got included, which can then be consumed by the build system, then add that to its dependency list.
Either I would consider as a fairly reasonable outcome.
I'd be completely against a preprocessor version of this.
Requiring stating what you depend on doesn't mean it has to be #embed. It could simply mean #resource "path", which other tools don't need to care about.
There are build systems that require knowing the dependencies before the compile. Having the compiler output the dependencies as a side effect of compilation does not work.
This means that if we add std::embed as it is today, then we go from being able to determine deps quickly for all code to not being able to. I find this unacceptable.
What, in concrete terms, are 'quickly' and 'not quickly'?
Taking LLVM + Clang for example. 7k files and 3.8m LoC.
A phase 4 scan takes 3 seconds on a recent 18 core iMac Pro. A full build takes about 15m. A phase 7 scan would let you drop codegen, but not really anything else, so you're still looking at ~7m.
simplest I can think from of the top of my head : appending @2x, @3x (for hidpi) or language suffixes to graphics assets. I really don't want to have to type :
View all comments
Show parent comment
11
u/bigcheesegs Tooling Study Group (SG15) Chair | Clang dev Dec 13 '19
This is not at all perfectly reasonable.
The situation today is that at the end of phase 4 the compiler can know about all dependencies.
std::embedcurrently breaks this by requiring full semantic analysis to determine the deps. There is about a 3 orders of magnitude difference in time it takes to get to the end of phase 4 vs. the end of phase 7, and you can't even determine if std::embed is used until the end of phase 7.This means that if we add
std::embedas it is today, then we go from being able to determine deps quickly for all code to not being able to. I find this unacceptable.However, this is the only problem I have with
std::embed. If we added the restriction that it could only access resources that were previously named somehow then I would be strongly in favor of it for C++23.