Skip to content

Commit 2b2d15d

Browse files
committed
Build fix for Dispatch overlay on Linux with 03242016 compiler.
The types mode_t and off_t are conditionally defined in multiple header files in GLibc. This interacts poorly with the clang module maps, resulting in it insisting that these types should be imported from stdio.h (which we don't want to unconditionally include in the dispatch API header files). We can fix the clash with mode_t by including sys/types.h early in the list of includes in dispatch.h. I was unable to find a similar fix for off_t, so instead this change conditionally includes stdio.h in dispatch/io.h under a preprocessor symbol that will only be defined when compiling Dispatch.swift to build the swiftmodule for the overlay.
1 parent 054d938 commit 2b2d15d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

dispatch/dispatch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <TargetConditionals.h>
2727
#endif
2828
#include <sys/cdefs.h>
29+
#include <sys/types.h>
2930
#include <stddef.h>
3031
#include <stdint.h>
3132
#include <stdbool.h>

dispatch/io.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
#include <dispatch/base.h> // for HeaderDoc
2727
#endif
2828

29+
#ifdef __DISPATCH_BUILDING_SWIFT_MODULE__
30+
#include <stdio.h>
31+
#endif
32+
2933
__BEGIN_DECLS
3034

3135
/*! @header

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ SWIFT_OBJECTS= \
122122
$(abs_builddir)/Dispatch.swiftdoc \
123123
$(abs_builddir)/Dispatch.o
124124

125-
SWIFTC_FLAGS = -Xcc -fmodule-map-file=$(abs_top_srcdir)/dispatch/module.map -I$(abs_top_srcdir) -parse-as-library -Xcc -fblocks
125+
SWIFTC_FLAGS = -Xcc -D__DISPATCH_BUILDING_SWIFT_MODULE__=1 -Xcc -fmodule-map-file=$(abs_top_srcdir)/dispatch/module.map -I$(abs_top_srcdir) -parse-as-library -Xcc -fblocks
126126

127127
$(abs_builddir)/Dispatch.o: $(abs_srcdir)/swift/Dispatch.swift
128128
$(SWIFTC) $(SWIFTC_FLAGS) -c -o $@ $<

0 commit comments

Comments
 (0)