Page MenuHomePhabricator

Provide -fsource-dir flag in Clang
Needs ReviewPublic

Authored by phosek on Sep 18 2020, 12:17 PM.

Details

Reviewers
keith
rnk
vsk
Summary

This flag can be used to relativize source paths againts a given
directory. Compared to -f*-prefix-map flags, it avoids the absolute
path on the compiler command line analogously to -fdebug-compile-dir,
which is important distributed compilation scenarios.

Diff Detail

Event Timeline

phosek created this revision.Sep 18 2020, 12:17 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 18 2020, 12:17 PM
phosek requested review of this revision.Sep 18 2020, 12:17 PM

This change is trying to address the issues raised in D83154. There are still some open questions:

  • Is -fsource-dir the best name for this flag?
  • I'm not sure if make_relative should be applied to all source paths, or only paths that start with SourceDir which would exclude system paths outside of the source directory (e.g. it's probably undesirable to relativize paths to /usr/include)?
  • If we decide to exclude source paths outside of the source directory, should we support -fsource-dir to be specified more then once to handle multiple source directories?
keith added a comment.Sep 21 2020, 5:08 PM

This change is trying to address the issues raised in D83154. There are still some open questions:

  • Is -fsource-dir the best name for this flag?

I think this name works as long as its recommended usage doesn't end up including directories outside of the source root.

  • I'm not sure if make_relative should be applied to all source paths, or only paths that start with SourceDir which would exclude system paths outside of the source directory (e.g. it's probably undesirable to relativize paths to /usr/include)?

This is one place where I think the *-prefix-map flags have a UX advantage. For example in the Apple toolchain, there are places where the Xcode paths are embedded in this data, and you may want to exclude them by doing -f*-prefix-map=/path/to/Xcode.app=STANDARD_XCODE_PATH and remapping that later as needed to increase reproducibility

  • If we decide to exclude source paths outside of the source directory, should we support -fsource-dir to be specified more then once to handle multiple source directories?

I think this would be a bit confusing usage wise, so I would say it should act like -fdebug-compilation-dir where only 1 can be passed.