yxsamliu wrote:

> > Clang has two save-temps modes: --save-temps (same as --save-temps=cwd) 
> > puts files in the current working directory, while --save-temps=obj puts 
> > them next to the output file. After this change, the linker wrapper always 
> > uses the output file's directory, which matches --save-temps=obj but 
> > diverges from the default --save-temps=cwd behavior. Should we check which 
> > mode was requested and preserve the CWD behavior for the default case?
> 
> Yeah it's a little tough because it's shared between three places now, clang, 
> lld, and linker-wrapper. `lld` just dumps it next to the obj by default I 
> believe. I wonder if we could make this more consistent.

With `--save-temps` (cwd mode), users expect intermediate files in the current 
working directory — that's how clang's own stages behave. The linker wrapper's 
pre-patch code happened to conform to that expectation (by using filename(), 
which effectively placed files in CWD). After this patch, the linker wrapper 
matches lld's behavior instead, which may surprise users who find their 
intermediate files suddenly appearing in the output directory rather than CWD.

Would it be better to pass the full `--save-temps=cwd/--save-temps=obj` option 
through to the linker wrapper instead of collapsing it to a boolean, and then 
preserve the old (CWD) behavior for `--save-temps=cwd` while using the new 
(output-dir) behavior for `--save-temps=obj`? That would keep the linker 
wrapper consistent with how clang handles both modes. As a bonus, lld's 
intermediate files would follow automatically since they derive their location 
from the .img output path.

https://github.com/llvm/llvm-project/pull/198679
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to