From 8c2f52dee8da32e7bca418a8a3fc77260c247eb8 Mon Sep 17 00:00:00 2001 From: Ernesto Castellotti Date: Thu, 4 Jul 2019 00:21:15 +0200 Subject: [PATCH] Suppressed the new GCC 9 -Wmissing-attributes warnings With the new release of the GCC 9 compiler the operation of -Wmissing-attributes warnings has also been extended to aliases: this causes a warnings if the alias has less attributes than its target. This warnings does not actually indicate a problem in the mimalloc code and you could safely ignore it by adding "-Wno-missing-attributes" to the CFLAGS, however I was not going to use a "hack" to hide the warning when compiling alloc-override .c So this patch solves the problem simply by using an attribute (present only in GCC> = 9) that copies the attributes of another function, since this attribute is exclusive only for GCC 9 (or later) I had to use a simple precompiler instruction to add the "copy" attribute only with GCC 9. --- src/alloc-override.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/alloc-override.c b/src/alloc-override.c index 6980735..65a62ac 100644 --- a/src/alloc-override.c +++ b/src/alloc-override.c @@ -25,7 +25,11 @@ terms of the MIT license. A copy of the license can be found in the file #if (defined(__GNUC__) || defined(__clang__)) && !defined(__MACH__) // use aliasing to alias the exported function to one of our `mi_` functions +#if (defined(__GNUC__) && __GNUC__ >= 9) + #define MI_FORWARD(fun) __attribute__((alias(#fun), used, visibility("default"), copy(fun))) +#else #define MI_FORWARD(fun) __attribute__((alias(#fun), used, visibility("default"))) +#endif #define MI_FORWARD1(fun,x) MI_FORWARD(fun) #define MI_FORWARD2(fun,x,y) MI_FORWARD(fun) #define MI_FORWARD0(fun,x) MI_FORWARD(fun)