Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS Monteray Xcode 13 build failure incomplete type 'struct nfsstats' #150

Open
MarekR22 opened this issue Jan 16, 2022 · 1 comment
Open

Comments

@MarekR22
Copy link

MarekR22 commented Jan 16, 2022

Apparently system library header files has been changed for latest Xcode hiding definition of struct nfsstats.
As a result sigar fails to compile.

Xcode Version 13.2.1 (13C100)
MacOS Monteray 12.1 (21C52)

Steps I used:

git clone https://github.com/hyperic/sigar.git
cd sigar
mkdir build
cd build
cmake -G Xcode ..
cmake --build . -j 4

Outcome:

/Users/marekR22/Downloads/sigar/src/os/darwin/darwin_sigar.c:3233:24: error: invalid application of 'sizeof' to an incomplete type 'struct nfsstats'
    size_t len = sizeof(*stats);
                       ^~~~~~~~
/Users/marekR22/Downloads/sigar/src/os/darwin/darwin_sigar.c:3231:32: note: forward declaration of 'struct nfsstats'
static int get_nfsstats(struct nfsstats *stats)
                               ^
/Users/marekR22/Downloads/sigar/src/os/darwin/darwin_sigar.c:3303:21: error: variable has incomplete type 'struct nfsstats'
    struct nfsstats stats;
                    ^
/Users/marekR22/Downloads/sigar/src/os/darwin/darwin_sigar.c:3303:12: note: forward declaration of 'struct nfsstats'
    struct nfsstats stats;
           ^
/Users/marekR22/Downloads/sigar/src/os/darwin/darwin_sigar.c:3329:21: error: variable has incomplete type 'struct nfsstats'
    struct nfsstats stats;
                    ^
/Users/marekR22/Downloads/sigar/src/os/darwin/darwin_sigar.c:3329:12: note: forward declaration of 'struct nfsstats'
    struct nfsstats stats;
           ^

I'm still trying to find proper header file to include, but no luck so far.
I will provide pull request when I find solution.

@MarekR22
Copy link
Author

Looks like meaning of constant NFS_NFSSTATS has changed.
It is used here.

Old version of NFS_NFSSTATS is defined here.

#define NFS_NFSSTATS        1       /* struct: struct nfsstats */

Now when I jump to this constant when using new Xcode (new SDK) this defintion has following comment

#define NFS_NFSSTATS        1       /* struct: struct nfsclntstats */

Now old definition of struct nfsstats:

/*
 * Stats structure
 */
struct nfsstats {
	uint64_t        attrcache_hits;
	uint64_t        attrcache_misses;
	uint64_t        lookupcache_hits;
	uint64_t        lookupcache_misses;
	uint64_t        direofcache_hits;
	uint64_t        direofcache_misses;
	uint64_t        biocache_reads;
	uint64_t        read_bios;
	uint64_t        read_physios;
	uint64_t        biocache_writes;
	uint64_t        write_bios;
	uint64_t        write_physios;
	uint64_t        biocache_readlinks;
	uint64_t        readlink_bios;
	uint64_t        biocache_readdirs;
	uint64_t        readdir_bios;
	uint64_t        rpccnt[NFS_NPROCS];
	uint64_t        rpcretries;
	uint64_t        srvrpccnt[NFS_NPROCS];
	uint64_t        srvrpc_errs;
	uint64_t        srv_errs;
	uint64_t        rpcrequests;
	uint64_t        rpctimeouts;
	uint64_t        rpcunexpected;
	uint64_t        rpcinvalid;
	uint64_t        srvcache_inproghits;
	uint64_t        srvcache_idemdonehits;
	uint64_t        srvcache_nonidemdonehits;
	uint64_t        srvcache_misses;
	uint64_t        srvvop_writes;
	uint64_t        pageins;
	uint64_t        pageouts;
};

New struct nfsclntstats:

/*
 * Stats structure
 */
struct nfsclntstats {
	uint64_t        attrcache_hits;
	uint64_t        attrcache_misses;
	uint64_t        lookupcache_hits;
	uint64_t        lookupcache_misses;
	uint64_t        direofcache_hits;
	uint64_t        direofcache_misses;
	uint64_t        biocache_reads;
	uint64_t        read_bios;
	uint64_t        read_physios;
	uint64_t        biocache_writes;
	uint64_t        write_bios;
	uint64_t        write_physios;
	uint64_t        biocache_readlinks;
	uint64_t        readlink_bios;
	uint64_t        biocache_readdirs;
	uint64_t        readdir_bios;
	uint64_t        rpccntv3[NFS_NPROCS];
	uint64_t        opcntv4[NFS_OP_COUNT];
	uint64_t        rpcretries;
	uint64_t        rpcrequests;
	uint64_t        rpctimeouts;
	uint64_t        rpcunexpected;
	uint64_t        rpcinvalid;
	uint64_t        pageins;
	uint64_t        pageouts;
};

So they are look similar, but not same.
Note this breaks binary compatibility :/ so this this Apple bug :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant