From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp60.i.mail.ru (smtp60.i.mail.ru [217.69.128.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 8FB7346971A for ; Sun, 1 Dec 2019 23:59:38 +0300 (MSK) From: Vladislav Shpilevoy Date: Sun, 1 Dec 2019 21:59:34 +0100 Message-Id: <24ad607cdb08403e955e4c66daf11e2ed99e750e.1575233822.git.v.shpilevoy@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/1] Fix build on Mac with gcc and XCode 11 List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org, kyukhin@tarantool.org There is a bug in XCode 11 which makes some standard C headers not self sufficient when compile with gcc. At least and 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 --- Issue: https://github.com/tarantool/tarantool/issues/4580 Branch: https://github.com/tarantool/tarantool/tree/gerold103/gh-4580-mac-build Note, the branch depends on another branch in decNumber repository. decNumber should be pushed first, then this branch should be updated to look at the newest decNumber. src/box/blackhole.c | 2 -- src/box/sql/tokenize.c | 1 - src/box/vclock.h | 1 - src/lib/core/fiber.h | 1 - src/lib/salad/rope.c | 3 ++- test/unit/bitset_basic.c | 1 - test/unit/bitset_index.c | 1 - test/unit/bitset_iterator.c | 1 - test/unit/bps_tree.cc | 1 - test/unit/bps_tree_iterator.cc | 1 - test/unit/guava.c | 1 - test/unit/heap.c | 1 - test/unit/heap_iterator.c | 1 - test/unit/histogram.c | 1 - test/unit/light.cc | 1 - test/unit/ratelimit.c | 1 - test/unit/rtree.cc | 1 - test/unit/rtree_iterator.cc | 1 - test/unit/rtree_multidim.cc | 7 +------ test/unit/unit.h | 3 +-- third_party/decNumber | 2 +- third_party/tarantool_ev.h | 1 - 22 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/box/blackhole.c b/src/box/blackhole.c index 4f6ea9ab9..69f1deba1 100644 --- a/src/box/blackhole.c +++ b/src/box/blackhole.c @@ -30,8 +30,6 @@ */ #include "blackhole.h" -#include -#include #include #include "diag.h" diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c index 9fa069d09..2855e9dec 100644 --- a/src/box/sql/tokenize.c +++ b/src/box/sql/tokenize.c @@ -36,7 +36,6 @@ * individual tokens and sends those tokens one-by-one over to the * parser for analysis. */ -#include #include #include diff --git a/src/box/vclock.h b/src/box/vclock.h index f9633ac90..b5eddcf8b 100644 --- a/src/box/vclock.h +++ b/src/box/vclock.h @@ -30,7 +30,6 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include #include #include #include diff --git a/src/lib/core/fiber.h b/src/lib/core/fiber.h index c5b975513..faaf2e0da 100644 --- a/src/lib/core/fiber.h +++ b/src/lib/core/fiber.h @@ -34,7 +34,6 @@ #include #include -#include #include "tt_pthread.h" #include "third_party/tarantool_ev.h" #include "diag.h" diff --git a/src/lib/salad/rope.c b/src/lib/salad/rope.c index 5de951c78..39db466e8 100644 --- a/src/lib/salad/rope.c +++ b/src/lib/salad/rope.c @@ -42,7 +42,6 @@ * * Author: Hans-J. Boehm (boehm@parc.xerox.com) */ -#include /** * This macro helps to implement some common rope functions, not @@ -54,6 +53,8 @@ #define rope_ctx_t void * #include "rope.h" +#include + static inline int avl_node_height(struct avl_node *node) { diff --git a/test/unit/bitset_basic.c b/test/unit/bitset_basic.c index a2cbce4a0..fe4b6ab07 100644 --- a/test/unit/bitset_basic.c +++ b/test/unit/bitset_basic.c @@ -1,4 +1,3 @@ -#include #include #include diff --git a/test/unit/bitset_index.c b/test/unit/bitset_index.c index 8343317af..c077fae49 100644 --- a/test/unit/bitset_index.c +++ b/test/unit/bitset_index.c @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/bitset_iterator.c b/test/unit/bitset_iterator.c index 3830fff2c..04f2f9f72 100644 --- a/test/unit/bitset_iterator.c +++ b/test/unit/bitset_iterator.c @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/bps_tree.cc b/test/unit/bps_tree.cc index cf3789af6..ef374deb1 100644 --- a/test/unit/bps_tree.cc +++ b/test/unit/bps_tree.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/bps_tree_iterator.cc b/test/unit/bps_tree_iterator.cc index 56b13bb87..5c800bc69 100644 --- a/test/unit/bps_tree_iterator.cc +++ b/test/unit/bps_tree_iterator.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/guava.c b/test/unit/guava.c index 6b38871db..4e3ced76a 100644 --- a/test/unit/guava.c +++ b/test/unit/guava.c @@ -1,4 +1,3 @@ -#include #include #include diff --git a/test/unit/heap.c b/test/unit/heap.c index 5cf32802a..89806c633 100644 --- a/test/unit/heap.c +++ b/test/unit/heap.c @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/heap_iterator.c b/test/unit/heap_iterator.c index 3dfb8e77c..4fde39dfe 100644 --- a/test/unit/heap_iterator.c +++ b/test/unit/heap_iterator.c @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/histogram.c b/test/unit/histogram.c index a026be263..3056d20fe 100644 --- a/test/unit/histogram.c +++ b/test/unit/histogram.c @@ -1,4 +1,3 @@ -#include #include #include diff --git a/test/unit/light.cc b/test/unit/light.cc index f4c42bb0d..6d89938b4 100644 --- a/test/unit/light.cc +++ b/test/unit/light.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/ratelimit.c b/test/unit/ratelimit.c index 3dfbe485d..e47151bb9 100644 --- a/test/unit/ratelimit.c +++ b/test/unit/ratelimit.c @@ -1,4 +1,3 @@ -#include #include #include "unit.h" diff --git a/test/unit/rtree.cc b/test/unit/rtree.cc index 81a9947e4..02ca9cdd6 100644 --- a/test/unit/rtree.cc +++ b/test/unit/rtree.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/rtree_iterator.cc b/test/unit/rtree_iterator.cc index 5ab5b4f48..b3c8695e9 100644 --- a/test/unit/rtree_iterator.cc +++ b/test/unit/rtree_iterator.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/test/unit/rtree_multidim.cc b/test/unit/rtree_multidim.cc index 843b437e3..e09f6190b 100644 --- a/test/unit/rtree_multidim.cc +++ b/test/unit/rtree_multidim.cc @@ -1,11 +1,6 @@ -#include - -#include #include -#include -#include -#include #include +#include #include "unit.h" #include "salad/rtree.h" diff --git a/test/unit/unit.h b/test/unit/unit.h index 89ad7a57b..43c301b28 100644 --- a/test/unit/unit.h +++ b/test/unit/unit.h @@ -30,9 +30,8 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include -#include /* exit() */ #include +#include /* exit() */ #define header() printf("\t*** %s ***\n", __func__) #define footer() printf("\t*** %s: done ***\n", __func__) diff --git a/third_party/decNumber b/third_party/decNumber index 878ed752f..d1c6c2441 160000 --- a/third_party/decNumber +++ b/third_party/decNumber @@ -1 +1 @@ -Subproject commit 878ed752f2453cd5e73587e67f7782aec9181a22 +Subproject commit d1c6c24414cc165e1d990e171e2c9bd0824712e9 diff --git a/third_party/tarantool_ev.h b/third_party/tarantool_ev.h index 2fea76e6b..9fac941e3 100644 --- a/third_party/tarantool_ev.h +++ b/third_party/tarantool_ev.h @@ -32,7 +32,6 @@ #include #include #include -#include #define EV_MULTIPLICITY 1 #define EV_COMPAT3 0 -- 2.21.0 (Apple Git-122.2)