From b4c40ad6186ac85395041df96dc91336f13b8e4b Mon Sep 17 00:00:00 2001 From: Dianjin Wang Date: Wed, 9 Sep 2026 10:54:32 +0800 Subject: [PATCH] Fix OPENSSL_API_COMPAT redefinition warning in gpcloud s3conf.cpp includes the OpenSSL headers through s3common_headers.h before it includes c.h, so pg_config.h redefines OPENSSL_API_COMPAT with a different value than the one OpenSSL already settled on. On Rocky 8 (gcc 8, OpenSSL 1.1.1) every build of the module prints: In file included from ../../src/include/c.h:56, from src/s3conf.cpp:16: ../../src/include/pg_config.h:904: warning: "OPENSSL_API_COMPAT" redefined #define OPENSSL_API_COMPAT 0x10001000L In file included from /usr/include/openssl/opensslconf.h:42, from /usr/include/openssl/hmac.h:13, from include/s3common_headers.h:8, from include/gpcommon.h:4, from include/s3conf.h:4, from src/s3conf.cpp:1: /usr/include/openssl/opensslconf-x86_64.h:145: note: this is the location of the previous definition # define OPENSSL_API_COMPAT OPENSSL_MIN_API Undefine it before including c.h. By then the OpenSSL headers are fully parsed, so the macro no longer affects anything and behaviour is unchanged -- only the warning goes away. Reordering the includes so that c.h comes first would also work, but it would move the extern "C" block ahead of the C++ standard headers pulled in by s3common_headers.h. gpcloud.cpp is the only other file in the module that includes a PostgreSQL header, and it includes postgres.h on its first line, ahead of any OpenSSL header, so it does not have the problem. Assisted-by: Claude Code Backpatch-through: REL_2_STABLE --- gpcontrib/gpcloud/src/s3conf.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gpcontrib/gpcloud/src/s3conf.cpp b/gpcontrib/gpcloud/src/s3conf.cpp index 2bff0174236..1accb8fdba0 100644 --- a/gpcontrib/gpcloud/src/s3conf.cpp +++ b/gpcontrib/gpcloud/src/s3conf.cpp @@ -13,6 +13,10 @@ void write_log(const char* fmt, ...) __attribute__((format(printf, 1, 2))); // For GpIdentity #ifndef S3_STANDALONE extern "C" { +// The OpenSSL headers included above (through s3common_headers.h) already +// define OPENSSL_API_COMPAT, so drop it before pg_config.h defines its own +// value to avoid a macro redefinition warning. +#undef OPENSSL_API_COMPAT #include "c.h" #include "cdb/cdbvars.h" extern int getgpsegmentCount(void);