-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: fix AIX build issues #14464
lib: fix AIX build issues #14464
Conversation
``` lib/memdebug.h:107:13: warning: unknown attribute 'vec_malloc' ignored [-Wunknown-attributes] CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode, ^~~~~~~~~~ lib/memdebug.h:37:37: note: expanded from macro 'ALLOC_FUNC' ^~~~~~ ``` Ref: https://curl.se/dev/log.cgi?id=20240808180420-3809007
Avoiding warning on AIX: ``` lib/memdebug.h:117:9: warning: 'malloc' macro redefined [-Wmacro-redefined] ^ /usr/include/stdlib.h:753:9: note: previous definition is here ^ ``` Ref: https://curl.se/dev/log.cgi?id=20240808180420-3809007
This fixes the compile issue when building with ibm-clang, but I found a gcc on this machine and it doesn't need this workaround. The clang case set a |
``` lib/easy.c:608:47: warning: format specifies type 'int' but the argument has type 'long' [-Wformat] "%" CURL_FORMAT_SOCKET_T ")", fds[i].fd); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~ ``` Ref: https://curl.se/dev/log.cgi?id=20240808180420-3809007
``` lib/if2ip.c:219:19: warning: signed shift result (0x80000000) sets the sign bit of the shift expression's type ('int') and becomes negative [-Wshift-sign-overflow] if(ioctl(dummy, SIOCGIFADDR, &req) < 0) { ^~~~~~~~~~~ /usr/include/sys/ioctl.h:401:26: note: expanded from macro 'SIOCGIFADDR' ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/sys/ioctl.h:174:23: note: expanded from macro '_IOWR' ^~~~~~~~~ /usr/include/sys/ioctl.h:168:20: note: expanded from macro 'IOC_INOUT' ^~~~~~ /usr/include/sys/ioctl.h:167:28: note: expanded from macro 'IOC_IN' ~~~~~~~~~~^ ~ ``` Ref: https://curl.se/dev/log.cgi?id=20240808180420-3809007
The As for the other, what do you think of this?: diff --git a/lib/memdebug.h b/lib/memdebug.h
index aba289f4e7..0e12cc27a0 100644
--- a/lib/memdebug.h
+++ b/lib/memdebug.h
@@ -33,7 +33,8 @@
#include <curl/curl.h>
#include "functypes.h"
-#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(_AIX)
+#if defined(__GNUC__) && __GNUC__ >= 3 && \
+ !(defined(_AIX) && defined(_LINUX_SOURCE_COMPAT))
/* AIX defines a macro named 'malloc', which breaks the line below */
# define ALLOC_FUNC __attribute__((malloc))
# define ALLOC_SIZE(s) __attribute__((alloc_size(s))) |
Hm, this might be most future-proof, if it doesn't have a side-effect: #if defined(__GNUC__) && __GNUC__ >= 3 && !(defined(_AIX) && defined(malloc))
/* ibm-clang defines _LINUX_SOURCE_COMPAT which in turn defines a macro named
'malloc', which breaks the line below */ |
Actually, how about |
I wasn't brave enough to go that far :) But yes, if there is no side-effect, it seems even better. The ultimate solution would be if compilers supported the |
Confirmed on godbolt that both |
and also `__alloc_size__`. (requires gcc 4.4 (or 4.3/4.2) like `alloc_size`.
I suppose the simple case of a malloc macro simply redirecting to another function would be fine with this block, so an unconditional FYI, I uploaded an AIX gcc snapshot autobuild log. |
The PR commit 0b3c791 works fine on ibm-clang 17.1 and gcc 10.3. |
This still triggers, though a bit differently. Is it possible the cast is missing?:
|
The autobuild logs are pure daily snapshots—no patches. With this PR, those warnings don't show up for me with either ibm-clang or gcc.
|
memdebug: replace keyword
malloc
with__malloc__
tonot interfere with envs where
malloc
is redefined. Also applythe fix to
alloc_size
.Fixes:
memdebug: always undef before defining.
Also do this for the rest of functions redefined in the same block.
Avoids warning on AIX:
easy: fix
-Wformat
warning on AIX by adding a cast.if2ip: silence compiler warning inside AIX system header.
Ref: https://curl.se/dev/log.cgi?id=20240808180420-3809007
Assisted-by: Dan Fandrich
Closes #14464