<html><body><p>As part of helping to resolve old libdispatch pull requests, I have run into a problem with the GLibc module map on Linux that I need help understanding and fixing.<br><br>The symptom I am trying to resolve is that somewhere between the March 16 and March 24 Swift development snapshots, the Dispatch overlay for libdispatch on Linux stopped building.  We've been hacking around the problem for 2 months (<a href="https://github.com/apple/swift-corelibs-libdispatch/pull/62">https://github.com/apple/swift-corelibs-libdispatch/pull/62</a>), but we don't want to merge that hack back to the master branch of libdispatch.<br><br>The issue is that swiftc is convinced that off_t and mode_t should be defined in the stdio module (by including stdio.h).  We don't want to include stdio.h in dispatch.h;  it is sufficient (and the C compilation of libdispatch succeeds) to only include fcntl.h and unistd.h.  However without including stdio.h in dispatch.h, building the swiftmodule from Dispatch.swift fails, starting with the March 24 driver (and is still broken on master as of this morning).<br><br>I can hack around this by (a) including stdio.h in dispatch.h  or (b) editing glibc.modulemap.gyb to put the module statements for fnctl and unistd before the modile statement for stdio.   Neither of these seem like the right fix.<br><br>Can anyone point me to a better solution?<br><br>I've attached the full buildlog.   The actual build errors are excerpted below as well.<br><br>thanks,<br><br>--dave<br><br><i>(See attached file: buildLog.txt)</i><br><br>make[2]: Entering directory '/home/dgrove/swift/build/dpg/libdispatch-linux-x86_64/src'<br>/home/dgrove/swift/build/dpg/swift-linux-x86_64/bin/swiftc -Xcc -fmodule-map-file=/home/dgrove/swift/swift-corelibs-libdispatch/dispatch/module.map -I/home/dgrove/swift/swift-corelibs-libdispatch -parse-as-library -Xcc -fblocks -c -o /home/dgrove/swift/build/dpg/libdispatch-linux-x86_64/src/Dispatch.o /home/dgrove/swift/swift-corelibs-libdispatch/src/swift/Dispatch.swift<br>&lt;module-includes&gt;:1:10: note: in file included from &lt;module-includes&gt;:1:<br>#include &quot;dispatch.h&quot;<br>         ^<br>/home/dgrove/swift/swift-corelibs-libdispatch/dispatch/dispatch.h:59:10: note: in file included from /home/dgrove/swift/swift-corelibs-libdispatch/dispatch/dispatch.h:59:<br>#include &lt;dispatch/io.h&gt;<br>         ^<br>/home/dgrove/swift/swift-corelibs-libdispatch/dispatch/io.h:253:31: error: declaration of 'mode_t' must be imported from module 'SwiftGlibc.POSIX.sys.types' before it is required<br>        const char *path, int oflag, mode_t mode,<br>                                     ^<br>/usr/include/x86_64-linux-gnu/sys/types.h:70:18: note: previous declaration is here<br>typedef __mode_t mode_t;<br>                 ^<br>&lt;module-includes&gt;:1:10: note: in file included from &lt;module-includes&gt;:1:<br>#include &quot;dispatch.h&quot;<br>         ^<br>/home/dgrove/swift/swift-corelibs-libdispatch/dispatch/dispatch.h:59:10: note: in file included from /home/dgrove/swift/swift-corelibs-libdispatch/dispatch/dispatch.h:59:<br>#include &lt;dispatch/io.h&gt;<br>         ^<br>/home/dgrove/swift/swift-corelibs-libdispatch/dispatch/io.h:355:2: error: declaration of 'off_t' must be imported from module 'SwiftGlibc.C.stdio' before it is required<br>        off_t offset,<br>        ^<br>/usr/include/stdio.h:90:17: note: previous declaration is here<br>typedef __off_t off_t;<br>                ^<br>/home/dgrove/swift/swift-corelibs-libdispatch/src/swift/Dispatch.swift:13:19: error: could not build Objective-C module 'Dispatch'<br>@_exported import Dispatch<br>                  ^<br>Makefile:909: recipe for target '/home/dgrove/swift/build/dpg/libdispatch-linux-x86_64/src/Dispatch.o' failed<br>make[2]: *** [/home/dgrove/swift/build/dpg/libdispatch-linux-x86_64/src/Dispatch.o] Error 1<br>make[2]: Leaving directory '/home/dgrove/swift/build/dpg/libdispatch-linux-x86_64/src'<br>Makefile:493: recipe for target 'all' failed<br>make[1]: *** [all] Error 2<br>make[1]: Leaving directory '/home/dgrove/swift/build/dpg/libdispatch-linux-x86_64/src'<br>Makefile:454: recipe for target 'all-recursive' failed<br>make: *** [all-recursive] Error 1<br>./utils/build-script: command terminated with a non-zero exit status 2, aborting<br>./utils/build-script: command terminated with a non-zero exit status 1, aborting<BR>
</body></html>