cc-rs
cc-rs copied to clipboard
Map source absolute paths to OUT_DIR as relative.
If a source file was specified by absolute path, then the corresponding object file was placed into OUT_DIR. This posed a problem if multiple files with the same base name were specified by absolute paths.
Fixes #683.
This method can still cause multiple distinct paths to be mapped to the same object file.
For example, all these source files will be mapped to the same object file:
foo/bar.c -> OUT_DIR/foo/bar.o
/home/me/foo/bar.c -> OUT_DIR/foo/bar.o
/home/foo/bar.c -> OUT_DIR/foo/bar.o
A different option could be to include a hash of the source path in the object name. That avoids clashes without producing very long file paths.
Well, arguably suggested scenario is unlikely to be a common case, but I've added unique prefix based on absolute path for maintainers to consider :-)
I'd remove the path grafting entirely now. I'd even consider doing the same for relative paths and dump all object files in one directory. Although I guess it's nice to mimic the directory structure for relative paths.
I'd remove the path grafting entirely now.
Even for relative paths? The original idea was to be as conservative as possible. I mean not changing the way it currently works in the most common case of relative paths. As for absolute paths, yeah, I've thought of "flattening" and reckoned that keeping traces of the directory structure could be helpful for trouble-shooting purposes. But sure, it's definitely a viable option. For both relative and absolute paths. Nobody traverses the object files' destination directories anyway...
I've thought of "flattening" and reckoned that keeping traces of the directory structure could be helpful for trouble-shooting purposes.
On the other hand, one can totally say that "flattening" would actually be more a conservative approach, because that's how the absolute paths are treated now. Fair enough, I'll remove the grafting for absolute paths and let maintainers choose [or express their preferences]...
Note for maintainers. There are three suggestions to consider, one per commit. First one attempts to graft subdirectories of absolute source files' paths to output directory. The second one prefixes object files with source directories' hashes. And the third one removes grafting. There is also suggestion to use hashes as prefixes even with relative paths.
This seems fine -- I prefer this approach to flattening.
Could you clarify the course of further actions for me here. I mean should I remove all commits but the fist here, or do you simply cherry-pick it yourself?
Sorry, that wasn't about the commit structure. I just forgot to merge