Opened 2 years ago

Closed 3 weeks ago

#70694 closed defect (fixed)

qemu @9.1.0: error: implicit declaration of function 'pthread_jit_write_protect_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

Reported by: tom-programming Owned by: herbygillot (Herby Gillot)
Priority: Normal Milestone:
Component: ports Version: 2.10.1
Keywords: legacy-os Cc: raimue (Rainer Müller), herbygillot (Herby Gillot), tom-programming, cooljeanius (Eric Gallager), hadrabap (Petr Hadraba), Randrianasulu (Andrew Randrianasulu)
Port: qemu

Description

qemu fails on compilation in macOS 10.15 (Catalina) with newest command line tools

error is:

:info:build In file included from qapi/qapi-visit-authz.c:13:
:info:build /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_emulators_qemu/qemu/work/qemu-9.1.0/include/qemu/osdep.h:803:5: error: implicit declaration of function 'pthread_jit_write_protect_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build     pthread_jit_write_protect_np(true);
:info:build     ^
:info:build /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_emulators_qemu/qemu/work/qemu-9.1.0/include/qemu/osdep.h:808:5: error: implicit declaration of function 'pthread_jit_write_protect_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build     pthread_jit_write_protect_np(false);
:info:build     ^
:info:build 2 errors generated.

which suggest to me lack of an include pthreads.h directive

Attachments (1)

main.log (497.8 KB) - added by tom-programming 2 years ago.

Download all attachments as: .zip

Change History (10)

Changed 2 years ago by tom-programming

Attachment: main.log added

comment:1 Changed 2 years ago by tom-programming

Cc: tom-programming added

comment:2 Changed 2 years ago by cooljeanius (Eric Gallager)

Cc: cooljeanius added

comment:3 Changed 2 years ago by hadrabap (Petr Hadraba)

Cc: hadrabap added

comment:4 Changed 23 months ago by Randrianasulu (Andrew Randrianasulu)

Cc: Randrianasulu added

comment:5 Changed 23 months ago by ryandesign (Ryan Carsten Schmidt)

Keywords: legacy-os added
Summary: qemu @9.1.0 Error on compilation (pthread_jit_write_protect_np)qemu @9.1.0: error: implicit declaration of function 'pthread_jit_write_protect_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

pthread_jit_write_protect_np is only available in macOS 11 and later. I could not find a web page stating that, but in the file /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/pthread/pthread.h on my system the function is declared as:

__API_AVAILABLE(macos(11.0))
__API_UNAVAILABLE(ios, tvos, watchos, driverkit)
void pthread_jit_write_protect_np(int enabled);

The qemu developers deliberately removed the compatibility code that used to allow it to compile on macOS 10.x:

https://gitlab.com/qemu-project/qemu/-/commit/7b60b971cc2f52ed2a69006a2ad709df2831cd67

The maintainer of the qemu port has previous expressed disinterest in supporting older versions of macOS than the developers of qemu do.

Last edited 23 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:6 Changed 22 months ago by cooljeanius (Eric Gallager)

I also get one of these for IOMainPort when compiling on x86_64 Big Sur with Xcode 13, FWIW:

../qemu-9.1.1/block/file-posix.c:3942:18: error: implicit declaration of function 'IOMainPort' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
                 ^
1 error generated.

(this blocks upgrading of macpine, lima, and colima for me, btw)

Last edited 22 months ago by cooljeanius (Eric Gallager) (previous) (diff)

comment:7 Changed 21 months ago by brendonjkding (Brendon)

Hi, here's all the patches needed to compile on macOS 10.15. Hope it helps. :)

https://github.com/koucyuu/qemu_catalina_patches

comment:8 in reply to:  7 Changed 21 months ago by cooljeanius (Eric Gallager)

Replying to brendonjkding:

Hi, here's all the patches needed to compile on macOS 10.15. Hope it helps. :)

https://github.com/koucyuu/qemu_catalina_patches

Do these fix #71593 too?

comment:9 Changed 3 weeks ago by herbygillot (Herby Gillot)

Owner: set to herbygillot
Resolution: fixed
Status: newclosed

In aae3f6252a00ef40c3dbdcdb4bf0fa08c4c7f83a/macports-ports (master):

qemu: fix build on macOS 11 and earlier

qemu 11.1.0 fails on every buildbot below macOS 12, from 10.6 through 11
on both arches, while 12 and later are green apart from an unrelated
arm64 failure on 12. The cutoff falls where Apple's macOS 11 and 12 API
additions and inclusive-language renames landed. This is not a
compiler-selection problem: the port already sets compiler.blacklist
{clang < 1500} and is therefore already building with macports-clang.
Each failure is a symbol the older SDK does not declare, and since the
port declares no floor and carries deliberate support back to darwin 10,
these are regressions rather than unsupported setups.

Adds seven patchfiles guarding APIs that older SDKs lack:
pthread_jit_write_protect_np (macOS 11), IOMainPort (12),
kAudioObjectPropertyElementMain (12), -[NSScreen safeAreaInsets] (12),
HV_DENIED (11), HV_DEADLINE_FOREVER with hv_vcpu_run_until (11 and
10.15), and timespec_get/TIME_UTC (10.15); and disables vmnet below
darwin 20. Every threshold was read from Apple's own SDK headers on the
target systems rather than from documentation. Constants are guarded on
MAC_OS_X_VERSION_MAX_ALLOWED, since they need only be declared; functions
and Objective-C methods on MAC_OS_X_VERSION_MIN_REQUIRED, since referring
to them below the deployment target would fail at run time even when a
newer SDK declares them.

Two are not simple defines. hv_vcpu_run_until() is annotated HV_10_15,
so below 10.15 the function itself is absent and no #define can help; the
shim falls back to hv_vcpu_run(), which Apple's macOS 11 header documents
as its equivalent for an infinite deadline, keeping HVF acceleration
instead of dropping those hosts to TCG. vmnet is an upstream detection
bug: meson probes for VMNET_BRIDGED_MODE, which 10.15 does have, and then
compiles net/vmnet-* against macOS 11 symbols that it does not.

Verified by full clean builds on 10.14.6, 10.15.7 and 11.7.10 with zero
patch failures and HVF present in each. Because the macOS 11 test host
carried an SDK newer than its OS, a second build there pinned to an 11.3
SDK exercises the other branch of the macOS 12 guards. Symbol selection
was confirmed against the built binaries. Not tested below 10.14, on
arm64, or with a running guest.

Closes: #70694
Closes: #72042
Closes: #70482
Assisted-by: Claude:claude-opus-5
Co-Authored-By: Claude Opus 5 <noreply@…>

Note: See TracTickets for help on using tickets.