[llvm-bugs] [Bug 45169] New: modulemap umbrella directory iteration order led to compile failures
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 10 12:38:48 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45169
Bug ID: 45169
Summary: modulemap umbrella directory iteration order led to
compile failures
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: drodrigueztroitino at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
A modulemap file including a directive like `umbrella "."` might led to
different include orders, and led to compilation errors in different OS or the
same OS and different file systems.
It is possible to create a modulemap file with the so-called "umbrella
directory declaration" pointing to a directory. Because how the contents of the
directory are iterated, the interpretation of such module might be different in
different in different systems, even if the contents of the directory are
exactly the same.
The problem happens because in
https://github.com/llvm/llvm-project/blob/4a0267e3ad8c4d47f267d7d960f127e099fb4818/clang/lib/Frontend/FrontendAction.cpp#L367
llvm::vfs::recursive_directory_iterator is used. Under the hood the
recursive_directory_iterator will use readdir
(https://github.com/llvm/llvm-project/blob/47ec8702cbc6f607b2e5cc25270a560eb9e02710/llvm/lib/Support/Unix/Path.inc#L876-L891).
In my manual documentation of readdir, one can read "Note that the order of the
directory entries vended by readdir() is not specified. Some filesystems may
return entries in lexicographic sort order and others may not." (macOS
10.14.6).
Since the order of iteration is not specific, the headers that work in one
system might be reordered in the next system, and might fail to compile.
There seems to be backwards compatibility hack in
https://github.com/llvm/llvm-project/blob/47ec8702cbc6f607b2e5cc25270a560eb9e02710/clang/lib/Lex/ModuleMap.cpp#L2416-L2439
for some cases, but it is commented with "Although iterating over the directory
is relatively expensive, in practice this only applies to the uncommonly used
Tcl module on Darwin platforms.".
What I am asking is that all the umbrella directory declarations should provide
a consistent output given a consistent input, and should try to discard the
effects of the OS or the file system.
As a workaround, providing manually all the headers in lexicographical order in
the modulemap works, and provides a consistent compilation.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200310/a96f6b1d/attachment.html>
More information about the llvm-bugs
mailing list