diff --git a/Configuration/UTMQemuConfiguration+Arguments.swift b/Configuration/UTMQemuConfiguration+Arguments.swift index 1fd7d70b..8488af2e 100644 --- a/Configuration/UTMQemuConfiguration+Arguments.swift +++ b/Configuration/UTMQemuConfiguration+Arguments.swift @@ -349,13 +349,9 @@ import Virtualization // for getting network interfaces } private var isNeptuneSupported: Bool { - #if os(macOS) isGLSupported && (rendererBackend == .qemuRendererBackendAngleMetal || rendererBackend == .qemuRendererBackendDefault) && directXDriver != .qemuDirectXDriverDisabled - #else - false - #endif } private var isSparc: Bool { diff --git a/Platform/iOS/Settings.bundle/Root.plist b/Platform/iOS/Settings.bundle/Root.plist index 4dd7e428..b7eacab9 100644 --- a/Platform/iOS/Settings.bundle/Root.plist +++ b/Platform/iOS/Settings.bundle/Root.plist @@ -171,6 +171,32 @@ iOS-Remote + + Type + PSMultiValueSpecifier + Title + DirectX Driver + Key + QEMUDirectXDriver + DefaultValue + 0 + Titles + + Default + Disabled + DXMT + + Values + + 0 + 1 + 2 + + ExcludeTargets + + iOS-Remote + + Type PSMultiValueSpecifier diff --git a/UTM.xcodeproj/project.pbxproj b/UTM.xcodeproj/project.pbxproj index e160d35b..2221f91b 100644 --- a/UTM.xcodeproj/project.pbxproj +++ b/UTM.xcodeproj/project.pbxproj @@ -632,6 +632,8 @@ CE2D958E24AD4F990059923A /* UTMApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE2D955524AD4F980059923A /* UTMApp.swift */; }; CE2D958F24AD4FF00059923A /* VMCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE2D954324AD4F980059923A /* VMCardView.swift */; }; CE2D959024AD50D50059923A /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 521F3EFB2414F73800130500 /* Localizable.strings */; }; + CE30F93630200C2000024DB2 /* dxmt-native.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CEA3EDE93016810500AAA8E4 /* dxmt-native.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + CE30F93730200C3300024DB2 /* dxmt-native.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CEA3EDE93016810500AAA8E4 /* dxmt-native.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CE38EC692B5DB3AE008B324B /* UTMRemoteClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE38EC682B5DB3AE008B324B /* UTMRemoteClient.swift */; }; CE4698F924C8FBD9008C1BD6 /* Icons in Resources */ = {isa = PBXBuildFile; fileRef = CE4698F824C8FBD9008C1BD6 /* Icons */; }; CE4698FA24C8FBD9008C1BD6 /* Icons in Resources */ = {isa = PBXBuildFile; fileRef = CE4698F824C8FBD9008C1BD6 /* Icons */; }; @@ -735,9 +737,7 @@ CE9B15482B12A87E003A32DD /* GenerateKey.c in Sources */ = {isa = PBXBuildFile; fileRef = CE9B15462B12A87E003A32DD /* GenerateKey.c */; }; CE9B15492B12A87E003A32DD /* GenerateKey.c in Sources */ = {isa = PBXBuildFile; fileRef = CE9B15462B12A87E003A32DD /* GenerateKey.c */; }; CE9B154A2B12A87E003A32DD /* GenerateKey.c in Sources */ = {isa = PBXBuildFile; fileRef = CE9B15462B12A87E003A32DD /* GenerateKey.c */; }; - CEA3EDEB3016810500AAA8E4 /* dxmt-native.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA3EDE93016810500AAA8E4 /* dxmt-native.framework */; }; CEA3EDEC3016810500AAA8E4 /* dxmt-native.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CEA3EDE93016810500AAA8E4 /* dxmt-native.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - CEA3EDED3016810500AAA8E4 /* d3dmetal-native.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEA3EDEA3016810500AAA8E4 /* d3dmetal-native.framework */; }; CEA3EDEE3016810500AAA8E4 /* d3dmetal-native.framework in Embed Libraries */ = {isa = PBXBuildFile; fileRef = CEA3EDEA3016810500AAA8E4 /* d3dmetal-native.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; CEA3EE05301691C500AAA8E4 /* QEMURenderServer.app in Embed Executables */ = {isa = PBXBuildFile; fileRef = CEA3EDFA30168B9000AAA8E4 /* QEMURenderServer.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; CEA45E25263519B5002FA97D /* VMDisplayMetalViewController+Pointer.h in Sources */ = {isa = PBXBuildFile; fileRef = 83FBDD53242FA71900D2C5D7 /* VMDisplayMetalViewController+Pointer.h */; }; @@ -1452,6 +1452,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + CE30F93730200C3300024DB2 /* dxmt-native.framework in Embed Libraries */, CE2D937624AD46670059923A /* gpg-error.0.framework in Embed Libraries */, CE2D937724AD46670059923A /* qemu-mips64el-softmmu.framework in Embed Libraries */, CE2D937824AD46670059923A /* gstcontroller-1.0.0.framework in Embed Libraries */, @@ -1553,6 +1554,7 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( + CE30F93630200C2000024DB2 /* dxmt-native.framework in Embed Libraries */, CEA45F72263519B5002FA97D /* gpg-error.0.framework in Embed Libraries */, CE63B0FD2F0EFB0700C59D13 /* vulkan_kosmickrisp.framework in Embed Libraries */, CEA45F74263519B5002FA97D /* gstcontroller-1.0.0.framework in Embed Libraries */, @@ -2369,7 +2371,6 @@ CEF83F882500949D00557D15 /* gthread-2.0.0.framework in Frameworks */, CE03D08724D90F0700F76B84 /* gobject-2.0.0.framework in Frameworks */, CE9B15362B11A491003A32DD /* SwiftConnect in Frameworks */, - CEA3EDED3016810500AAA8E4 /* d3dmetal-native.framework in Frameworks */, CE0B6F0A24AD677200FE012D /* spice-client-glib-2.0.8.framework in Frameworks */, CE0B6ECF24AD677200FE012D /* gstrtp-1.0.0.framework in Frameworks */, CE0B6ECC24AD677200FE012D /* gstriff-1.0.0.framework in Frameworks */, @@ -2385,7 +2386,6 @@ CE0B6EBB24AD677200FE012D /* libgstgio.a in Frameworks */, 84937EFF28960789003148F4 /* zstd.1.framework in Frameworks */, CE0B6EE224AD677200FE012D /* gstnet-1.0.0.framework in Frameworks */, - CEA3EDEB3016810500AAA8E4 /* dxmt-native.framework in Frameworks */, CE03D08624D90F0700F76B84 /* gmodule-2.0.0.framework in Frameworks */, CED297142CE425CB00F1E3EB /* soup-3.0.0.framework in Frameworks */, CE03D0CA24D9142000F76B84 /* ssl.1.1.framework in Frameworks */, diff --git a/patches/llvm-project-15.0.7.src.patch b/patches/llvm-project-15.0.7.src.patch new file mode 100644 index 00000000..c321c6ff --- /dev/null +++ b/patches/llvm-project-15.0.7.src.patch @@ -0,0 +1,49 @@ +LLVM 15 gates its Mach-O linker behaviour on `CMAKE_SYSTEM_NAME MATCHES "Darwin"`, +which is false when cross-compiling for iOS/visionOS (CMAKE_SYSTEM_NAME is "iOS" / +"visionOS"). The build then falls through to the ELF/COFF paths and passes flags +Apple's ld rejects. Use `APPLE`, which is true for every Apple platform. + +Fixed upstream after 15.x; drop this patch when moving to a newer LLVM. + + 1. add_llvm_symbol_exports() fell through to the Windows branch and handed a + .def file to ld: + ld: unknown file type in '.../LLVMHello.def' + + 2. -Wl,-z,defs is ELF-only and was not excluded for iOS: + ld: unknown options: -z + + 3. add_link_opts() skipped -Wl,-dead_strip, so non-Debug builds silently lost + dead stripping that the macOS build of the same sources already gets. + Not a build failure, just larger output. + +--- a/llvm/cmake/modules/AddLLVM.cmake ++++ b/llvm/cmake/modules/AddLLVM.cmake +@@ -82,7 +82,7 @@ + endfunction() + + function(add_llvm_symbol_exports target_name export_file) +- if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ++ if(APPLE) + set(native_export_file "${target_name}.exports") + add_custom_command(OUTPUT ${native_export_file} + COMMAND sed -e "s/^/_/" < ${export_file} > ${native_export_file} +@@ -263,7 +263,7 @@ + # linker in a context where the optimizations are not important. + if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + if(NOT LLVM_NO_DEAD_STRIP) +- if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") ++ if(APPLE) + # ld64's implementation of -dead_strip breaks tools that use plugins. + set_property(TARGET ${target_name} APPEND_STRING PROPERTY + LINK_FLAGS " -Wl,-dead_strip") +--- a/llvm/cmake/modules/HandleLLVMOptions.cmake ++++ b/llvm/cmake/modules/HandleLLVMOptions.cmake +@@ -229,7 +229,7 @@ + # Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO + # build might work on ELF but fail on MachO/COFF. + if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX|SunOS|OS390" OR +- WIN32 OR CYGWIN) AND ++ APPLE OR WIN32 OR CYGWIN) AND + NOT LLVM_USE_SANITIZER) + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs") + endif() diff --git a/patches/sources b/patches/sources index 6f183033..0b775533 100644 --- a/patches/sources +++ b/patches/sources @@ -53,7 +53,7 @@ MOLTENVK_REPO="https://github.com/utmapp/MoltenVK.git" MOLTENVK_COMMIT="ef1c5461774f5fbd224ddcfd91fd2c0ea23f0384" LLVM15_SRC="https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-project-15.0.7.src.tar.xz" DXMT_REPO="https://github.com/utmapp/dxmt.git" -DXMT_COMMIT="be80e14c07613cd558036a576b82dc6d78acdfce" +DXMT_COMMIT="822ae637a39512ddbd8e0bbd7744af514670c9d3" D3DMETAL_REPO="https://github.com/utmapp/d3dmetal-native.git" D3DMETAL_COMMIT="edd2e386c25a2039eca0f6ce8f794b3b165841eb" diff --git a/scripts/build_dependencies.sh b/scripts/build_dependencies.sh index 2cfedfbf..e39881a0 100755 --- a/scripts/build_dependencies.sh +++ b/scripts/build_dependencies.sh @@ -301,6 +301,26 @@ generate_meson_cross() { else echo "system = '$system'" >> $cross fi + if [ "$system" == "darwin" ]; then + echo "kernel = 'xnu'" >> $cross + case $PLATFORM in + ios_simulator* ) + echo "subsystem = 'ios-simulator'" >> $cross + ;; + ios* ) + echo "subsystem = 'ios'" >> $cross + ;; + visionos_simulator* ) + echo "subsystem = 'visionos-simulator'" >> $cross + ;; + visionos* ) + echo "subsystem = 'visionos'" >> $cross + ;; + macos ) + echo "subsystem = 'macos'" >> $cross + ;; + esac + fi case "$ARCH" in armv7 | armv7s ) echo "cpu_family = 'arm'" >> $cross @@ -625,6 +645,19 @@ meson_darwin_build () { meson_cross_build darwin $@ } +# The generated toolchain file is the single source of truth for CMake builds: +# it sets every compiler, binutil, and flag variable with CACHE FORCE. The +# exported CC/CFLAGS/... are needed by the autotools and meson builds, but for +# CMake they are redundant *and* harmful: a nested host configure that does not +# get the toolchain file (such as LLVM's NATIVE sub-build for llvm-tblgen) +# inherits them from the environment and ends up compiling for the target while +# discovering and linking host libraries. Drop them for every cmake invocation. +cmake_clean_env () { + env -u CC -u CPP -u CXX -u OBJCC -u LD -u AR -u NM -u RANLIB -u STRIP \ + -u CFLAGS -u CPPFLAGS -u CXXFLAGS -u OBJCFLAGS -u LDFLAGS \ + cmake "$@" +} + cmake_build () { SRCDIR="$1" shift 1 @@ -650,7 +683,7 @@ cmake_build () { mkdir -p "$BUILDDIR" echo "${GREEN}Configuring ${NAME}...${NC}" - cmake -S . -B "$BUILDDIR" \ + cmake_clean_env -S . -B "$BUILDDIR" \ -DCMAKE_INSTALL_PREFIX="$PREFIX" \ -DCMAKE_BUILD_TYPE="$BUILD_CONFIGURATION" \ -DCMAKE_TOOLCHAIN_FILE="$CMAKE_TOOLCHAIN" \ @@ -658,10 +691,10 @@ cmake_build () { fi echo "${GREEN}Building ${NAME}...${NC}" - cmake --build "$BUILDDIR" --parallel "$NCPU" + cmake_clean_env --build "$BUILDDIR" --parallel "$NCPU" echo "${GREEN}Installing ${NAME}...${NC}" - cmake --install "$BUILDDIR" + cmake_clean_env --install "$BUILDDIR" cd "$pwd" } @@ -843,8 +876,8 @@ build_vulkan_drivers () { build_d3d_drivers () { LLVM15_NAME=$(basename "${LLVM15_SRC%.tar.*}") cmake_build "$BUILD_DIR/$LLVM15_NAME/llvm" -DLLVM_ENABLE_ZSTD=Off -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_TOOLS=Off -DLLVM_VERSION_PRINTER_SHOW_HOST_TARGET_INFO=Off - meson_build $DXMT_REPO -Dnative_llvm_path="$PREFIX" - if [ "$ARCH" == "x86_64" ]; then + meson_darwin_build $DXMT_REPO -Dnative_llvm_path="$PREFIX" + if [ "$ARCH" == "x86_64" -a "$PLATFORM" == "macos" ]; then meson_build $D3DMETAL_REPO -Dtests=disabled else # empty placeholder file @@ -1046,7 +1079,7 @@ ios* | visionos* ) PLATFORM_FAMILY_NAME="$PLATFORM_FAMILY_PREFIX" ;; esac - QEMU_PLATFORM_BUILD_FLAGS="--enable-shared-lib --disable-cocoa --disable-coreaudio --disable-slirp-smbd --enable-ucontext --with-coroutine=libucontext $HVF_FLAGS $TCI_BUILD_FLAGS" + QEMU_PLATFORM_BUILD_FLAGS="--enable-shared-lib --disable-cocoa --disable-sdl --disable-coreaudio --disable-slirp-smbd --enable-ucontext --with-coroutine=libucontext $HVF_FLAGS $TCI_BUILD_FLAGS" ;; macos ) if [ -z "$SDKMINVER" ]; then @@ -1055,7 +1088,7 @@ macos ) SDK=macosx CFLAGS_TARGET="-target $ARCH-apple-macos$SDKMINVER" PLATFORM_FAMILY_NAME="macOS" - QEMU_PLATFORM_BUILD_FLAGS="--enable-shared-lib --disable-cocoa --cpu=$CPU" + QEMU_PLATFORM_BUILD_FLAGS="--enable-shared-lib --disable-cocoa --disable-sdl --cpu=$CPU" ;; * ) usage @@ -1176,9 +1209,7 @@ build_qemu_dependencies build $QEMU_DIR --cross-prefix="" $QEMU_PLATFORM_BUILD_FLAGS $QEMU_DEBUG_FLAGS build_spice_client build_vulkan_drivers -if [ "$PLATFORM" == "macos" ]; then - build_d3d_drivers -fi +build_d3d_drivers fixup_all remove_shared_gst_plugins # another hack... echo "${GREEN}All done!${NC}"