[CONC-521] ucontext not detected on macOS with Apple Silicon Created: 2021-01-09  Updated: 2021-06-14  Resolved: 2021-01-21

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: 3.1.11
Fix Version/s: 3.2.0, 3.1.12

Type: Bug Priority: Minor
Reporter: Evan Miller Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: None
Environment:

macOS 11.1
Apple clang version 12.0.0 (clang-1200.0.32.28)



 Description   

The non-blocking functions on non-x86 architectures require ucontext. However, ucontext is not properly detected on Apple Silicon systems because _XOPEN_SOURCE must be set in order to expose makecontext to the compiler. The error log indicates:

{{
Determining if files ucontext.h exist failed with the following output:
Change Dir: /XXX/mariadb-connector-c-3.1.11-src/CMakeFiles/CMakeTmp

Run Build Command(s):/Library/Developer/CommandLineTools/usr/bin/make cmTC_b1c76/fast && /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_b1c76.dir/build.make CMakeFiles/cmTC_b1c76.dir/build
Building C object CMakeFiles/cmTC_b1c76.dir/HAVE_FILE_UCONTEXT_H.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -arch x86_64 -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk -mmacosx-version-min=10.13 -o CMakeFiles/cmTC_b1c76.dir/HAVE_FILE_UCONTEXT_H.c.o -c /XXX/mariadb-connector-c-3.1.11-src/CMakeFiles/CheckIncludeFiles/HAVE_FILE_UCONTEXT_H.c
In file included from /XXX/mariadb-connector-c-3.1.11-src/CMakeFiles/CheckIncludeFiles/HAVE_FILE_UCONTEXT_H.c:2:
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/usr/include/ucontext.h:51:2: error: The deprecated ucontext routines require _XOPEN_SOURCE to be defined
#error The deprecated ucontext routines require _XOPEN_SOURCE to be defined
^
1 error generated.
make[1]: *** [CMakeFiles/cmTC_b1c76.dir/HAVE_FILE_UCONTEXT_H.c.o] Error 1
make: *** [cmTC_b1c76/fast] Error 2
}}

The message states that the ucontext functions are deprecated. However, in my testing the functions do work on Apple Silicon systems, and they are the only way to enable MYSQL_OPT_NONBLOCK on those machines. I will open a pull request on GitHub with the changes that I suggest.



 Comments   
Comment by Evan Miller [ 2021-01-09 ]

Pull request: https://github.com/mariadb-corporation/mariadb-connector-c/pull/152

Comment by Georg Richter [ 2021-01-21 ]

Fixed. Kudos to Even Miller for providing the fix

Generated at Thu Feb 08 03:05:55 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.