Skip to content

cmake: sync AIX _ALL_SOURCE trick with autotools#14461

Closed
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:cm-aix
Closed

cmake: sync AIX _ALL_SOURCE trick with autotools#14461
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:cm-aix

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Aug 8, 2024

Follow-up to 919394e #14450
Closes #14461

@vszakats
Copy link
Member Author

vszakats commented Aug 8, 2024

Ref: #14450 (comment)

The actual value of _ALL_SOURCE doesn't matter as long as it's defined. Closing!

@vszakats vszakats closed this Aug 8, 2024
@vszakats vszakats deleted the cm-aix branch August 8, 2024 17:31
@dfandrich
Copy link
Contributor

FWIW, AIX seems to have trouble compiling out of the box already. I've just sent an AIX build log from yesterday's daily snapshot to https://curl.se/dev/builds.html

@vszakats
Copy link
Member Author

vszakats commented Aug 8, 2024

Ah, there are issues.

undefs are missing for a few redefined symbols. And a AIX-specific hack for ALLOC_FUNC (it might have a better way). Would this patch help?:

diff --git a/lib/memdebug.h b/lib/memdebug.h
index fd5cc2c94d..2f7baffafe 100644
--- a/lib/memdebug.h
+++ b/lib/memdebug.h
@@ -33,7 +33,7 @@
 #include <curl/curl.h>
 #include "functypes.h"
 
-#if defined(__GNUC__) && __GNUC__ >= 3
+#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(_AIX)
 #  define ALLOC_FUNC __attribute__((malloc))
 #  define ALLOC_SIZE(s) __attribute__((alloc_size(s)))
 #  define ALLOC_SIZE2(n, s) __attribute__((alloc_size(n, s)))
@@ -114,11 +114,17 @@ CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
 /* Set this symbol on the command-line, recompile all lib-sources */
 #undef strdup
 #define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
+#undef malloc
 #define malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
+#undef calloc
 #define calloc(nbelem,size) curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
+#undef realloc
 #define realloc(ptr,size) curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
+#undef free
 #define free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
+#undef send
 #define send(a,b,c,d) curl_dbg_send(a,b,c,d, __LINE__, __FILE__)
+#undef recv
 #define recv(a,b,c,d) curl_dbg_recv(a,b,c,d, __LINE__, __FILE__)
 
 #ifdef _WIN32

@dfandrich
Copy link
Contributor

That patch gets it successfully through the main compile with only the warnings at easy.c:608 and if2ip.c:219 left.

@vszakats
Copy link
Member Author

vszakats commented Aug 8, 2024

/curl-8.10.0-20240808/lib/easy.c:608:47: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
"%" CURL_FORMAT_SOCKET_T ")", fds[i].fd);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/curl-8.10.0-20240808/lib/curl_trc.h:76:27: note: expanded from macro 'infof'
Curl_infof(data, __VA_ARGS__); } while(0)
/curl-8.10.0-20240808/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'
#define SIOCGIFADDR (int)_IOWR('i',33, struct oifreq) /* get ifnet address */
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/ioctl.h:174:23: note: expanded from macro '_IOWR'
#define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|(x<<8)|y)
                      ^~~~~~~~~
/usr/include/sys/ioctl.h:168:20: note: expanded from macro 'IOC_INOUT'
#define IOC_INOUT (IOC_IN|IOC_OUT)
                   ^~~~~~
/usr/include/sys/ioctl.h:167:28: note: expanded from macro 'IOC_IN'
#define IOC_IN (0x40000000<<1) /* copy in parameters */
                ~~~~~~~~~~^ ~

@vszakats
Copy link
Member Author

vszakats commented Aug 8, 2024

Opened #14464.

@vszakats
Copy link
Member Author

vszakats commented Aug 8, 2024

Maybe this for the easy.c issue. The if2ip.c issue happens inside AIX system headers, so suppressing it may be the way to go:

diff --git a/lib/easy.c b/lib/easy.c
index a0704b0ed3..ab34e1499c 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -605,7 +605,7 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev)
           int act = poll2cselect(fds[i].revents); /* convert */
           infof(multi->easyp,
                 "call curl_multi_socket_action(socket "
-                "%" CURL_FORMAT_SOCKET_T ")", fds[i].fd);
+                "%" CURL_FORMAT_SOCKET_T ")", (curl_socket_t)fds[i].fd);
           mcode = curl_multi_socket_action(multi, fds[i].fd, act,
                                            &ev->running_handles);
         }
diff --git a/lib/if2ip.c b/lib/if2ip.c
index 42e14500bc..55afd553d6 100644
--- a/lib/if2ip.c
+++ b/lib/if2ip.c
@@ -216,7 +216,15 @@ if2ip_result_t Curl_if2ip(int af,
   memcpy(req.ifr_name, interf, len + 1);
   req.ifr_addr.sa_family = AF_INET;
 
+#if defined(__GNUC__) && defined(_AIX)
+/* Suppress warning inside system headers */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wshift-sign-overflow"
+#endif
   if(ioctl(dummy, SIOCGIFADDR, &req) < 0) {
+#if defined(__GNUC__) && defined(_AIX)
+#pragma GCC diagnostic pop
+#endif
     sclose(dummy);
     /* With SIOCGIFADDR, we cannot tell the difference between an interface
        that does not exist and an interface that has no address of the

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants