[PATCH] D125138: [clang] Add the flag -ffile-reproducible

Alan Zhao via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 6 15:27:50 PDT 2022


ayzhao created this revision.
Herald added a project: All.
ayzhao requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

When Clang generates the path prefix (i.e. the path of the directory
where the file is) when generating __FILE__, __builtin_FILE(), and
std::source_location, Clang uses the platform-specific path separator
character of the build environment where Clang _itself_ is built. This
leads to inconsistencies in Chrome builds where Clang running on
non-Windows environments uses the forward slash (/) path separator
while Clang running on Windows builds uses the backslash (\) path
separator. To fix this, we add a flag -ffile-reproducible (and its
inverse, -fno-file-reproducible) to have Clang use the target's
platform-specific file separator character.

Additionally, the existing flags -fmacro-prefix-map and
-ffile-prefix-map now both imply -ffile-reproducible. This can be
overriden by setting -fno-file-reproducible.

[0]: https://crbug.com/1310767


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125138

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/AST/Expr.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/Preprocessor/file_test.c
  clang/test/Preprocessor/file_test_windows.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125138.427770.patch
Type: text/x-patch
Size: 16292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220506/8ab71627/attachment-0001.bin>


More information about the cfe-commits mailing list