use "INSERT AFTER" in embedded-test.x#67
Conversation
|
Thank you for deep-diving into this. That is a nice solution. |
Signed-off-by: Kaspar Schleiser <kaspar@schleiser.de>
Signed-off-by: Kaspar Schleiser <kaspar@schleiser.de>
Done, not sure about the wording ... |
|
Thank you. |
It can wait, we can use this from our branch for now. Thanks! |
I don't know what you did, but naively trying to update embedded-test results in esp-hal tests failing to compile with |
can you share a failing build? |
This comment was marked as outdated.
This comment was marked as outdated.
|
You can now see the build errors e.g. at https://github.com/esp-rs/esp-hal/actions/runs/16747543756/job/47409604439?pr=3889 |
hmm, fails on xtensa only. |
|
I think I did test on xtensa, wouldn't swear on it though. I'm on vacations for two more weeks, will deal with it then! |
TL/DR: add
INSERT AFTER .comment;toembedded-test.xso it never overrides a default linker script.Currently, the
embedded-test.xis supposed to be added to builds by adding-Tembedded-test.xto the linker args.-Tfoois used to specify a new default linker script. If multiple linker scripts are added using-T..., the first replaces the default script, the rest is then considered to be augmenting other linker scripts.On embedded, there are usually other linker scripts before
-Tembedded-test.x, e.g., on cortex-m, it is-Tlink.x.Now on std, we don't usually have another linker script, and some ld/lld provided default script is used. Here, adding
-Tembedded-test.xwould override that default script, causing linking to fail.For the std example, I worked around that by not using
-Tbut adding a relative path to the in-repoembedded-test.x. That works in this repo, for this example, but requires similar action for any users. The ususalprintln!("cargo::rustc-link-arg-tests=-Tembedded-test.x");doesn't work on std.I went into a deep dive on how this works, and found out:
-T, the linker search path is not used.-lfilename, and don't forcably uselibfilenameiffilenameis prefixed with:, but only GNU ld accepts linker scripts this wayINSERT AFTER/BEFORE, even if it is added using-T.So in order to not override the default linker script on std, I've added
INSERT AFTER .comment;intoembedded-test.x. In my testing, that.commentsection is inserted by GNU ld and lld on linux, cortex-m, riscv and xtensa.Signed-off-by: Kaspar Schleiser kaspar@schleiser.de