From b3e459e8f7a0b72b0257cf315ca7bd68630e3034 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Wed, 27 Aug 2025 16:41:55 -0300 Subject: [PATCH 1/3] Not finding vmnet shouldn't be a fatal error Allows the build to continue if vmnet isn't supported, either because the deployment target is too old (before 10.10) or the compiler lacks support for blocks (GCC). --- cmake/dep-link.cmake | 26 ++------------------------ cmake/dep-locate.cmake | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/cmake/dep-link.cmake b/cmake/dep-link.cmake index 0dec7bcf6..53a7569dd 100644 --- a/cmake/dep-link.cmake +++ b/cmake/dep-link.cmake @@ -351,35 +351,13 @@ if (WITH_NETWORK) list(APPEND NETWORK_PKG_STATUS "NAT(SLiRP)") endif (WITH_SLIRP) - if (WITH_VMNET AND APPLE) - # CMAKE_OSX_DEPLOYMENT_TARGET is attractive, but not set by default. - # See what we're using, either by default or what the user has set. - check_c_source_compiles( - " - #include - #if TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 - #error macOS too old - #endif - int main(int argc, char **argv) { return 0; } - " TARGETING_MACOS_10_10) - if (NOT TARGETING_MACOS_10_10) - message(FATAL_ERROR "vmnet.framework requires targeting macOS 10.10 or newer") - endif() - - # vmnet requires blocks for its callback parameter, even in vanilla C. - # This is only supported in clang, not by GCC. It's default in clang, - # but we should be clear about it. Do a feature instead of compiler - # check anyways though, in case GCC does add it eventually. - check_c_compiler_flag(-fblocks HAVE_C_BLOCKS) - if (NOT HAVE_C_BLOCKS) - message(FATAL_ERROR "vmnet.framework requires blocks support in the C compiler") - endif() + if (WITH_VMNET AND VMNET_FOUND) target_compile_options(simh_network INTERFACE -fblocks) target_link_libraries(simh_network INTERFACE "-framework vmnet") target_compile_definitions(simh_network INTERFACE HAVE_VMNET_NETWORK) list(APPEND NETWORK_PKG_STATUS "macOS vmnet.framework") - endif(WITH_VMNET AND APPLE) + endif(WITH_VMNET AND VMNET_FOUND) ## Finally, set the network runtime if (NOT network_runtime) diff --git a/cmake/dep-locate.cmake b/cmake/dep-locate.cmake index bd8101595..2cb90b7c5 100644 --- a/cmake/dep-locate.cmake +++ b/cmake/dep-locate.cmake @@ -48,6 +48,37 @@ if (WITH_NETWORK) find_package(VDE) endif () + if (WITH_VMNET AND APPLE) + # CMAKE_OSX_DEPLOYMENT_TARGET is attractive, but not set by default. + # See what we're using, either by default or what the user has set. + check_c_source_compiles( + " + #include + #if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 101000 + #error macOS MAC_OS_X_VERSION_MIN_REQUIRED too old + #else + #error macOS MAC_OS_X_VERSION_MIN_REQUIRED is good + #endif + int main(int argc, char **argv) { return 0; } + " TARGETING_MACOS_10_10) + if (NOT TARGETING_MACOS_10_10) + message(WARNING "vmnet.framework requires targeting macOS 10.10 or newer, skipping support") + endif() + + # vmnet requires blocks for its callback parameter, even in vanilla C. + # This is only supported in clang, not by GCC. It's default in clang, + # but we should be clear about it. Do a feature instead of compiler + # check anyways though, in case GCC does add it eventually. + check_c_compiler_flag(-fblocks HAVE_C_BLOCKS) + if (NOT HAVE_C_BLOCKS) + message(WARNING "vmnet.framework requires blocks support in the C compiler, skipping support") + endif() + + if (TARGETING_MACOS_10_10 AND HAVE_C_BLOCKS) + set(VMNET_FOUND TRUE) + endif() + endif() + ## pcap is special: Headers only and dynamically loaded. if (WITH_PCAP) find_package(PCAP) From 29bdb6fc3c8d9c2d1b59f7da8f624bbb27381b92 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Wed, 27 Aug 2025 17:35:18 -0300 Subject: [PATCH 2/3] Fix broken debug code in CMake --- cmake/dep-locate.cmake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/dep-locate.cmake b/cmake/dep-locate.cmake index 2cb90b7c5..611d0bec0 100644 --- a/cmake/dep-locate.cmake +++ b/cmake/dep-locate.cmake @@ -54,10 +54,8 @@ if (WITH_NETWORK) check_c_source_compiles( " #include - #if TARGET_OS_OSX && MAC_OS_X_VERSION_MIN_REQUIRED < 101000 - #error macOS MAC_OS_X_VERSION_MIN_REQUIRED too old - #else - #error macOS MAC_OS_X_VERSION_MIN_REQUIRED is good + #if TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 + #error macOS too old #endif int main(int argc, char **argv) { return 0; } " TARGETING_MACOS_10_10) From 8f7886003afbd563d0e7f67e6b380f81f5241204 Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Wed, 27 Aug 2025 17:57:27 -0300 Subject: [PATCH 3/3] Check for blocks support in the plain makefile --- makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/makefile b/makefile index 6eeba1034..8fbc59a4f 100644 --- a/makefile +++ b/makefile @@ -1063,12 +1063,21 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin) NETWORK_CCDEFS += -DUSE_NETWORK endif endif - # XXX: Check for the target version of macOS, check for -fblocks + # XXX: Check for the target version of macOS ifeq (Darwin,$(OSTYPE)) - # Provide support for macOS vmnet.framework (requires 10.10) - NETWORK_CCDEFS += -fblocks -DHAVE_VMNET_NETWORK - NETWORK_LAN_FEATURES += vmnet.framework - NETWORK_LDFLAGS += -framework vmnet + # Check if blocks are supported + CC_HELP_OUTPUT_CMD = ${CC} --help 2>&1 + CC_HELP_OUTPUT = $(shell $(CC_HELP_OUTPUT_CMD)) + ifneq (,$(findstring -fblocks,$(CC_HELP_OUTPUT))) + # Provide support for macOS vmnet.framework (requires 10.10) + NETWORK_CCDEFS += -fblocks -DHAVE_VMNET_NETWORK + NETWORK_LAN_FEATURES += vmnet.framework + NETWORK_LDFLAGS += -framework vmnet + else + $(info *** Warning ***) + $(info *** Warning *** No blocks support in the compiler, vmnet.framework will be skipped) + $(info *** Warning ***) + endif endif ifeq (slirp,$(shell if ${TEST} -e slirp_glue/sim_slirp.c; then echo slirp; fi)) NETWORK_CCDEFS += -Islirp -Islirp_glue -Islirp_glue/qemu -DHAVE_SLIRP_NETWORK -DUSE_SIMH_SLIRP_DEBUG slirp/*.c slirp_glue/*.c