Repository navigation
fix: Support '=' and '$SYSROOT' in linker scripts and inputs - #2720
Conversation
c99a051 to
3d3501f
Compare
| [advisories] | ||
| ignore = [ | ||
| "RUSTSEC-2024-0436", # paste is no longer maintained | ||
| "RUSTSEC-2024-0449", # unsafe-libyaml is no longer maintained |
There was a problem hiding this comment.
We've just merged a change to address this, so this line is no longer needed.
There was a problem hiding this comment.
Can you check if we're able to correctly create a save-dir when a path like $SYSROOT/tmp/input.o is passed to the linker, but no --sysroot is supplied? Specifically, does the save-dir load $D/tmp/input.o (i.e. a saved file inside the save-dir) or does it try to load /tmp/input.o from outside the save-dir (i.e. break the encapsulation of the save-dir).
There was a problem hiding this comment.
Sure! previously, save_dir only expanded forced sysroot prefixes for -L directories, not positional input arguments. When $SYSROOT/tmp/input.o was passed without --sysroot, write_args was emitting the literal $SYSROOT/tmp/input.o into the response file / run-with script, which caused the replay to load /tmp/input.o from outside the save directory and broke encapsulation.
I've added forced-sysroot handling for positional inputs in save_dir.rs::write_args, so it now resolves the path and emits $D/tmp/input.o.
3d3501f to
b9fbc32
Compare
| @@ -0,0 +1,2 @@ | |||
| /* GNU ld script */ | |||
| GROUP ( =/lib/libvalue.a ) | |||
There was a problem hiding this comment.
Does the save-dir code correctly handle paths like this in linker scripts? How about when --sysroot isn't set?
There was a problem hiding this comment.
Thanks for pointing this out. I've pushed an update with save-dir integration tests covering both = and $SYSROOT prefixes, with and without --sysroot.
I also replaced global string substitution with position-based edits to avoid overlapping path replacements.
…-dir tests Use position-based edits in save-dir to avoid replacement overlap bugs, and add integration tests for '=' and '$SYSROOT' scripts without --sysroot.
7b91a99 to
e959c48
Compare
Resolves #2719 by properly handling GNU ld sysroot prefixes (
=and$SYSROOT) across linker scripts, command-line inputs, and search paths.Check
maybe_forced_sysrootbefore checking if the linker script is inside the sysroot inmaybe_apply_sysroot, fixing resolution for in-sysroot scripts specifying=or$SYSROOT.Support the default empty sysroot when
--sysrootis not configured by stripping the prefix without altering absolute/relative path structure.