Skip to content

Commit a906492

Browse files
committed
libretro-common/md5: skip built-in implementation on Apple
lrc_hash.h has two MD5_CTX definitions behind an __APPLE__ fence: * Apple: typedef to CC_MD5_CTX (struct CC_MD5state_st) with MD5_Init/Update/Final #define'd to the CommonCrypto CC_* equivalents. * Everyone else: the Solar Designer plain-C struct with explicit a/b/c/d/lo/hi/buffer/block members, matched by the implementation in libretro-common/utils/md5.c. md5.c was still being compiled unconditionally on Apple, which produced a hard build failure on macOS command-line builds: libretro-common/utils/md5.c:95:20: error: no member named 'a' in 'struct CC_MD5state_st' libretro-common/utils/md5.c:107:31: error: no member named 'block' in 'struct CC_MD5state_st' (... 20 errors, ferror-limit ...) The file's contents are unreachable on Apple anyway -- the #defines in lrc_hash.h remap every call site to CC_* before md5.c's declarations are seen, so the symbols it defines are orphans on Apple builds even when they do compile. The right fix is to skip the translation unit entirely, matching the Apple branch in the header. Scope: * One file touched (libretro-common/utils/md5.c). * Two lines of real change: `#ifndef __APPLE__` right before the first #include, matching `#endif` at EOF. * No behavioural change on non-Apple platforms; the preprocessor fence is a no-op there. * No Makefile change needed -- md5.c stays in the sources list on every platform, it just compiles to an empty object on Apple. Local build check: [pass] `make clean && make -j16` on macOS arm64 (Darwin 24, Apple clang) now reaches the link stage past md5.o instead of failing at CC libretro-common/utils/md5.c. [pass] No change to the compile log on a Linux x86_64 build -- md5.c still compiles to the same object.
1 parent acd0b89 commit a906492

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • libretro-common/utils

libretro-common/utils/md5.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
* optimizations are not included to reduce source code size and avoid
3535
* compile-time configuration.
3636
*/
37+
38+
+/* On Apple platforms MD5 is provided by CommonCrypto, and lrc_hash.h
39+
+ * aliases MD5_CTX / MD5_Init / MD5_Update / MD5_Final to the CC_*
40+
+ * equivalents. The Solar Designer implementation below pokes at
41+
+ * struct members (a, b, c, d, block) that do not exist on
42+
+ * CC_MD5state_st, so it must be skipped entirely on Apple. */
43+
+#ifndef __APPLE__
44+
3745
#include <lrc_hash.h>
3846

3947
#include <stdint.h>
@@ -287,3 +295,5 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx)
287295

288296
memset(ctx, 0, sizeof(*ctx));
289297
}
298+
299+
#endif /* !__APPLE__ */

0 commit comments

Comments
 (0)