[CDRIVER-4505] mongoc counters on macos M1 fails due to an undeclared function call Created: 17/Oct/22  Updated: 28/Oct/23  Resolved: 26/Oct/22

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.23.2

Type: Bug Priority: Unknown
Reporter: Gil Alon Assignee: Kyle Kloberdanz
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Summary

Building the CDriver on a M1 macOS fails because of a call to an undeclared function (getpagesize). However, this function is available on macOS M1. Using the configuration and the build commands listed below, the c driver can't be built.

Environment

C driver version is 1.23.0

The host is on MacOS Monterey 12.6 on the M1 chip ARM64. 

clang version 15.0.2

How to Reproduce

These steps were taken from the C Driver Getting Started guide.

Configure cmake:

cmake \    
-DCMAKE_C_COMPILER="<path to LLVM>/bin/clang" \    
-DENABLE_MAINTAINER_FLAGS=ON \    
-DMONGO_SANITIZE="address;leak" \    
-B./cmake-build 

Then build the executables:

cmake --build cmake-build --target example-client 

Then run the executable 

./cmake-build/src/libmongoc/example-client 

This error will appear in 
mongo-c-driver/src/libmongoc/src/mongoc/mongoc-counters.c

error: call to undeclared function 'getpagesize'; ISO C99 and later do not support implicit function declarations [-Werror,-Wimplicit-function-declaration] return BSON_MAX (getpagesize (), size);



 Comments   
Comment by Githook User [ 03/Jan/23 ]

Author:

{'name': 'Kyle Kloberdanz', 'email': 'kyle.kloberdanz@mongodb.com', 'username': 'kkloberdanz'}

Message: CDRIVER-4505 Fix build on MacOS due to undeclared getpagesize (#1136)

Fix build on MacOS due to undeclared getpagesize

CDRIVER-4505

It appears that getpagesize has been deprecated on newer MacOS versions.
We can see that POSIX version 7 (link below) has removed getpagesize
altogether from the standard, so even including unistd.h does not solve
this problem on newer MacOS versions.

Please see here at section
B.3.2 System Interfaces Removed in the Previous Version:
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html

Relevant stackoverflow:
https://stackoverflow.com/a/37193970

Jira:
https://jira.mongodb.org/browse/CDRIVER-4505
Branch: r1.23
https://github.com/mongodb/mongo-c-driver/commit/592c1562785f4ac8b9f4570e801ad5a13bbd39a7

Comment by Githook User [ 26/Oct/22 ]

Author:

{'name': 'Kyle Kloberdanz', 'email': 'kyle.kloberdanz@mongodb.com', 'username': 'kkloberdanz'}

Message: CDRIVER-4505 Fix build on MacOS due to undeclared getpagesize (#1136)

Fix build on MacOS due to undeclared getpagesize

CDRIVER-4505

It appears that getpagesize has been deprecated on newer MacOS versions.
We can see that POSIX version 7 (link below) has removed getpagesize
altogether from the standard, so even including unistd.h does not solve
this problem on newer MacOS versions.

Please see here at section
B.3.2 System Interfaces Removed in the Previous Version:
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html

Relevant stackoverflow:
https://stackoverflow.com/a/37193970

Jira:
https://jira.mongodb.org/browse/CDRIVER-4505
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/a73297b3402c2acfdf47895b8d657b369fae7a38

Generated at Wed Feb 07 21:21:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.