WIP: libcpp and cp: ✨ __builtin_std_embed and #depend implementation, alongside libstdc++-v3 <embed> and version.h header improvements #181
No reviewers
Labels
No labels
Compat/Breaking
Frontend/ada
Frontend/c
Frontend/c++
Frontend/rust
General/forge
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Library/libgcc
Library/libstdc++
Midend/gimple
Midend/rtl
Midend/tree
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Target/aarch64
Target/arm
Target/i386
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gcc/gcc!181
Loading…
Reference in a new issue
No description provided.
Delete branch "ThePhD/gcc-TEST:feature/cxx/std_embed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a Work-In-Progress Pull Request that implements P1040, that is mostly here to ensure that I keep track of everything that is going on.
__builtin_std_embedfor the C++ Frontend onlystring_constantand other non-middle-end code to the general frontend for use with all frontends, where appropriate.static constexpr const T[]invisible arrayswchar_tpath name handling for__builtin_std_embed(not implemented; must translate from wide literal encoding usingwcset_converterthat comes from preprocessor -- how do we accesscpp_reader *in the frontend there?)Hi @ThePhD. This bot helps send your PR as a patch series to the mailing list.
Next steps
CC: Reviewer1 <revi.ewer@example.com>, Reviewer2 <an.other@example.com>./preview./submit.Changes since vXsection, and comment with/submitagain.See Submitting Patches and UsingForge.
Consider joining the gcc and gcc-patches mailing lists..
For real time communication, check the gcc irc channels.
Or join
#overseerson Libera Chat, particularly if this automation is not working (stay online to get replies, IRC does not save messages if people are not online).libcpp and cp: ✨ __builtin_std_embed and #depend implementation, alongside libstdc++-v3 <embed> and version.h header improvementsto WIP: libcpp and cp: ✨ __builtin_std_embed and #depend implementation, alongside libstdc++-v3 <embed> and version.h header improvementsbc3091058de8fcf02ad1e8fcf02ad108293254c208293254c27c61609724Why is there an emoji style '✨' in the commit subject? If you mean an asterisk (star), please use that.
7c616097246d2d1960e26d2d1960e2ddfb97a1e0Just some random comments.
I think the actual file reading should be done on the libcpp side, libcpp already has infrastructure to handle #embed, cache files that can be cached etc. and it would be nice if as much of that code is reused and files can be cached between #embed and __builtin_std_embed, so let the FE figure out the name of the file (using libcpp charset APIs to put it into the right character set) and then ask libcpp to check against #depend and load the file and return the preprocessor buffer containing it.
The code should be able to handle even > 2GiB std::embed calls, which it currently does no, both STRING_CST and RAW_DATA_CST have the 2GiB limitation. But for the latter one can just use several of those, so say for 6GiB minus epsilon use a CONSTRUCTOR with 3 RAW_DATA_CSTs in it, each covering roughly 2GiB.
Wc++29-extensions addition will conflict with https://gcc.gnu.org/pipermail/gcc-patches/2026-June/720168.html
In cxx_eval_builtin_function_call, if only one FE builtin uses arg_locs, perhaps it should be computed just when handling that builtin and not all the other ones.
And some coding style nits:
Some newly added functions don't have a function comment.
if/else/while/for body with a single statement in it shouldn't use {}s around that single statement.
We don't normally use something like
internal_error ("incorrect number of %<__builtin_std_embed%> arguments");Instead just gcc_assert (the_condition).
Lines shouldn't end with = and with initializer on next line, instead the = should be moved before the initializer.
Similarly e.g. for colon.
Instead of %llu and (unsigned long long int) casts when printing HOST_WIDE_INT using a gcc diagnostic function
one should use %wu and no cast.
I don't think we use -> tree on lambdas normally.
Some calls don't have a space between function name and (.
const char * first_rslash = strrchr (lookup_from, '\\');there should be no space after *. Also wonder about the '/' searches, should that be always / and not HAVE_DOS_BASED_FILE_SYSTEM dependent?There is a spurious character before wchar_t.
I think constant_byte_string etc. should stay where they are.
The ^L character removals are undesirable.
@jason @marek
Thanks @rearnsha and @jakub for the comments -- it will be a bit before I return to this PR, since I do have to wait for LEWG to approve the last changes they made. But after that I will be back to address all the comments; please don't take my silence as non-interest, there's just a lot to do!
ddfb97a1e0a9eda9452ca9eda9452c32705f355332705f355341699485ca41699485ca637ecc0448View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.