Open
Description
This is current metadata documentation:
.. cli:option:: -C metadata=<data>
Code generation option ``metadata`` enhances symbol mangling by supplying
additional data used in the hashed suffixes of symbols.
``<data>`` must be a comma-separated list of string literals. The list
must contain at least one element.
Example:
.. code-block::
$ rustc -C metadata=prod,arm32 my_program.rs
Multiple ``metadata`` code generation options are allowed on the command
line, where precedence increases from left to right.
rustc documentation is not clear what a "space-separated list of strings" is.
I haven't found any existing test for multiple metadata options. But I've found this in the compiler code:
for s in &metadata {
// Also incorporate the length of a metadata string, so that we generate
// different values for `-Cmetadata=ab -Cmetadata=c` and
// `-Cmetadata=a -Cmetadata=bc`
hasher.write_usize(s.len());
hasher.write(s.as_bytes());
}
I've also added a dbg!(&metadata)
here and tried this:
rustc -Cmetadata="one two" -Cmetadata="three" -Cmetadata="four,five" ./hello.rs
And the output was this:
[compiler/rustc_span/src/def_id.rs:153] &metadata = [
"one",
"two",
"three",
"four,five",
]
So:
- space separated means
-Cmetadata="a b"
- comma is not the delimiter
- multiple metadata options are allowed and they append to the list (so the rightmost does not override others)
Metadata
Assignees
Labels
No labels