Skip to content

Commit c7f1293

Browse files
dgrove-ossdas
authored andcommitted
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. Signed-off-by: Daniel A. Steffen <[email protected]>
1 parent a4a522e commit c7f1293

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
@@ -125,7 +125,7 @@ SWIFT_OBJECTS= \
125125
$(abs_builddir)/Dispatch.swiftdoc \
126126
$(abs_builddir)/Dispatch.o
127127

128-
SWIFTC_FLAGS = -Xcc -fmodule-map-file=$(abs_top_srcdir)/dispatch/module.map -I$(abs_top_srcdir) -parse-as-library -Xcc -fblocks
128+
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
129129

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

0 commit comments

Comments
 (0)