Skip to contentSkip to conversation

git-compat-util: fix NO_OPENSSL on current macOS

PATCH In review René Scharfe 2 participants 2 messages Apr 14, 2024 – Apr 18, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-compat-util: fix NO_OPENSSL on current macOS

b195aa00c1 (git-compat-util: suppress unavoidable Apple-specific deprecation warnings, 2014-12-16) started to define __AVAILABILITY_MACROS_USES_AVAILABILITY in git-compat-util.h. On current versions it is already defined (e.g. on macOS 14.4.1). Undefine it before redefining it to avoid a compilation error.

---
On my system I can remove the whole ifdef __APPLE__ section, as the OS doesn't include the deprecated OpenSSL anymore. I get a current version via Homebrew, which doesn't throw any deprecation warnings, of course.

Not sure if this is the right fix, as the no longer needed section still undefines __AVAILABILITY_MACROS_USES_AVAILABILITY at the end, which we may want to keep instead. But compilation succeeds and tests pass, so perhaps it's fine.

 git-compat-util.h | 1 +
 1 file changed, 1 insertion(+)
git-compat-util.h +1 -0
index 7c2a6538e5..1a4f5a30c3 100644
@@ -391,6 +391,7 @@ char *gitdirname(char *);
 
 #ifndef NO_OPENSSL
 #ifdef __APPLE__
+#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
 #define __AVAILABILITY_MACROS_USES_AVAILABILITY 0
 #include <AvailabilityMacros.h>
 #undef DEPRECATED_ATTRIBUTE

--
2.44.0

#1 lore raw
Quoted 12 lines · René Scharfe

b195aa00c1 (git-compat-util: suppress unavoidable Apple-specific deprecation warnings, 2014-12-16) started to define __AVAILABILITY_MACROS_USES_AVAILABILITY in git-compat-util.h. On current versions it is already defined (e.g. on macOS 14.4.1). Undefine it before redefining it to avoid a compilation error.

---
On my system I can remove the whole ifdef __APPLE__ section, as the OS doesn't include the deprecated OpenSSL anymore. I get a current version via Homebrew, which doesn't throw any deprecation warnings, of course.

Quoted 4 lines

Not sure if this is the right fix, as the no longer needed section still undefines __AVAILABILITY_MACROS_USES_AVAILABILITY at the end, which we may want to keep instead. But compilation succeeds and tests pass, so perhaps it's fine.

I think I added the final #undef __AVAILABILITY_MACROS_USES_AVAILABILITY in b195aa00c1 (git-compat-util: suppress unavoidable Apple-specific deprecation warnings, 2014-12-16) just for completeness; since I #define'd it, I also #undef'd it to ensure a clean state or the C preprocessor.

However, taking this new situation into account, where __AVAILABILITY_MACROS_USES_AVAILABILITY is now defined by default, it _probably_ would be more correct to drop that final #undef.

Having said that, though, it doesn't seem that it is likely to matter one way or the other as the project stands presently, especially since you report that building and testing succeeds. Moreover, the only other place in the project where we seem to care about the Apple version-compatibility macros is in compat/fsmonitor/fsm-listen-darwin.c, but even that isn't a problem because it consults a version-compatibility macro before #include'ing git-compat-util:

    #ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
    #define kFSEventStreamEventFlagItemCloned 0x00400000
    #endif
    #include "git-compat-util.h"

So, this patch can't possibly have any sort of negative interaction with that code even if __AVAILABILITY_MACROS_USES_AVAILABILITY somehow impacted AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER.