Getting exceptions while building Redis in Mac M1.

exception replication.c:1617:31: error: variable has incomplete type 'struct stat64' struct redis_stat buf; ^ replication.c:1617:20: note: forward declaration of 'struct stat64' struct redis_stat buf; ^ ./config.h:46:20: note: expanded from macro 'redis_stat'

define redis_stat stat64

               ^

replication.c:1666:21: error: call to undeclared function 'fstat64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] redis_fstat(slave->repldbfd,&buf) == -1) { ^ ./config.h:45:21: note: expanded from macro 'redis_fstat'

define redis_fstat fstat64

                ^

2 errors generated. make[1]: *** [replication.o] Error 1 make: *** [all] Error 2

Comment From: sundb

What verison of OSX are you using?

Comment From: rezawasim

os: Ventura 13.5.2 make: GNU Make 4.4.1 clang: clang-1500.0.40.1

Comment From: sundb

@rezawasim Not sure why you can't find out MAC_OS_X_VERSION_10_6. Please give the info by following:

cat /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/AvailabilityMacros.h | grep '
#define MAC_OS_X_VERSION_10_6'

Comment From: vladimirtemnikov

Same problem on Mac OS Sonoma latest beta. I'm not sure but I guess Xcode app is not required here, CommandLineTools should work without an app.

Comment From: sundb

@vladimirtemnikov Yes, we just need xcode CommandLineTools, did you run xcode-select install again after upgrading OSX?

Comment From: vladimirtemnikov

@sundb sure, I have multiple SDKs, 13 and 14 versions.

Comment From: vladimirtemnikov

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h

#define __MAC_10_6                                        1060
#define  MAC_OS_X_VERSION_10_6                           __MAC_10_6

Comment From: rezawasim

@sundb System Version: macOS 13.5.2 (22G91) Kernel Version: Darwin 22.6.0 Boot Volume: Macintosh HD Boot Mode: Normal Secure Virtual Memory: Enabled System Integrity Protection: Enabled This is the os config. It has the highest definition of os x version

define MAC_OS_VERSION_13_4 __MAC_13_4

define MAC_OS_VERSION_14_0 __MAC_14_0

Please let me know if you need any more information to debug the issue.

Comment From: sundb

Path: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityMacros.h Different between Ventura 13.2.1 and 13.5.2

AvailabilityMacros.h in 13.2.1 Redis Build Issue in arm

AvailabilityMacros.h in 13.5.2 Redis Build Issue in arm

Seems that these defines are removed. @yossigo Please have a look. may be we have to enable _DARWIN_C_SOURCE to see MAC_OS_X_VERSION_10_6.

define in AvailabilityVersions.h: Redis Build Issue in arm

Comment From: yossigo

@sundb I'm not using MacOS, where were they removed from?

Comment From: sundb

The following defines are removed from <AvailabilityMacros.h> since the lastest MacOSX SDK(13.5.2) Redis Build Issue in arm

So the compiler will go to the following code and cause a compilation error.

#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
#define redis_fstat fstat64
#define redis_stat stat64
#else

Comment From: sundb

I changed the daily CI to use macos-13(https://github.com/sundb/redis/blob/340e27ab57335363462058f4319ec75bfd5896e2/.github/workflows/daily.yml#L793-L801), and it failed.

fail CI: https://github.com/sundb/redis/actions/runs/6249358805/job/16965828088

Comment From: KFoxder

Experiencing the same issue as well when building from source

Comment From: peng9627

Same issue. What should i do.

Comment From: sundb

@peng9627 Please use the following patch temporarily

diff --git a/src/config.h b/src/config.h
index 3c9a2701..4607c177 100644
--- a/src/config.h
+++ b/src/config.h
@@ -31,6 +31,7 @@
 #define __CONFIG_H

 #ifdef __APPLE__
+#define _DARWIN_C_SOURCE
 #include <fcntl.h> // for fcntl(fd, F_FULLFSYNC)
 #include <AvailabilityMacros.h>
 #endif

Comment From: peng9627

Already available. Thanks!!!

Comment From: nicolaschambrier

Hi, when can we expect a release for this patch?

Comment From: sundb

@nicolaschambrier This patch will appear soon in the next release.

Comment From: lizhen1412

@peng9627 Please use the following patch temporarily

```diff diff --git a/src/config.h b/src/config.h index 3c9a2701..4607c177 100644 --- a/src/config.h +++ b/src/config.h @@ -31,6 +31,7 @@ #define __CONFIG_H

#ifdef APPLE +#define _DARWIN_C_SOURCE #include // for fcntl(fd, F_FULLFSYNC) #include #endif ```

I think it would be better for the government to repair or make mac computers compatible with m1 chip or m2 chip as soon as possible?

Comment From: WayneDu98

@peng9627 Please use the following patch temporarily ```diff diff --git a/src/config.h b/src/config.h index 3c9a2701..4607c177 100644 --- a/src/config.h +++ b/src/config.h @@ -31,6 +31,7 @@ #define __CONFIG_H

#ifdef APPLE +#define _DARWIN_C_SOURCE #include // for fcntl(fd, F_FULLFSYNC) #include #endif ```

I think it would be better for the government to repair or make mac computers compatible with m1 chip or m2 chip as soon as possible?

finally i compile 7.0,it success.