[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


            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
llvm::vfs::recursive_directory_iterator is used. Under the hood the
recursive_directory_iterator will use readdir
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

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
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