Skip to content

Commit 5147706

Browse files
committed
Work around a possible platform/modules bug.
On OpenBSD, `stdint.h` is a symlink to `sys/stdint.h`, and the platform modulemap (basically identical to `libcxx/include/module.modulemap`) has a defined submodule `std.depr.stdint_h`. When compiling happens with `-fmodules`, which is what happens in bootstrap builds, this seems to confuse clang royally and demands that `stdint.h` be included when it already is. I don't actually understand what the problem is here. The problem isn't the symlink, but something... else. I think the problem is the fact that `std.depr.stdint_h` exists which causes the problem somehow. Removing the module fixes the problem, as does using a different include (like `inttypes.h` which does not have a corresponding module) which includes `stdint.h` transitively. The other alternative is to counsel users trying to build for the platform to disable libswift, which means that modules aren't used. This would be OK, but given that eeckstein says that "*Currently* libswift does not contain any "mandatory" code yet" (emphasis mine) suggests that such counsel wouldn't be very durable. Therefore, to make sure the build is unbroken, make this terrible little hack for now.
1 parent 359ee9b commit 5147706

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/swift/SIL/BridgedSwiftObject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
#ifndef SWIFT_SIL_BRIDGEDSWIFTOBJECT_H
1919
#define SWIFT_SIL_BRIDGEDSWIFTOBJECT_H
2020

21+
#if defined(__OpenBSD__)
22+
#include <sys/stdint.h>
23+
#else
2124
#include <stdint.h>
25+
#endif
2226

2327
#if !defined(__has_feature)
2428
#define __has_feature(feature) 0

0 commit comments

Comments
 (0)