Fix build on Mac with gcc and XCode 11
There is a bug in XCode 11 which makes some standard C headers not self sufficient when compile with gcc. At least <stdlib.h> and <algorithm> are affected. When they are included first, compilation fails with creepy errors like this: In file included from /Applications/Xcode.app/Contents/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ sys/wait.h:110, from /Applications/Xcode.app/Contents/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ stdlib.h:66, from tarantool/third_party/zstd/lib/common/zstd_common.c:16: /Applications/Xcode.app/Content/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ sys/resource.h: In function 'getiopolicy_np': /Applications/Xcode.app/Contents/Developer/ Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ sys/resource.h:447:34: error: expected declaration specifiers before '__OSX_AVAILABLE_STARTING' 447 | int getiopolicy_np(int, int) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); The patch workarounds the bug by deleting the buggy header includes where possible, and by changing include order in other cases. Also there was a second compilation problem. This was about different definitions of the same standard functions: via extern "C" and without. It looked like this: In file included from tarantool/src/trivia/util.h:36, from tarantool/src/tt_pthread.h:35, from tarantool/src/lib/core/fiber.h:38, from tarantool/src/lib/core/coio.h:33, from tarantool/src/lib/core/coio.cc:31: /usr/local/Cellar/gcc/9.2.0_1/lib/gcc/9/gcc/x86_64-apple-darwin18/9.2.0 include-fixed/stdio.h:222:7: error: conflicting declaration of 'char* ctermid(char*)' with 'C' linkage 222 | char *ctermid(char *); | ^~~~~~~ In file included from /Applications/Xcode.app/Contents/Developer/Platforms/ MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:525, from tarantool/src/lib/core/fiber.h:37, from tarantool/src/lib/core/coio.h:33, from tarantool/src/lib/core/coio.cc:31: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/ Developer/SDKs/MacOSX.sdk/usr/include/_ctermid.h:26:10: note: previous declaration with 'C++' linkage 26 | char *ctermid(char *); | ^~~~~~~ This bug is workarounded by deletion of the conflicting includes, because anyway they appeared to be not needed. Closes #4580 Conflicts: third_party/decNumber
Showing
- src/box/blackhole.c 0 additions, 2 deletionssrc/box/blackhole.c
- src/box/sql/tokenize.c 0 additions, 1 deletionsrc/box/sql/tokenize.c
- src/box/vclock.h 0 additions, 1 deletionsrc/box/vclock.h
- src/lib/core/fiber.h 0 additions, 1 deletionsrc/lib/core/fiber.h
- src/lib/salad/rope.c 2 additions, 1 deletionsrc/lib/salad/rope.c
- test/unit/bitset_basic.c 0 additions, 1 deletiontest/unit/bitset_basic.c
- test/unit/bitset_index.c 0 additions, 1 deletiontest/unit/bitset_index.c
- test/unit/bitset_iterator.c 0 additions, 1 deletiontest/unit/bitset_iterator.c
- test/unit/bps_tree.cc 0 additions, 1 deletiontest/unit/bps_tree.cc
- test/unit/bps_tree_iterator.cc 0 additions, 1 deletiontest/unit/bps_tree_iterator.cc
- test/unit/guava.c 0 additions, 1 deletiontest/unit/guava.c
- test/unit/heap.c 0 additions, 1 deletiontest/unit/heap.c
- test/unit/heap_iterator.c 0 additions, 1 deletiontest/unit/heap_iterator.c
- test/unit/histogram.c 0 additions, 1 deletiontest/unit/histogram.c
- test/unit/light.cc 0 additions, 1 deletiontest/unit/light.cc
- test/unit/ratelimit.c 0 additions, 1 deletiontest/unit/ratelimit.c
- test/unit/rtree.cc 0 additions, 1 deletiontest/unit/rtree.cc
- test/unit/rtree_iterator.cc 0 additions, 1 deletiontest/unit/rtree_iterator.cc
- test/unit/rtree_multidim.cc 1 addition, 6 deletionstest/unit/rtree_multidim.cc
- test/unit/unit.h 1 addition, 2 deletionstest/unit/unit.h
Loading
Please register or sign in to comment