phosek added a comment. In D83154#2277712 <https://reviews.llvm.org/D83154#2277712>, @phosek wrote:
> In D83154#2277539 <https://reviews.llvm.org/D83154#2277539>, @rnk wrote: > >> Yeah, my goal is for the build system to be able to avoid having to embed >> PWD into the compiler flags. For example, I believe it is a goal of the LLVM >> gn build system for the build tree to be relocatable. If the compiler >> command lines need to contain absolute paths to make the paths in the >> coverage relative, we won't be able to achieve that goal. >> >> Based on all the comments that have gone before, it sounds like we want a >> `-fprofile-compilation-dir=` flag. Once we have that, would this logic work? >> >> - if profile compilation dir set, absolutize with that as the root >> - if no profile compilation dir, absolutize with CWD >> - apply profile prefix map >> >> Should `-no-canonical-prefixes` also be involved here? Unclear. > > I originally considered `-fprofile-compilation-dir=` and perhaps > `-ffile-compilation-dir=` to also handle cases like `__FILE__` macro > (`-ffile-prefix-map` and `-fmacro-prefix-map` suffer from the same issue as > `-fprofile-prefix-map`), but I'm not sure if specifying compilation dir is > the right approach. It makes sense for debug info because > `-fdebug-compilation-dir` is used directly as `DW_AT_comp_dir` and also > because it's a convention for source file paths in debug info to be relative > to build directory, but it's not the case for paths in coverage mapping or > `__FILE__`. > > So what I'm considering now and started prototyping is a `-fsource-dir`flag > (or maybe `-fsource-root-dir`, I'm open to suggestions for the name) where > the semantics would be that if this flag is set, all source paths will be > made relative to this directory. There's an open question whether this should > also apply to sources outside of that directory, for example system header > paths. > > The example use case, assuming source is in `/path/to/source` and build is in > `/path/to/build`, would be: `clang -fdebug-compilation-dir . -fsource-dir > ../source ../source/dir/file.c`. In this case `__FILE__` would expand to > `dir/file.c` and that path would be also stored in coverage mapping. D87928 <https://reviews.llvm.org/D87928> is the implementation of that idea. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D83154/new/ https://reviews.llvm.org/D83154 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits