Opened 21 months ago

Closed 3 months ago

#72042 closed defect (fixed)

qemu @9.2.0: error: call to undeclared function 'IOMainPort'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Reported by: chriskuku Owned by: raimue (Rainer Müller)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: herbygillot (Herby Gillot), Dave-Allured (Dave Allured), ileadu (Marshall)
Port: qemu

Description (last modified by jmroot (Joshua Root))

port install qemu fails (macOS BigSur, 11.7.10)

$ sudo port install qemu
--->  Computing dependencies for qemu
--->  Fetching archive for qemu
--->  Attempting to fetch qemu-9.2.0_0+cocoa+curses+spice+spice_protocol+target_arm+target_i386+target_x86_64+usb+vnc.darwin_20.x86_64.tbz2 from https://fra.de.packages.macports.org/qemu
--->  Attempting to fetch qemu-9.2.0_0+cocoa+curses+spice+spice_protocol+target_arm+target_i386+target_x86_64+usb+vnc.darwin_20.x86_64.tbz2 from https://packages.macports.org/qemu
--->  Attempting to fetch qemu-9.2.0_0+cocoa+curses+spice+spice_protocol+target_arm+target_i386+target_x86_64+usb+vnc.darwin_20.x86_64.tbz2 from https://vie.at.packages.macports.org/qemu
--->  Building qemu
Error: Failed to build qemu: command execution failed    
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_emulators_qemu/qemu/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a bug.
Error: Processing of port qemu failed
$ 

Attachments (1)

main.log.bz2​ (55.8 KB) - added by jmroot (Joshua Root) 21 months ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 21 months ago by jmroot (Joshua Root)

Cc: herbygillot added
Description: modified (diff)
Owner: set to raimue
Port: qemu added
Status: new → assigned

Please attach the main.log.

Changed 21 months ago by jmroot (Joshua Root)

Attachment: main.log.bz2​ added

comment:2 Changed 21 months ago by jmroot (Joshua Root)

:info:build ../qemu-9.2.0/block/file-posix.c:3942:18: error: call to undeclared function 'IOMainPort'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
:info:build  3942 |     kernResult = IOMainPort(MACH_PORT_NULL, &mainPort);
:info:build       |                  ^

Different function, but might effectively be a duplicate of #71857.

comment:3 Changed 20 months ago by Dave-Allured (Dave Allured)

Cc: Dave-Allured added

comment:4 in reply to:  2 Changed 20 months ago by Dave-Allured (Dave Allured)

Replying to jmroot:

Different function, but might effectively be a duplicate of #71857.

Not really a duplicate. #71857 is originally about accessing the Hypervisor framework. This report for IOMainPort concerns file I/O. QEMU is strict about deprecating older macos versions. So these two tickets are about different deprecations, probably at different times.

Here is the QEMU commit that removed IOMainPort:
"Drop ifdef for macOS versions older than 12.0"
​https://gitlab.com/qemu-project/qemu/-/commit/e9c9d8dc3ba993384bc9553b617120ad4717345c

Same issue filed for upstream. Note, "won't fix" for macOS < 12.0, unfortunately. They say that even 12.x and 13.x are no longer officially supported.
​https://gitlab.com/qemu-project/qemu/-/issues/2694

comment:5 Changed 20 months ago by Dave-Allured (Dave Allured)

The discussion in #71857 leads to this patch, which I think would fix this particular IOMainPort build error on BigSur/OS 11:
​https://github.com/koucyuu/qemu_catalina_patches/blob/master/patch-qemu-block-file-posix.diff

So how far does MacPorts want to go, patching QEMU to support older OS versions that upstream is actively discouraging? Tickets on both MacPorts and QEMU suggest ongoing interest within the legacy Mac user base.

comment:6 Changed 15 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: ileadu added
Summary: qemu port fails → qemu @9.2.0: error: call to undeclared function 'IOMainPort'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

MacPorts probably doesn't want to patch qemu to reinstate support for old OS versions that upstream has removed.

But we could introduce ports for older versions of qemu that would work on older OS versions.

Has duplicate #72665.

comment:7 Changed 3 months ago by herbygillot (Herby Gillot)

Resolution: → fixed
Status: assigned → closed

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.