diff --git a/app-emulation/FEX/FEX-2410-r1.ebuild b/app-emulation/FEX/FEX-2410-r1.ebuild deleted file mode 100644 index 25b5d0e..0000000 --- a/app-emulation/FEX/FEX-2410-r1.ebuild +++ /dev/null @@ -1,333 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -LLVM_COMPAT=( 18 ) -LLVM_OPTIONAL=1 - -inherit flag-o-matic cmake toolchain-funcs llvm-r1 - -DESCRIPTION="A fast usermode x86 and x86-64 emulator for Arm64 Linux" -HOMEPAGE="https://fex-emu.com" - -JEMALLOC_HASH="02ca52b5fefc0ccd0d2c4eaa1d17989cdd641927" -JEMALLOC_GLIBC_HASH="404353974e335fb771562249163e2ea62c558e7e" -# TODO: unvendor this when this version will be available in gentoo -FMTLIB_V="11.0.2" -CPP_OPTPARSE_HASH="eab4212ae864ba64306f0fe87f102e66cb5a3617" -ROBIN_MAP_HASH="d5683d9f1891e5b04e3e3b2192b5349dc8d814ea" - -# This need to be vendored since thunk generator does not support the latest version -VULKAN_HEADERS_HASH="29f979ee5aa58b7b005f805ea8df7a855c39ff37" - -SRC_URI=" - https://github.com/FEX-Emu/jemalloc/archive/${JEMALLOC_HASH}.tar.gz -> jemalloc-${JEMALLOC_HASH}.tar.gz - https://github.com/FEX-Emu/jemalloc/archive/${JEMALLOC_GLIBC_HASH}.tar.gz -> jemalloc-glibc-${JEMALLOC_GLIBC_HASH}.tar.gz - https://github.com/fmtlib/fmt/archive/refs/tags/${FMTLIB_V}.tar.gz -> libfmt-${FMTLIB_V}.tar.gz - https://github.com/Sonicadvance1/cpp-optparse/archive/${CPP_OPTPARSE_HASH}.tar.gz -> cpp-optparse-${CPP_OPTPARSE_HASH}.tar.gz - https://github.com/FEX-Emu/robin-map/archive/${ROBIN_MAP_HASH}.tar.gz -> robin-map-${ROBIN_MAP_HASH}.tar.gz - thunks? ( - https://github.com/KhronosGroup/Vulkan-Headers/archive/${VULKAN_HEADERS_HASH}.tar.gz -> Vulkan-Headers-${VULKAN_HEADERS_HASH}.tar.gz - ) - https://github.com/FEX-Emu/${PN}/archive/refs/tags/${P}.tar.gz -" - -S="${WORKDIR}/${PN}-${P}" - -LICENSE="MIT" -SLOT="0" -KEYWORDS="-* ~arm64" -BDEPEND=" - sys-devel/clang - sys-devel/llvm - thunks? ( - !crossdev-toolchain? ( - sys-devel/x86_64-multilib-toolchain - ) - $(llvm_gen_dep ' - sys-devel/clang:${LLVM_SLOT}= - sys-devel/llvm:${LLVM_SLOT}= - ') - ) -" -RDEPEND=" - dev-libs/xxhash - qt5? ( - dev-qt/qtcore:5 - dev-qt/qtgui:5[wayland(-),X(-)] - dev-qt/qtwidgets[X] - ) - qt6? ( - dev-qt/qtbase:6[gui,wayland(-),widgets,X(-)] - dev-qt/qtdeclarative:6 - ) - thunks? ( - x11-libs/libX11 - x11-libs/libdrm - dev-libs/wayland - media-libs/alsa-lib - media-libs/libglvnd - x11-libs/libxcb - ) - app-emulation/fex-rootfs-gentoo - app-emulation/fex-rootfs-mesa-asahi -" -DEPEND=" - >=sys-kernel/linux-headers-6.8 - ${RDEPEND} -" - -PATCHES=" - ${FILESDIR}/${P}-unvendor-drm-headers.patch - ${FILESDIR}/${P}-tiny-json-as-static.patch - ${FILESDIR}/${P}-fmt-as-static.patch - ${FILESDIR}/${PN}-thunks-toolchain-paths.patch - ${FILESDIR}/${PN}-thunkgen-gcc-install-dir.patch - ${FILESDIR}/${P}-clone-fork-semantics.patch - ${FILESDIR}/${P}-listen-abstract-named-sockets.patch - ${FILESDIR}/${P}-align-stack-base.patch - ${FILESDIR}/${P}-hide-rootfs-fd.patch - ${FILESDIR}/${P}-hide-rootfs-fd-2.patch -" - -IUSE="crossdev-toolchain fexconfig qt5 qt6 +thunks" - -REQUIRED_USE=" - crossdev-toolchain? ( thunks ) - fexconfig? ( ^^ ( qt5 qt6 ) ) - thunks? ( ${LLVM_REQUIRED_USE} ) -" - -my-test-flag-PROG() { - local comp=$1 - local lang=$2 - shift 2 - - if [[ -z $1 ]]; then - return 1 - fi - - if ! type -p ${comp[0]} >/dev/null; then - return 1 - fi - - local in_src in_ext cmdline_extra=() - case "${lang}" in - c) - in_ext='c' - in_src='int main(void) { return 0; }' - cmdline_extra+=(-xc -c) - ;; - c++) - in_ext='cc' - in_src='int main(void) { return 0; }' - cmdline_extra+=(-xc++ -c) - ;; - esac - local test_in=${T}/test-flag.${in_ext} - local test_out=${T}/test-flag.exe - - printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'" - local cmdline=( - "${comp[@]}" - -Werror - "$@" - "${cmdline_extra[@]}" - "${test_in}" -o "${test_out}" - ) - - "${cmdline[@]}" &>/dev/null -} - -my-test-flags-PROG() { - local comp=$1 - local lang=$2 - local flags=() - local x - - shift 2 - - while (( $# )); do - case "$1" in - --param|-B) - if my-test-flag-PROG ${comp} ${lang} "$1" "$2"; then - flags+=( "$1" "$2" ) - fi - shift 2 - ;; - *) - if my-test-flag-PROG ${comp} ${lang} "$1"; then - flags+=( "$1" ) - fi - shift 1 - ;; - esac - done - - echo "${flags[*]}" - [[ ${#flags[@]} -gt 0 ]] -} - -my-filter-var() { - local f x var=$1 new=() - shift - - for f in ${!var} ; do - for x in "$@" ; do - [[ ${f} == ${x} ]] && continue 2 - done - new+=( "${f}" ) - done - export ${var}="${new[*]}" -} - -THUNK_INC_DIR="${WORKDIR}/thunk-include" - -find_compiler() { - ( - pattern="$1" - shift - shopt -s nullglob - IFS=: read -r -a paths <<<"$PATH" - for dir in "${paths[@]}"; do - for cand in "$dir"/$pattern; do - "${cand}" -o /dev/null -x c "$@" - 2>/dev/null >/dev/null <<<'int main(){}' && echo "${cand#/${dir}}" && return 0 - done - done - return 1 - ) -} - -pkg_setup() { - use thunks && llvm-r1_pkg_setup -} - -pkg_pretend() { - [[ ${MERGE_TYPE} == binary ]] && return - use thunks || return - use crossdev-toolchain || return - errmsg="Unable to find a working ARCH compiler on your system. You need to install one using crossdev." - find_compiler 'x86_64*-linux-gnu-gcc' >/dev/null || die "${errmsg/ARCH/x86_64}" - find_compiler 'i?86*-linux-gnu-gcc' >/dev/null || find_compiler 'x86_64*-linux-gnu-gcc' -m32 >/dev/null || die "${errmsg/ARCH/i686}" -} - -src_unpack() { - default - local -A deps=( - jemalloc "jemalloc-${JEMALLOC_HASH}" - jemalloc_glibc "jemalloc-${JEMALLOC_GLIBC_HASH}" - fmt "fmt-${FMTLIB_V}" - robin-map "robin-map-${ROBIN_MAP_HASH}" - ) - use thunks && deps[Vulkan-Headers]="Vulkan-Headers-${VULKAN_HEADERS_HASH}" - for dep in "${!deps[@]}"; do - rmdir "${S}/External/${dep}" || die - mv "${WORKDIR}/${deps[${dep}]}" "${S}/External/${dep}" - done - rmdir "${S}/Source/Common/cpp-optparse" || die - mv "${WORKDIR}/cpp-optparse-${CPP_OPTPARSE_HASH}" "${S}/Source/Common/cpp-optparse" || die -} - -THUNK_HEADERS=" - GL - EGL - GLES - GLES2 - GLES3 - KHR - glvnd - wayland-client-core.h - wayland-client-protocol.h - wayland-client.h - wayland-cursor.h - wayland-egl-backend.h - wayland-egl-core.h - wayland-egl.h - wayland-server-core.h - wayland-server-protocol.h - wayland-server.h - wayland-util.h - wayland-version.h - X11 - libdrm - libsync.h - xf86drm.h - xf86drmMode.h - alsa - xcb -" - -src_prepare() { - cmake_src_prepare - sed -i -e "s:__REPLACE_ME_WITH_HEADER_DIR__:${THUNK_INC_DIR}:" ThunkLibs/GuestLibs/CMakeLists.txt || die - mkdir "${THUNK_INC_DIR}" || die - for header in $THUNK_HEADERS; do - cp -a "${BROOT}/usr/include/${header}" "${THUNK_INC_DIR}/${header}" || die - done -} - -src_configure() { - if ! tc-is-clang ; then - AR=llvm-ar - CC=clang - CXX=clang++ - NM=llvm-nm - RANLIB=llvm-ranlib - STRIP=llvm-strip - - strip-unsupported-flags - fi - oldpath="${PATH}" - use crossdev-toolchain || PATH="${BROOT}/usr/lib/x86_64-multilib-toolchain/bin:${PATH}" - - local x64_cc="$(find_compiler 'x86_64*-linux-gnu-gcc' || die)" - local x86_cc - if x86_cc="$(find_compiler 'x86_64*-linux-gnu-gcc' -m32)"; then - x86_cc="${x86_cc} -m32" - else - x86_cc="$(find_compiler 'i?86*-linux-gnu-gcc' || die)" - fi - - sed -i -e "s:__REPLACE_ME_WITH_C_COMPILER__:${x64_cc}:" toolchain_x86_64.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_C_COMPILER__:${x86_cc}:" toolchain_x86_32.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_CXX_COMPILER__:${x64_cc/linux-gnu-gcc/linux-gnu-g++}:" toolchain_x86_64.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_CXX_COMPILER__:${x86_cc/linux-gnu-gcc/linux-gnu-g++}:" toolchain_x86_32.cmake || die - - export X86_CFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/cc} c ${CFLAGS} ${LDFLAGS})" - export X86_CXXFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/c++} c++ ${CXXFLAGS} ${LDFLAGS})" - export X86_LDFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/cc} c ${LDFLAGS})" - - my-filter-var X86_CFLAGS '-flto*' -fwhole-program-vtables '-fsanitize=cfi*' - my-filter-var X86_CXXFLAGS '-flto*' -fwhole-program-vtables '-fsanitize=cfi*' - - tc-export CC CXX LD AR NM OBJDUMP RANLIB PKG_CONFIG - - local mycmakeargs=( - -DBUILD_TESTS=False - -DENABLE_CCACHE=False - -DENABLE_LTO=$(if tc-is-lto; then echo True; else echo False; fi) - -DBUILD_FEXCONFIG=$(usex fexconfig) - -DBUILD_THUNKS=$(usex thunks) - -DX86_CFLAGS="${X86_CFLAGS}" - -DX86_CXXFLAGS="${X86_CXXFLAGS}" - -DX86_LDFLAGS="${X86_LDFLAGS}" - ) - cmake_src_configure -} - -src_install() { - cmake_src_install - tc-is-lto && dostrip -x /usr/lib/libFEXCore.a - use thunks && dostrip -x /usr/share/fex-emu/GuestThunks{,_32}/ - rm "${ED}/usr/share/man/man1/FEX.1.gz" || die - PATH="${oldpath}" -} - -pkg_postinst() { - if [[ "$(getconf PAGESIZE)" -ne 4096 ]] && ! type -P "${EPREFIX}/usr/bin/muvm" >/dev/null ; then - ewarn "Your system page size is not 4096 and as such" - ewarn "you need to install app-emulation/muvm or a similar solution" - ewarn "for FEX to work on your machine." - fi -} diff --git a/app-emulation/FEX/FEX-2412-r1.ebuild b/app-emulation/FEX/FEX-2412-r1.ebuild deleted file mode 100644 index 0f96b3d..0000000 --- a/app-emulation/FEX/FEX-2412-r1.ebuild +++ /dev/null @@ -1,326 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -LLVM_COMPAT=( 18 19 ) -LLVM_OPTIONAL=1 - -inherit flag-o-matic cmake toolchain-funcs llvm-r1 - -DESCRIPTION="A fast usermode x86 and x86-64 emulator for Arm64 Linux" -HOMEPAGE="https://fex-emu.com" - -JEMALLOC_HASH="02ca52b5fefc0ccd0d2c4eaa1d17989cdd641927" -JEMALLOC_GLIBC_HASH="404353974e335fb771562249163e2ea62c558e7e" -CPP_OPTPARSE_HASH="eab4212ae864ba64306f0fe87f102e66cb5a3617" -ROBIN_MAP_HASH="d5683d9f1891e5b04e3e3b2192b5349dc8d814ea" - -# This need to be vendored since thunk generator does not support the latest version -VULKAN_HEADERS_HASH="29f979ee5aa58b7b005f805ea8df7a855c39ff37" - -SRC_URI=" - https://github.com/FEX-Emu/jemalloc/archive/${JEMALLOC_HASH}.tar.gz -> jemalloc-${JEMALLOC_HASH}.tar.gz - https://github.com/FEX-Emu/jemalloc/archive/${JEMALLOC_GLIBC_HASH}.tar.gz -> jemalloc-glibc-${JEMALLOC_GLIBC_HASH}.tar.gz - https://github.com/Sonicadvance1/cpp-optparse/archive/${CPP_OPTPARSE_HASH}.tar.gz -> cpp-optparse-${CPP_OPTPARSE_HASH}.tar.gz - https://github.com/FEX-Emu/robin-map/archive/${ROBIN_MAP_HASH}.tar.gz -> robin-map-${ROBIN_MAP_HASH}.tar.gz - thunks? ( - https://github.com/KhronosGroup/Vulkan-Headers/archive/${VULKAN_HEADERS_HASH}.tar.gz -> Vulkan-Headers-${VULKAN_HEADERS_HASH}.tar.gz - ) - https://github.com/FEX-Emu/${PN}/archive/refs/tags/${P}.tar.gz -" - -S="${WORKDIR}/${PN}-${P}" - -LICENSE="MIT" -SLOT="0" -KEYWORDS="-* ~arm64" -BDEPEND=" - sys-devel/clang - sys-devel/llvm - thunks? ( - !crossdev-toolchain? ( - sys-devel/x86_64-multilib-toolchain - ) - $(llvm_gen_dep ' - sys-devel/clang:${LLVM_SLOT}= - sys-devel/llvm:${LLVM_SLOT}= - ') - ) -" -RDEPEND=" - dev-libs/xxhash - >=dev-libs/libfmt-11.0.2 - qt5? ( - dev-qt/qtcore:5 - dev-qt/qtgui:5[wayland(-),X(-)] - dev-qt/qtwidgets[X] - ) - qt6? ( - dev-qt/qtbase:6[gui,wayland(-),widgets,X(-)] - dev-qt/qtdeclarative:6 - ) - thunks? ( - x11-libs/libX11 - x11-libs/libdrm - dev-libs/wayland - media-libs/alsa-lib - media-libs/libglvnd - x11-libs/libxcb - ) - app-emulation/fex-rootfs-gentoo - app-emulation/fex-rootfs-mesa-asahi -" -DEPEND=" - >=sys-kernel/linux-headers-6.8 - ${RDEPEND} -" - -PATCHES=" - ${FILESDIR}/${P}-unvendor-drm-headers.patch - ${FILESDIR}/${P}-tiny-json-as-static.patch - ${FILESDIR}/${PN}-thunks-toolchain-paths.patch - ${FILESDIR}/${PN}-thunkgen-gcc-install-dir.patch - ${FILESDIR}/${P}-llvm19-support.patch - ${FILESDIR}/${P}-revert-pause-inst-changes.patch -" - -IUSE="crossdev-toolchain fexconfig qt5 qt6 +thunks" - -REQUIRED_USE=" - crossdev-toolchain? ( thunks ) - fexconfig? ( ^^ ( qt5 qt6 ) ) - thunks? ( ${LLVM_REQUIRED_USE} ) -" - -my-test-flag-PROG() { - local comp=$1 - local lang=$2 - shift 2 - - if [[ -z $1 ]]; then - return 1 - fi - - if ! type -p ${comp[0]} >/dev/null; then - return 1 - fi - - local in_src in_ext cmdline_extra=() - case "${lang}" in - c) - in_ext='c' - in_src='int main(void) { return 0; }' - cmdline_extra+=(-xc -c) - ;; - c++) - in_ext='cc' - in_src='int main(void) { return 0; }' - cmdline_extra+=(-xc++ -c) - ;; - esac - local test_in=${T}/test-flag.${in_ext} - local test_out=${T}/test-flag.exe - - printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'" - local cmdline=( - "${comp[@]}" - -Werror - "$@" - "${cmdline_extra[@]}" - "${test_in}" -o "${test_out}" - ) - - "${cmdline[@]}" &>/dev/null -} - -my-test-flags-PROG() { - local comp=$1 - local lang=$2 - local flags=() - local x - - shift 2 - - while (( $# )); do - case "$1" in - --param|-B) - if my-test-flag-PROG ${comp} ${lang} "$1" "$2"; then - flags+=( "$1" "$2" ) - fi - shift 2 - ;; - *) - if my-test-flag-PROG ${comp} ${lang} "$1"; then - flags+=( "$1" ) - fi - shift 1 - ;; - esac - done - - echo "${flags[*]}" - [[ ${#flags[@]} -gt 0 ]] -} - -my-filter-var() { - local f x var=$1 new=() - shift - - for f in ${!var} ; do - for x in "$@" ; do - [[ ${f} == ${x} ]] && continue 2 - done - new+=( "${f}" ) - done - export ${var}="${new[*]}" -} - -THUNK_INC_DIR="${WORKDIR}/thunk-include" - -find_compiler() { - ( - pattern="$1" - shift - shopt -s nullglob - IFS=: read -r -a paths <<<"$PATH" - for dir in "${paths[@]}"; do - for cand in "$dir"/$pattern; do - "${cand}" -o /dev/null -x c "$@" - 2>/dev/null >/dev/null <<<'int main(){}' && echo "${cand#/${dir}}" && return 0 - done - done - return 1 - ) -} - -pkg_setup() { - use thunks && llvm-r1_pkg_setup -} - -pkg_pretend() { - [[ ${MERGE_TYPE} == binary ]] && return - use thunks || return - use crossdev-toolchain || return - errmsg="Unable to find a working ARCH compiler on your system. You need to install one using crossdev." - find_compiler 'x86_64*-linux-gnu-gcc' >/dev/null || die "${errmsg/ARCH/x86_64}" - find_compiler 'i?86*-linux-gnu-gcc' >/dev/null || find_compiler 'x86_64*-linux-gnu-gcc' -m32 >/dev/null || die "${errmsg/ARCH/i686}" -} - -src_unpack() { - default - local -A deps=( - jemalloc "jemalloc-${JEMALLOC_HASH}" - jemalloc_glibc "jemalloc-${JEMALLOC_GLIBC_HASH}" - robin-map "robin-map-${ROBIN_MAP_HASH}" - ) - use thunks && deps[Vulkan-Headers]="Vulkan-Headers-${VULKAN_HEADERS_HASH}" - for dep in "${!deps[@]}"; do - rmdir "${S}/External/${dep}" || die - mv "${WORKDIR}/${deps[${dep}]}" "${S}/External/${dep}" - done - rmdir "${S}/Source/Common/cpp-optparse" || die - mv "${WORKDIR}/cpp-optparse-${CPP_OPTPARSE_HASH}" "${S}/Source/Common/cpp-optparse" || die -} - -THUNK_HEADERS=" - GL - EGL - GLES - GLES2 - GLES3 - KHR - glvnd - wayland-client-core.h - wayland-client-protocol.h - wayland-client.h - wayland-cursor.h - wayland-egl-backend.h - wayland-egl-core.h - wayland-egl.h - wayland-server-core.h - wayland-server-protocol.h - wayland-server.h - wayland-util.h - wayland-version.h - X11 - libdrm - libsync.h - xf86drm.h - xf86drmMode.h - alsa - xcb -" - -src_prepare() { - cmake_src_prepare - sed -i -e "s:__REPLACE_ME_WITH_HEADER_DIR__:${THUNK_INC_DIR}:" ThunkLibs/GuestLibs/CMakeLists.txt || die - mkdir "${THUNK_INC_DIR}" || die - for header in $THUNK_HEADERS; do - cp -a "${BROOT}/usr/include/${header}" "${THUNK_INC_DIR}/${header}" || die - done -} - -src_configure() { - if ! tc-is-clang ; then - AR=llvm-ar - CC=clang - CXX=clang++ - NM=llvm-nm - RANLIB=llvm-ranlib - STRIP=llvm-strip - - strip-unsupported-flags - fi - oldpath="${PATH}" - use crossdev-toolchain || PATH="${BROOT}/usr/lib/x86_64-multilib-toolchain/bin:${PATH}" - - local x64_cc="$(find_compiler 'x86_64*-linux-gnu-gcc' || die)" - local x86_cc - if x86_cc="$(find_compiler 'x86_64*-linux-gnu-gcc' -m32)"; then - x86_cc="${x86_cc} -m32" - else - x86_cc="$(find_compiler 'i?86*-linux-gnu-gcc' || die)" - fi - - sed -i -e "s:__REPLACE_ME_WITH_C_COMPILER__:${x64_cc}:" toolchain_x86_64.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_C_COMPILER__:${x86_cc}:" toolchain_x86_32.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_CXX_COMPILER__:${x64_cc/linux-gnu-gcc/linux-gnu-g++}:" toolchain_x86_64.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_CXX_COMPILER__:${x86_cc/linux-gnu-gcc/linux-gnu-g++}:" toolchain_x86_32.cmake || die - - export X86_CFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/cc} c ${CFLAGS} ${LDFLAGS})" - export X86_CXXFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/c++} c++ ${CXXFLAGS} ${LDFLAGS})" - export X86_LDFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/cc} c ${LDFLAGS})" - - my-filter-var X86_CFLAGS '-flto*' -fwhole-program-vtables '-fsanitize=cfi*' - my-filter-var X86_CXXFLAGS '-flto*' -fwhole-program-vtables '-fsanitize=cfi*' - - tc-export CC CXX LD AR NM OBJDUMP RANLIB PKG_CONFIG - - local mycmakeargs=( - -DBUILD_TESTS=False - -DENABLE_CCACHE=False - -DENABLE_LTO=$(if tc-is-lto; then echo True; else echo False; fi) - -DBUILD_FEXCONFIG=$(usex fexconfig) - -DBUILD_THUNKS=$(usex thunks) - -DX86_CFLAGS="${X86_CFLAGS}" - -DX86_CXXFLAGS="${X86_CXXFLAGS}" - -DX86_LDFLAGS="${X86_LDFLAGS}" - ) - cmake_src_configure -} - -src_install() { - cmake_src_install - tc-is-lto && dostrip -x /usr/lib/libFEXCore.a - use thunks && dostrip -x /usr/share/fex-emu/GuestThunks{,_32}/ - rm "${ED}/usr/share/man/man1/FEX.1.gz" || die - PATH="${oldpath}" -} - -pkg_postinst() { - if [[ "$(getconf PAGESIZE)" -ne 4096 ]] && ! type -P "${EPREFIX}/usr/bin/muvm" >/dev/null ; then - ewarn "Your system page size is not 4096 and as such" - ewarn "you need to install app-emulation/muvm or a similar solution" - ewarn "for FEX to work on your machine." - fi -} diff --git a/app-emulation/FEX/FEX-2412.ebuild b/app-emulation/FEX/FEX-2412.ebuild deleted file mode 100644 index 2a49543..0000000 --- a/app-emulation/FEX/FEX-2412.ebuild +++ /dev/null @@ -1,325 +0,0 @@ -# Copyright 1999-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 - -LLVM_COMPAT=( 18 19 ) -LLVM_OPTIONAL=1 - -inherit flag-o-matic cmake toolchain-funcs llvm-r1 - -DESCRIPTION="A fast usermode x86 and x86-64 emulator for Arm64 Linux" -HOMEPAGE="https://fex-emu.com" - -JEMALLOC_HASH="02ca52b5fefc0ccd0d2c4eaa1d17989cdd641927" -JEMALLOC_GLIBC_HASH="404353974e335fb771562249163e2ea62c558e7e" -CPP_OPTPARSE_HASH="eab4212ae864ba64306f0fe87f102e66cb5a3617" -ROBIN_MAP_HASH="d5683d9f1891e5b04e3e3b2192b5349dc8d814ea" - -# This need to be vendored since thunk generator does not support the latest version -VULKAN_HEADERS_HASH="29f979ee5aa58b7b005f805ea8df7a855c39ff37" - -SRC_URI=" - https://github.com/FEX-Emu/jemalloc/archive/${JEMALLOC_HASH}.tar.gz -> jemalloc-${JEMALLOC_HASH}.tar.gz - https://github.com/FEX-Emu/jemalloc/archive/${JEMALLOC_GLIBC_HASH}.tar.gz -> jemalloc-glibc-${JEMALLOC_GLIBC_HASH}.tar.gz - https://github.com/Sonicadvance1/cpp-optparse/archive/${CPP_OPTPARSE_HASH}.tar.gz -> cpp-optparse-${CPP_OPTPARSE_HASH}.tar.gz - https://github.com/FEX-Emu/robin-map/archive/${ROBIN_MAP_HASH}.tar.gz -> robin-map-${ROBIN_MAP_HASH}.tar.gz - thunks? ( - https://github.com/KhronosGroup/Vulkan-Headers/archive/${VULKAN_HEADERS_HASH}.tar.gz -> Vulkan-Headers-${VULKAN_HEADERS_HASH}.tar.gz - ) - https://github.com/FEX-Emu/${PN}/archive/refs/tags/${P}.tar.gz -" - -S="${WORKDIR}/${PN}-${P}" - -LICENSE="MIT" -SLOT="0" -KEYWORDS="-* ~arm64" -BDEPEND=" - sys-devel/clang - sys-devel/llvm - thunks? ( - !crossdev-toolchain? ( - sys-devel/x86_64-multilib-toolchain - ) - $(llvm_gen_dep ' - sys-devel/clang:${LLVM_SLOT}= - sys-devel/llvm:${LLVM_SLOT}= - ') - ) -" -RDEPEND=" - dev-libs/xxhash - >=dev-libs/libfmt-11.0.2 - qt5? ( - dev-qt/qtcore:5 - dev-qt/qtgui:5[wayland(-),X(-)] - dev-qt/qtwidgets[X] - ) - qt6? ( - dev-qt/qtbase:6[gui,wayland(-),widgets,X(-)] - dev-qt/qtdeclarative:6 - ) - thunks? ( - x11-libs/libX11 - x11-libs/libdrm - dev-libs/wayland - media-libs/alsa-lib - media-libs/libglvnd - x11-libs/libxcb - ) - app-emulation/fex-rootfs-gentoo - app-emulation/fex-rootfs-mesa-asahi -" -DEPEND=" - >=sys-kernel/linux-headers-6.8 - ${RDEPEND} -" - -PATCHES=" - ${FILESDIR}/${P}-unvendor-drm-headers.patch - ${FILESDIR}/${P}-tiny-json-as-static.patch - ${FILESDIR}/${PN}-thunks-toolchain-paths.patch - ${FILESDIR}/${PN}-thunkgen-gcc-install-dir.patch - ${FILESDIR}/${P}-llvm19-support.patch -" - -IUSE="crossdev-toolchain fexconfig qt5 qt6 +thunks" - -REQUIRED_USE=" - crossdev-toolchain? ( thunks ) - fexconfig? ( ^^ ( qt5 qt6 ) ) - thunks? ( ${LLVM_REQUIRED_USE} ) -" - -my-test-flag-PROG() { - local comp=$1 - local lang=$2 - shift 2 - - if [[ -z $1 ]]; then - return 1 - fi - - if ! type -p ${comp[0]} >/dev/null; then - return 1 - fi - - local in_src in_ext cmdline_extra=() - case "${lang}" in - c) - in_ext='c' - in_src='int main(void) { return 0; }' - cmdline_extra+=(-xc -c) - ;; - c++) - in_ext='cc' - in_src='int main(void) { return 0; }' - cmdline_extra+=(-xc++ -c) - ;; - esac - local test_in=${T}/test-flag.${in_ext} - local test_out=${T}/test-flag.exe - - printf "%s\n" "${in_src}" > "${test_in}" || die "Failed to create '${test_in}'" - local cmdline=( - "${comp[@]}" - -Werror - "$@" - "${cmdline_extra[@]}" - "${test_in}" -o "${test_out}" - ) - - "${cmdline[@]}" &>/dev/null -} - -my-test-flags-PROG() { - local comp=$1 - local lang=$2 - local flags=() - local x - - shift 2 - - while (( $# )); do - case "$1" in - --param|-B) - if my-test-flag-PROG ${comp} ${lang} "$1" "$2"; then - flags+=( "$1" "$2" ) - fi - shift 2 - ;; - *) - if my-test-flag-PROG ${comp} ${lang} "$1"; then - flags+=( "$1" ) - fi - shift 1 - ;; - esac - done - - echo "${flags[*]}" - [[ ${#flags[@]} -gt 0 ]] -} - -my-filter-var() { - local f x var=$1 new=() - shift - - for f in ${!var} ; do - for x in "$@" ; do - [[ ${f} == ${x} ]] && continue 2 - done - new+=( "${f}" ) - done - export ${var}="${new[*]}" -} - -THUNK_INC_DIR="${WORKDIR}/thunk-include" - -find_compiler() { - ( - pattern="$1" - shift - shopt -s nullglob - IFS=: read -r -a paths <<<"$PATH" - for dir in "${paths[@]}"; do - for cand in "$dir"/$pattern; do - "${cand}" -o /dev/null -x c "$@" - 2>/dev/null >/dev/null <<<'int main(){}' && echo "${cand#/${dir}}" && return 0 - done - done - return 1 - ) -} - -pkg_setup() { - use thunks && llvm-r1_pkg_setup -} - -pkg_pretend() { - [[ ${MERGE_TYPE} == binary ]] && return - use thunks || return - use crossdev-toolchain || return - errmsg="Unable to find a working ARCH compiler on your system. You need to install one using crossdev." - find_compiler 'x86_64*-linux-gnu-gcc' >/dev/null || die "${errmsg/ARCH/x86_64}" - find_compiler 'i?86*-linux-gnu-gcc' >/dev/null || find_compiler 'x86_64*-linux-gnu-gcc' -m32 >/dev/null || die "${errmsg/ARCH/i686}" -} - -src_unpack() { - default - local -A deps=( - jemalloc "jemalloc-${JEMALLOC_HASH}" - jemalloc_glibc "jemalloc-${JEMALLOC_GLIBC_HASH}" - robin-map "robin-map-${ROBIN_MAP_HASH}" - ) - use thunks && deps[Vulkan-Headers]="Vulkan-Headers-${VULKAN_HEADERS_HASH}" - for dep in "${!deps[@]}"; do - rmdir "${S}/External/${dep}" || die - mv "${WORKDIR}/${deps[${dep}]}" "${S}/External/${dep}" - done - rmdir "${S}/Source/Common/cpp-optparse" || die - mv "${WORKDIR}/cpp-optparse-${CPP_OPTPARSE_HASH}" "${S}/Source/Common/cpp-optparse" || die -} - -THUNK_HEADERS=" - GL - EGL - GLES - GLES2 - GLES3 - KHR - glvnd - wayland-client-core.h - wayland-client-protocol.h - wayland-client.h - wayland-cursor.h - wayland-egl-backend.h - wayland-egl-core.h - wayland-egl.h - wayland-server-core.h - wayland-server-protocol.h - wayland-server.h - wayland-util.h - wayland-version.h - X11 - libdrm - libsync.h - xf86drm.h - xf86drmMode.h - alsa - xcb -" - -src_prepare() { - cmake_src_prepare - sed -i -e "s:__REPLACE_ME_WITH_HEADER_DIR__:${THUNK_INC_DIR}:" ThunkLibs/GuestLibs/CMakeLists.txt || die - mkdir "${THUNK_INC_DIR}" || die - for header in $THUNK_HEADERS; do - cp -a "${BROOT}/usr/include/${header}" "${THUNK_INC_DIR}/${header}" || die - done -} - -src_configure() { - if ! tc-is-clang ; then - AR=llvm-ar - CC=clang - CXX=clang++ - NM=llvm-nm - RANLIB=llvm-ranlib - STRIP=llvm-strip - - strip-unsupported-flags - fi - oldpath="${PATH}" - use crossdev-toolchain || PATH="${BROOT}/usr/lib/x86_64-multilib-toolchain/bin:${PATH}" - - local x64_cc="$(find_compiler 'x86_64*-linux-gnu-gcc' || die)" - local x86_cc - if x86_cc="$(find_compiler 'x86_64*-linux-gnu-gcc' -m32)"; then - x86_cc="${x86_cc} -m32" - else - x86_cc="$(find_compiler 'i?86*-linux-gnu-gcc' || die)" - fi - - sed -i -e "s:__REPLACE_ME_WITH_C_COMPILER__:${x64_cc}:" toolchain_x86_64.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_C_COMPILER__:${x86_cc}:" toolchain_x86_32.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_CXX_COMPILER__:${x64_cc/linux-gnu-gcc/linux-gnu-g++}:" toolchain_x86_64.cmake || die - sed -i -e "s:__REPLACE_ME_WITH_CXX_COMPILER__:${x86_cc/linux-gnu-gcc/linux-gnu-g++}:" toolchain_x86_32.cmake || die - - export X86_CFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/cc} c ${CFLAGS} ${LDFLAGS})" - export X86_CXXFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/c++} c++ ${CXXFLAGS} ${LDFLAGS})" - export X86_LDFLAGS="$(my-test-flags-PROG ${x64_cc/%gcc/cc} c ${LDFLAGS})" - - my-filter-var X86_CFLAGS '-flto*' -fwhole-program-vtables '-fsanitize=cfi*' - my-filter-var X86_CXXFLAGS '-flto*' -fwhole-program-vtables '-fsanitize=cfi*' - - tc-export CC CXX LD AR NM OBJDUMP RANLIB PKG_CONFIG - - local mycmakeargs=( - -DBUILD_TESTS=False - -DENABLE_CCACHE=False - -DENABLE_LTO=$(if tc-is-lto; then echo True; else echo False; fi) - -DBUILD_FEXCONFIG=$(usex fexconfig) - -DBUILD_THUNKS=$(usex thunks) - -DX86_CFLAGS="${X86_CFLAGS}" - -DX86_CXXFLAGS="${X86_CXXFLAGS}" - -DX86_LDFLAGS="${X86_LDFLAGS}" - ) - cmake_src_configure -} - -src_install() { - cmake_src_install - tc-is-lto && dostrip -x /usr/lib/libFEXCore.a - use thunks && dostrip -x /usr/share/fex-emu/GuestThunks{,_32}/ - rm "${ED}/usr/share/man/man1/FEX.1.gz" || die - PATH="${oldpath}" -} - -pkg_postinst() { - if [[ "$(getconf PAGESIZE)" -ne 4096 ]] && ! type -P "${EPREFIX}/usr/bin/muvm" >/dev/null ; then - ewarn "Your system page size is not 4096 and as such" - ewarn "you need to install app-emulation/muvm or a similar solution" - ewarn "for FEX to work on your machine." - fi -} diff --git a/app-emulation/FEX/Manifest b/app-emulation/FEX/Manifest index 0fcaa59..3be70ba 100644 --- a/app-emulation/FEX/Manifest +++ b/app-emulation/FEX/Manifest @@ -1,8 +1,6 @@ -DIST FEX-2410.tar.gz 2065522 BLAKE2B 8e4e32f6777dff592172d2e45e82bf9456f10bb1e2f18a189cab50f0d97c63891b420fc53bc9d2785b77d50dc859bd7e90e3dcf698c23772be72c11fda631cf6 SHA512 df4b85b03acb6246295c912b87f9b7a8998033f6daaaea0ef463cfff52de914c680ea27da4b97e294fc97565f39c95763015568d150917050f8e62f7a4537d74 DIST FEX-2412.tar.gz 2074906 BLAKE2B 8dd3e2500a1f383036b42f2ebe36b72d8ca068652abd8eeac1a6a83ebba3601abe822ce0005243c9044d710c56478b5de9295a95c9192d1c35063173cbd6d75b SHA512 ecd2eabbcdb78f872b2dcc593bf83effebb3464074494284cc97e205c74ee934dcefeeb2745f61a85bd98d04cb00f1bf318b9149502b297a3e1f92d63499b3f9 DIST Vulkan-Headers-29f979ee5aa58b7b005f805ea8df7a855c39ff37.tar.gz 2359246 BLAKE2B 4208b0837789cb26bcb5309d8f1f56aa58dca2f06f61557b6624aa9e63566e62b1e544da33050a48489e58c3e71022ff58dd10ebca00008105c8a909cc07a44c SHA512 15618de42ee2bc019053f00e51afdf37dbdedc1ce6ec18e806e169ba002ac7720c8b3c75e57adb01e56d2c0f5888ddf6418f688bcb666859549befdfa3beb8b5 DIST cpp-optparse-eab4212ae864ba64306f0fe87f102e66cb5a3617.tar.gz 13162 BLAKE2B a1baf212e684d355e312b867c9c046d3b9946a71b0ed1c6a6322f6eb16bdb88f9ffb1f2201baf5ff06ddb0068bab42f2b8cbff9d3e79103e4148b7b100d0593e SHA512 12bb88cc26642b8951cb9cdd7c02e2690303da021d781ad49f41d5cc222eeb3cad955023cbe132d70be155962bad045d071c0af804ec515d8890026c344f23a9 DIST jemalloc-02ca52b5fefc0ccd0d2c4eaa1d17989cdd641927.tar.gz 847982 BLAKE2B 7676066b106af133bb7dab4518aa63fe10341cf86175f8ed664b4850f240535c2107698876e9406a0f36e312f89cdb6785393e3883c212fd9cba3031047814ce SHA512 b15e1fdcff9f593dbaca88337a2ab784cb66491ef8794f72fbf67617c1f396c57ba1664deb53fa18e5c21a4bd777809ae4c03b1ce48f6e80ccabbcbd7668651d DIST jemalloc-glibc-404353974e335fb771562249163e2ea62c558e7e.tar.gz 825252 BLAKE2B deec3bbccbe898af2875e184c2fd350ebaa082b241f32f2f14eafe9cab00e531ee21d7a505845f85fb476b12f5299ce030a7074598603a238b0e3619b875ba49 SHA512 9902c1c8be69a09eeaa55e163216ca3c4b4eb12767c62032f07249cd7de1770f74364c309656a94a64afeaf25901042d8cab6bc5b706f35566c503b1750bbffd -DIST libfmt-11.0.2.tar.gz 700956 BLAKE2B c1f7998e68770bbb93ab7211a18b4930727699b340b2f2e15dedc83e55ff02400cfd363abaec1bf63a0165f8c21cc515a4aa23c4f3bc2e65b6fbc041781f0379 SHA512 47ff6d289dcc22681eea6da465b0348172921e7cafff8fd57a1540d3232cc6b53250a4625c954ee0944c87963b17680ecbc3ea123e43c2c822efe0dc6fa6cef3 DIST robin-map-d5683d9f1891e5b04e3e3b2192b5349dc8d814ea.tar.gz 70652 BLAKE2B 03ca6c6c333661ece0ac818d43eee37ead3e0a0acb71c45df201bff30715db89b8f2be3f5bac0991379327f2fac4273ba1bd3d6c4102e5a472a7c7567fae4651 SHA512 23fe18c7d2dda9bc4216201a7e5935c8dc9f51066173e95d514360e3310c994c4dc7786a33f43cb7d15dcceb913375a48b8c02529eacde58c0a80f0e91e9b94d diff --git a/app-emulation/FEX/files/FEX-2410-align-stack-base.patch b/app-emulation/FEX/files/FEX-2410-align-stack-base.patch deleted file mode 100644 index 22b0166..0000000 --- a/app-emulation/FEX/files/FEX-2410-align-stack-base.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 4a67893f1d36fc2611a63eaac30eea3b9e69213d Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Wed, 13 Nov 2024 03:47:03 +0900 -Subject: [PATCH] FEXLoader: Align stack base - -This ensures that __libc_stack_end is aligned, the same way it is on -native. ---- - Source/Tools/FEXLoader/ELFCodeLoader.h | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/Source/Tools/FEXLoader/ELFCodeLoader.h b/Source/Tools/FEXLoader/ELFCodeLoader.h -index 8e24f75b83..733be0317f 100644 ---- a/Source/Tools/FEXLoader/ELFCodeLoader.h -+++ b/Source/Tools/FEXLoader/ELFCodeLoader.h -@@ -725,6 +725,9 @@ class ELFCodeLoader final : public FEX::CodeLoader { - uint64_t ExecFNLocation = TotalArgumentMemSize; - TotalArgumentMemSize += Args[0].size() + 1; - -+ // Align the argument block to 16 bytes to keep the stack aligned -+ TotalArgumentMemSize = FEXCore::AlignUp(TotalArgumentMemSize, 16); -+ - // Offset the stack by how much memory we need - StackPointer -= TotalArgumentMemSize; - diff --git a/app-emulation/FEX/files/FEX-2410-clone-fork-semantics.patch b/app-emulation/FEX/files/FEX-2410-clone-fork-semantics.patch deleted file mode 100644 index 08c1e8e..0000000 --- a/app-emulation/FEX/files/FEX-2410-clone-fork-semantics.patch +++ /dev/null @@ -1,72 +0,0 @@ -From bfed21870fff0be99327f21c0a4cb1c68861d999 Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Tue, 12 Nov 2024 22:16:58 +0900 -Subject: [PATCH] Support CLONE_FS and CLONE_FILES with fork() semantics - -Needed by Discord, part of the Chromium sandbox code. The warning still -triggers because Chromium asks for CLONE_VM on x86_64, but that can be -safely ignored (CLONE_FS is the one that matters). ---- - .../LinuxEmulation/LinuxSyscalls/Syscalls.cpp | 2 +- - .../LinuxSyscalls/Syscalls/Thread.cpp | 14 ++++++++++++-- - 2 files changed, 13 insertions(+), 3 deletions(-) - -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp -index 9541471059..bcb92096a7 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp -@@ -583,7 +583,7 @@ uint64_t CloneHandler(FEXCore::Core::CpuStateFrame* Frame, FEX::HLE::clone3_args - return false; - } - } else { -- if (AnyFlagsSet(args->args.flags, CLONE_SYSVSEM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_VM)) { -+ if (AnyFlagsSet(args->args.flags, CLONE_SYSVSEM | CLONE_SIGHAND | CLONE_VM)) { - // CLONE_VM is particularly nasty here - // Memory regions at the point of clone(More similar to a fork) are shared - LogMan::Msg::IFmt("clone: Unsupported flags w/o CLONE_THREAD (Shared Resources), {:X}", args->args.flags); -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp -index 0a1178019b..7f2313b03e 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Thread.cpp -@@ -26,6 +26,7 @@ tags: LinuxSyscalls|syscalls-shared - #include - #include - #include -+#include - #include - #include - #include -@@ -228,6 +229,15 @@ uint64_t HandleNewClone(FEX::HLE::ThreadStateObject* Thread, FEXCore::Context::C - return Thread->Thread->StatusCode; - } - -+static int Clone3Fork(uint32_t flags) { -+ struct clone_args cl_args = { -+ .flags = (flags & (CLONE_FS | CLONE_FILES)), -+ .exit_signal = SIGCHLD, -+ }; -+ -+ return syscall(SYS_clone3, cl_args, sizeof(cl_args)); -+} -+ - uint64_t ForkGuest(FEXCore::Core::InternalThreadState* Thread, FEXCore::Core::CpuStateFrame* Frame, uint32_t flags, void* stack, - size_t StackSize, pid_t* parent_tid, pid_t* child_tid, void* tls) { - // Just before we fork, we lock all syscall mutexes so that both processes will end up with a locked mutex -@@ -248,7 +258,7 @@ uint64_t ForkGuest(FEXCore::Core::InternalThreadState* Thread, FEXCore::Core::Cp - - // XXX: We don't currently support a real `vfork` as it causes problems. - // Currently behaves like a fork (with wait after the fact), which isn't correct. Need to find where the problem is -- Result = fork(); -+ Result = Clone3Fork(flags); - - if (Result == 0) { - // Close the read end of the pipe. -@@ -259,7 +269,7 @@ uint64_t ForkGuest(FEXCore::Core::InternalThreadState* Thread, FEXCore::Core::Cp - close(VForkFDs[1]); - } - } else { -- Result = fork(); -+ Result = Clone3Fork(flags); - } - const bool IsChild = Result == 0; - diff --git a/app-emulation/FEX/files/FEX-2410-fmt-as-static.patch b/app-emulation/FEX/files/FEX-2410-fmt-as-static.patch deleted file mode 100644 index e9c9abc..0000000 --- a/app-emulation/FEX/files/FEX-2410-fmt-as-static.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/External/fmt/CMakeLists.txt b/External/fmt/CMakeLists.txt -index e3b35110..58ada4da 100644 ---- a/External/fmt/CMakeLists.txt -+++ b/External/fmt/CMakeLists.txt -@@ -1,5 +1,7 @@ - cmake_minimum_required(VERSION 3.8...3.28) - -+set(BUILD_SHARED_LIBS OFF) -+ - # Fallback for using newer policies on CMake <3.12. - if (${CMAKE_VERSION} VERSION_LESS 3.12) - cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) diff --git a/app-emulation/FEX/files/FEX-2410-hide-rootfs-fd-2.patch b/app-emulation/FEX/files/FEX-2410-hide-rootfs-fd-2.patch deleted file mode 100644 index 987abda..0000000 --- a/app-emulation/FEX/files/FEX-2410-hide-rootfs-fd-2.patch +++ /dev/null @@ -1,107 +0,0 @@ -From 73ffaa1e18e80c6ee0bbd38b3f3e6baebff4b60a Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Wed, 13 Nov 2024 01:22:42 +0900 -Subject: [PATCH] FileManagement: Hide the FEX RootFS fd from /proc/self/fd - take 2 - -Apparently Chromium/CEF can chroot or otherwise sandbox the filesystem -away before forking and checking for directory FDs, making /proc -inaccessible, which means we can't stat it for our inode check, breaking -the hiding. - -So, double down on things and do what Chromium does: open an fd to /proc -ahead of time, so that continues to work. Then we use it to update the -inode of our RootFS fd instead, and finally, also do the /proc fd itself -to hide that one too. - -We also don't need to check the st_dev of /proc more than once, since -that's not expected to change anyway. - -Fixes cefsimple. ---- - .../LinuxSyscalls/FileManagement.cpp | 33 +++++++++++++++---- - .../LinuxSyscalls/FileManagement.h | 2 ++ - 2 files changed, 28 insertions(+), 7 deletions(-) - -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp -index e71d3e049c..d4ccaa5a4a 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp -@@ -322,6 +322,16 @@ FileManager::FileManager(FEXCore::Context::Context* ctx) - } - } - -+ // Keep an fd open for /proc, to bypass chroot-style sandboxes -+ ProcFD = open("/proc", O_RDONLY | O_CLOEXEC); -+ -+ // Track the st_dev of /proc, to check for inode equality -+ struct stat Buffer; -+ auto Result = fstat(ProcFD, &Buffer); -+ if (Result >= 0) { -+ ProcFSDev = Buffer.st_dev; -+ } -+ - UpdatePID(::getpid()); - } - -@@ -998,30 +1008,39 @@ void FileManager::UpdatePID(uint32_t PID) { - CurrentPID = PID; - - // Track the inode of /proc/self/fd/, to be able to hide it -- auto FDpath = fextl::fmt::format("/proc/self/fd/{}", RootFSFD); -+ auto FDpath = fextl::fmt::format("self/fd/{}", RootFSFD); - struct stat Buffer {}; -- int Result = fstatat(AT_FDCWD, FDpath.c_str(), &Buffer, AT_SYMLINK_NOFOLLOW); -+ int Result = fstatat(ProcFD, FDpath.c_str(), &Buffer, AT_SYMLINK_NOFOLLOW); - if (Result >= 0) { - RootFSFDInode = Buffer.st_ino; -+ } else { -+ // Probably in a strict sandbox -+ RootFSFDInode = 0; -+ ProcFDInode = 0; -+ return; - } - -- // Track the st_dev of /proc, to check for inode equality -- Result = stat("/proc/self", &Buffer); -+ // And track the ProcFSFD itself -+ FDpath = fextl::fmt::format("self/fd/{}", ProcFD); -+ Result = fstatat(ProcFD, FDpath.c_str(), &Buffer, AT_SYMLINK_NOFOLLOW); - if (Result >= 0) { -- ProcFSDev = Buffer.st_dev; -+ ProcFDInode = Buffer.st_ino; -+ } else { -+ // ?? -+ ProcFDInode = 0; -+ return; - } - } - - bool FileManager::IsRootFSFD(int dirfd, uint64_t inode) { - - // Check if we have to hide this entry -- if (inode == RootFSFDInode) { -+ if (inode == RootFSFDInode || inode == ProcFDInode) { - struct stat Buffer; - if (fstat(dirfd, &Buffer) >= 0) { - if (Buffer.st_dev == ProcFSDev) { - LogMan::Msg::DFmt("Hiding directory entry for RootFSFD"); - return true; -- } else { - } - } - } -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h -index f84ef30be6..aecf9a874c 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h -@@ -161,7 +161,9 @@ class FileManager final { - FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE); - uint32_t CurrentPID {}; - int RootFSFD {AT_FDCWD}; -+ int ProcFD {0}; - int64_t RootFSFDInode = 0; -+ int64_t ProcFDInode = 0; - dev_t ProcFSDev; - }; - } // namespace FEX::HLE diff --git a/app-emulation/FEX/files/FEX-2410-hide-rootfs-fd.patch b/app-emulation/FEX/files/FEX-2410-hide-rootfs-fd.patch deleted file mode 100644 index d604259..0000000 --- a/app-emulation/FEX/files/FEX-2410-hide-rootfs-fd.patch +++ /dev/null @@ -1,167 +0,0 @@ -From 3d701f5fcf8a729246ad51f5e9e57a0d48732cd6 Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Sun, 27 Oct 2024 07:00:54 +0900 -Subject: [PATCH] FileManagement: Hide the FEX RootFS fd from /proc/self/fd - -Chromium/CEF has code that iterates through all open FDs and bails if -any are directories (apparently a sandboxing sanity check). To avoid -this check, we need to hide the RootFS FD. This requires hooking all the -getdents variants to skip that entry. - -To keep the runtime cost low, we keep track of the inode of -/proc/self/fd/ (note: not the RootFS inode, the inode of the -magic symlink in /proc), and first do a quick check on that. If it -matches, then we stat the dirfd we are reading and check against the -procfs device, to complete the inode equality check. - -As an extra benefit, this also fixes code that tries to iterate and -close all/extra FDs and ends up closing the RootFS fd. ---- - .../LinuxSyscalls/FileManagement.cpp | 34 +++++++++++++++++++ - .../LinuxSyscalls/FileManagement.h | 7 ++-- - .../LinuxEmulation/LinuxSyscalls/Syscalls.cpp | 5 +++ - .../LinuxSyscalls/Syscalls/Passthrough.cpp | 2 -- - .../LinuxEmulation/LinuxSyscalls/x32/FD.cpp | 5 +++ - .../LinuxEmulation/LinuxSyscalls/x64/FD.cpp | 17 ++++++++++ - 6 files changed, 65 insertions(+), 5 deletions(-) - -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp -index e57c281586..e71d3e049c 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp -@@ -994,4 +994,38 @@ uint64_t FileManager::LRemovexattr(const char* path, const char* name) { - return ::lremovexattr(SelfPath, name); - } - -+void FileManager::UpdatePID(uint32_t PID) { -+ CurrentPID = PID; -+ -+ // Track the inode of /proc/self/fd/, to be able to hide it -+ auto FDpath = fextl::fmt::format("/proc/self/fd/{}", RootFSFD); -+ struct stat Buffer {}; -+ int Result = fstatat(AT_FDCWD, FDpath.c_str(), &Buffer, AT_SYMLINK_NOFOLLOW); -+ if (Result >= 0) { -+ RootFSFDInode = Buffer.st_ino; -+ } -+ -+ // Track the st_dev of /proc, to check for inode equality -+ Result = stat("/proc/self", &Buffer); -+ if (Result >= 0) { -+ ProcFSDev = Buffer.st_dev; -+ } -+} -+ -+bool FileManager::IsRootFSFD(int dirfd, uint64_t inode) { -+ -+ // Check if we have to hide this entry -+ if (inode == RootFSFDInode) { -+ struct stat Buffer; -+ if (fstat(dirfd, &Buffer) >= 0) { -+ if (Buffer.st_dev == ProcFSDev) { -+ LogMan::Msg::DFmt("Hiding directory entry for RootFSFD"); -+ return true; -+ } else { -+ } -+ } -+ } -+ return false; -+} -+ - } // namespace FEX::HLE -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h -index c230aedb48..f84ef30be6 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.h -@@ -81,9 +81,8 @@ class FileManager final { - std::optional GetSelf(const char* Pathname); - bool IsSelfNoFollow(const char* Pathname, int flags) const; - -- void UpdatePID(uint32_t PID) { -- CurrentPID = PID; -- } -+ void UpdatePID(uint32_t PID); -+ bool IsRootFSFD(int dirfd, uint64_t inode); - - fextl::string GetEmulatedPath(const char* pathname, bool FollowSymlink = false); - using FDPathTmpData = std::array; -@@ -162,5 +161,7 @@ class FileManager final { - FEX_CONFIG_OPT(Is64BitMode, IS64BIT_MODE); - uint32_t CurrentPID {}; - int RootFSFD {AT_FDCWD}; -+ int64_t RootFSFDInode = 0; -+ dev_t ProcFSDev; - }; - } // namespace FEX::HLE -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp -index 01d6554256..9541471059 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls.cpp -@@ -120,6 +120,11 @@ uint64_t GetDentsEmulation(int fd, T* dirp, uint32_t count) { - Outgoing->d_name[Outgoing->d_reclen - offsetof(T, d_name) - 1] = Tmp->d_type; - - TmpOffset += Tmp->d_reclen; -+ -+ if (FEX::HLE::_SyscallHandler->FM.IsRootFSFD(fd, Outgoing->d_ino)) { -+ continue; -+ } -+ - // Outgoing is 5 bytes smaller - Offset += NewRecLen; - -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp -index d8e02c87ad..b75d09dfcd 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp -@@ -694,8 +694,6 @@ namespace x64 { - SyscallPassthrough6); - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(io_getevents, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - SyscallPassthrough5); -- REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(getdents64, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, -- SyscallPassthrough3); - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(semtimedop, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, - SyscallPassthrough4); - REGISTER_SYSCALL_IMPL_X64_PASS_FLAGS(timer_create, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY, -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp -index 9a2dfabaf1..01712da60a 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp -@@ -600,6 +600,11 @@ void RegisterFD(FEX::HLE::SyscallHandler* Handler) { - for (size_t i = 0, num = 0; i < Result; ++num) { - linux_dirent_64* Incoming = (linux_dirent_64*)(reinterpret_cast(dirp) + i); - Incoming->d_off = num; -+ if (FEX::HLE::_SyscallHandler->FM.IsRootFSFD(fd, Incoming->d_ino)) { -+ Result -= Incoming->d_reclen; -+ memmove(Incoming, (linux_dirent_64*)(reinterpret_cast(Incoming) + Incoming->d_reclen), Result - i); -+ continue; -+ } - i += Incoming->d_reclen; - } - } -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp -index e973bce1f3..ea2d78265e 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/FD.cpp -@@ -112,6 +112,23 @@ void RegisterFD(FEX::HLE::SyscallHandler* Handler) { - return GetDentsEmulation(fd, reinterpret_cast(dirp), count); - }); - -+ REGISTER_SYSCALL_IMPL_X64(getdents64, [](FEXCore::Core::CpuStateFrame* Frame, int fd, void* dirp, uint32_t count) -> uint64_t { -+ uint64_t Result = ::syscall(SYSCALL_DEF(getdents64), static_cast(fd), dirp, static_cast(count)); -+ if (Result != -1) { -+ // Check for and hide the RootFS FD -+ for (size_t i = 0; i < Result;) { -+ linux_dirent_64* Incoming = (linux_dirent_64*)(reinterpret_cast(dirp) + i); -+ if (FEX::HLE::_SyscallHandler->FM.IsRootFSFD(fd, Incoming->d_ino)) { -+ Result -= Incoming->d_reclen; -+ memmove(Incoming, (linux_dirent_64*)(reinterpret_cast(Incoming) + Incoming->d_reclen), Result - i); -+ continue; -+ } -+ i += Incoming->d_reclen; -+ } -+ } -+ SYSCALL_ERRNO(); -+ }); -+ - REGISTER_SYSCALL_IMPL_X64(dup2, [](FEXCore::Core::CpuStateFrame* Frame, int oldfd, int newfd) -> uint64_t { - uint64_t Result = ::dup2(oldfd, newfd); - SYSCALL_ERRNO(); diff --git a/app-emulation/FEX/files/FEX-2410-json-maker-as-static.patch b/app-emulation/FEX/files/FEX-2410-json-maker-as-static.patch deleted file mode 100644 index 6ecbf79..0000000 --- a/app-emulation/FEX/files/FEX-2410-json-maker-as-static.patch +++ /dev/null @@ -1,9 +0,0 @@ -diff --git a/External/json-maker/CMakeLists.txt b/External/json-maker/CMakeLists.txt -index 0e86f13..0ecc9e1 100644 ---- a/External/json-maker/CMakeLists.txt -+++ b/External/json-maker/CMakeLists.txt -@@ -1,3 +1,3 @@ - set(NAME json-maker) - set(SRCS json-maker.c) --add_library(${NAME} ${SRCS}) -+add_library(${NAME} STATIC ${SRCS}) diff --git a/app-emulation/FEX/files/FEX-2410-listen-abstract-named-sockets.patch b/app-emulation/FEX/files/FEX-2410-listen-abstract-named-sockets.patch deleted file mode 100644 index 89b23ad..0000000 --- a/app-emulation/FEX/files/FEX-2410-listen-abstract-named-sockets.patch +++ /dev/null @@ -1,337 +0,0 @@ -From 44213c396854ff6a54084ca7134f2a89b9c0b704 Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Mon, 18 Nov 2024 22:24:41 +0900 -Subject: [PATCH 1/4] FEXServerClient: Switch GetTempFolder to not use - temp_directory_path() - -Apparently this causes allocations which are banned in some paths? ---- - Source/Common/FEXServerClient.cpp | 19 +++++++++++++------ - 1 file changed, 13 insertions(+), 6 deletions(-) - -diff --git a/Source/Common/FEXServerClient.cpp b/Source/Common/FEXServerClient.cpp -index 424ecf0a09..9daaf8a902 100644 ---- a/Source/Common/FEXServerClient.cpp -+++ b/Source/Common/FEXServerClient.cpp -@@ -96,14 +96,21 @@ fextl::string GetServerRootFSLockFile() { - } - - fextl::string GetTempFolder() { -- auto XDGRuntimeEnv = getenv("XDG_RUNTIME_DIR"); -- if (XDGRuntimeEnv) { -- // If the XDG runtime directory works then use that. -- return XDGRuntimeEnv; -+ const std::array Vars = { -+ "XDG_RUNTIME_DIR", "TMPDIR", "TMP", "TEMP", "TEMPDIR", -+ }; -+ -+ for (auto& Var : Vars) { -+ auto Path = getenv(Var); -+ if (Path) { -+ // If one of the env variable-driven paths works then use that. -+ return Path; -+ } - } -- // Fallback to `/tmp/` if XDG_RUNTIME_DIR doesn't exist. -+ -+ // Fallback to `/tmp/` if no env vars are set. - // Might not be ideal but we don't have much of a choice. -- return fextl::string {std::filesystem::temp_directory_path().string()}; -+ return fextl::string {"/tmp"}; - } - - fextl::string GetServerMountFolder() { - -From a1aa2547ce16a38b8ae92e23ca1f2288ec3cca9f Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Wed, 20 Nov 2024 01:57:17 +0900 -Subject: [PATCH 2/4] FEXServerClient: Do not use strerror() in - ConnectToServer() - -This triggers glibc allocation. - -Signed-off-by: Asahi Lina ---- - Source/Common/FEXServerClient.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/Source/Common/FEXServerClient.cpp b/Source/Common/FEXServerClient.cpp -index 9daaf8a902..4cab8e181f 100644 ---- a/Source/Common/FEXServerClient.cpp -+++ b/Source/Common/FEXServerClient.cpp -@@ -160,7 +160,7 @@ int ConnectToServer(ConnectionOption ConnectionOption) { - // Create the initial unix socket - int SocketFD = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); - if (SocketFD == -1) { -- LogMan::Msg::EFmt("Couldn't open AF_UNIX socket {} {}", errno, strerror(errno)); -+ LogMan::Msg::EFmt("Couldn't open AF_UNIX socket {}", errno); - return -1; - } - -@@ -177,7 +177,7 @@ int ConnectToServer(ConnectionOption ConnectionOption) { - - if (connect(SocketFD, reinterpret_cast(&addr), SizeOfAddr) == -1) { - if (ConnectionOption == ConnectionOption::Default || errno != ECONNREFUSED) { -- LogMan::Msg::EFmt("Couldn't connect to FEXServer socket {} {} {}", ServerSocketName, errno, strerror(errno)); -+ LogMan::Msg::EFmt("Couldn't connect to FEXServer socket {} {}", ServerSocketName, errno); - } - close(SocketFD); - return -1; - -From d761fc44f4a694b205519e0f1fe36eea7de789f3 Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Wed, 13 Nov 2024 02:09:34 +0900 -Subject: [PATCH 3/4] FEXServer: Listen on both abstract & named sockets - -Abstract sockets have one limitation: they are bound to a network -namespace. Chromium/CEF sandboxes using a new netns, which breaks -connecting to the FEXServer. - -To work around this, use and try *both* abstract and named sockets. As -long as either the filesystem or the network is unsandboxed, things will -work. If both are sandboxed, there isn't much we can do... but at that -point we shouldn't be reinitializing the FEXServer connection anyway -since the FS should be available on FEXInterpreter startup. ---- - Source/Common/FEXServerClient.cpp | 40 +++++++++++++++++++-- - Source/Common/FEXServerClient.h | 1 + - Source/Tools/FEXServer/Main.cpp | 8 ++++- - Source/Tools/FEXServer/ProcessPipe.cpp | 48 ++++++++++++++++++-------- - Source/Tools/FEXServer/ProcessPipe.h | 2 +- - 5 files changed, 80 insertions(+), 19 deletions(-) - -diff --git a/Source/Common/FEXServerClient.cpp b/Source/Common/FEXServerClient.cpp -index 4cab8e181f..32180693e7 100644 ---- a/Source/Common/FEXServerClient.cpp -+++ b/Source/Common/FEXServerClient.cpp -@@ -150,6 +150,24 @@ fextl::string GetServerSocketName() { - return ServerSocketPath; - } - -+fextl::string GetServerSocketPath() { -+ FEX_CONFIG_OPT(ServerSocketPath, SERVERSOCKETPATH); -+ -+ auto name = ServerSocketPath(); -+ -+ if (name.starts_with("/")) { -+ return name; -+ } -+ -+ auto Folder = GetTempFolder(); -+ -+ if (name.empty()) { -+ return fextl::fmt::format("{}/{}.FEXServer.Socket", Folder, ::geteuid()); -+ } else { -+ return fextl::fmt::format("{}/{}", Folder, name); -+ } -+} -+ - int GetServerFD() { - return ServerFD; - } -@@ -179,11 +197,27 @@ int ConnectToServer(ConnectionOption ConnectionOption) { - if (ConnectionOption == ConnectionOption::Default || errno != ECONNREFUSED) { - LogMan::Msg::EFmt("Couldn't connect to FEXServer socket {} {}", ServerSocketName, errno); - } -- close(SocketFD); -- return -1; -+ } else { -+ return SocketFD; -+ } -+ -+ // Try again with a path-based socket, since abstract sockets will fail if we have been -+ // placed in a new netns as part of a sandbox. -+ auto ServerSocketPath = GetServerSocketPath(); -+ -+ SizeOfSocketString = std::min(ServerSocketPath.size(), sizeof(addr.sun_path) - 1); -+ strncpy(addr.sun_path, ServerSocketPath.data(), SizeOfSocketString); -+ SizeOfAddr = sizeof(addr.sun_family) + SizeOfSocketString; -+ if (connect(SocketFD, reinterpret_cast(&addr), SizeOfAddr) == -1) { -+ if (ConnectionOption == ConnectionOption::Default || (errno != ECONNREFUSED && errno != ENOENT)) { -+ LogMan::Msg::EFmt("Couldn't connect to FEXServer socket {} {}", ServerSocketPath, errno); -+ } -+ } else { -+ return SocketFD; - } - -- return SocketFD; -+ close(SocketFD); -+ return -1; - } - - bool SetupClient(char* InterpreterPath) { -diff --git a/Source/Common/FEXServerClient.h b/Source/Common/FEXServerClient.h -index 14599c102e..6bad43fc07 100644 ---- a/Source/Common/FEXServerClient.h -+++ b/Source/Common/FEXServerClient.h -@@ -53,6 +53,7 @@ fextl::string GetServerRootFSLockFile(); - fextl::string GetTempFolder(); - fextl::string GetServerMountFolder(); - fextl::string GetServerSocketName(); -+fextl::string GetServerSocketPath(); - int GetServerFD(); - - bool SetupClient(char* InterpreterPath); -diff --git a/Source/Tools/FEXServer/Main.cpp b/Source/Tools/FEXServer/Main.cpp -index 40ae2116b7..36fc87279a 100644 ---- a/Source/Tools/FEXServer/Main.cpp -+++ b/Source/Tools/FEXServer/Main.cpp -@@ -163,7 +163,13 @@ int main(int argc, char** argv, char** const envp) { - return -1; - } - -- if (!ProcessPipe::InitializeServerSocket()) { -+ if (!ProcessPipe::InitializeServerSocket(true)) { -+ // Couldn't create server socket for some reason -+ PipeScanner::ClosePipes(); -+ return -1; -+ } -+ -+ if (!ProcessPipe::InitializeServerSocket(false)) { - // Couldn't create server socket for some reason - PipeScanner::ClosePipes(); - return -1; -diff --git a/Source/Tools/FEXServer/ProcessPipe.cpp b/Source/Tools/FEXServer/ProcessPipe.cpp -index e379dfe34b..f3a898ce73 100644 ---- a/Source/Tools/FEXServer/ProcessPipe.cpp -+++ b/Source/Tools/FEXServer/ProcessPipe.cpp -@@ -19,6 +19,7 @@ namespace ProcessPipe { - constexpr int USER_PERMS = S_IRWXU | S_IRWXG | S_IRWXO; - int ServerLockFD {-1}; - int ServerSocketFD {-1}; -+int ServerFSSocketFD {-1}; - std::atomic ShouldShutdown {false}; - time_t RequestTimeout {10}; - bool Foreground {false}; -@@ -175,40 +176,58 @@ bool InitializeServerPipe() { - return true; - } - --bool InitializeServerSocket() { -- auto ServerSocketName = FEXServerClient::GetServerSocketName(); -+bool InitializeServerSocket(bool abstract) { - - // Create the initial unix socket -- ServerSocketFD = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); -- if (ServerSocketFD == -1) { -+ int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); -+ if (fd == -1) { - LogMan::Msg::EFmt("Couldn't create AF_UNIX socket: {} {}\n", errno, strerror(errno)); - return false; - } - - struct sockaddr_un addr {}; - addr.sun_family = AF_UNIX; -- size_t SizeOfSocketString = std::min(ServerSocketName.size() + 1, sizeof(addr.sun_path) - 1); -- addr.sun_path[0] = 0; // Abstract AF_UNIX sockets start with \0 -- strncpy(addr.sun_path + 1, ServerSocketName.data(), SizeOfSocketString); -+ -+ size_t SizeOfSocketString; -+ if (abstract) { -+ auto ServerSocketName = FEXServerClient::GetServerSocketName(); -+ SizeOfSocketString = std::min(ServerSocketName.size() + 1, sizeof(addr.sun_path) - 1); -+ addr.sun_path[0] = 0; // Abstract AF_UNIX sockets start with \0 -+ strncpy(addr.sun_path + 1, ServerSocketName.data(), SizeOfSocketString); -+ } else { -+ auto ServerSocketPath = FEXServerClient::GetServerSocketPath(); -+ // Unlink the socket file if it exists -+ // We are being asked to create a daemon, not error check -+ // We don't care if this failed or not -+ unlink(ServerSocketPath.c_str()); -+ -+ SizeOfSocketString = std::min(ServerSocketPath.size(), sizeof(addr.sun_path) - 1); -+ strncpy(addr.sun_path, ServerSocketPath.data(), SizeOfSocketString); -+ } - // Include final null character. - size_t SizeOfAddr = sizeof(addr.sun_family) + SizeOfSocketString; - - // Bind the socket to the path -- int Result = bind(ServerSocketFD, reinterpret_cast(&addr), SizeOfAddr); -+ int Result = bind(fd, reinterpret_cast(&addr), SizeOfAddr); - if (Result == -1) { - LogMan::Msg::EFmt("Couldn't bind AF_UNIX socket '{}': {} {}\n", addr.sun_path, errno, strerror(errno)); -- close(ServerSocketFD); -- ServerSocketFD = -1; -+ close(fd); - return false; - } - -- listen(ServerSocketFD, 16); -+ listen(fd, 16); - PollFDs.emplace_back(pollfd { -- .fd = ServerSocketFD, -+ .fd = fd, - .events = POLLIN, - .revents = 0, - }); - -+ if (abstract) { -+ ServerSocketFD = fd; -+ } else { -+ ServerFSSocketFD = fd; -+ } -+ - return true; - } - -@@ -422,6 +441,7 @@ void CloseConnections() { - - // Close the server socket so no more connections can be started - close(ServerSocketFD); -+ close(ServerFSSocketFD); - } - - void WaitForRequests() { -@@ -441,12 +461,12 @@ void WaitForRequests() { - bool Erase {}; - - if (Event.revents != 0) { -- if (Event.fd == ServerSocketFD) { -+ if (Event.fd == ServerSocketFD || Event.fd == ServerFSSocketFD) { - if (Event.revents & POLLIN) { - // If it is the listen socket then we have a new connection - struct sockaddr_storage Addr {}; - socklen_t AddrSize {}; -- int NewFD = accept(ServerSocketFD, reinterpret_cast(&Addr), &AddrSize); -+ int NewFD = accept(Event.fd, reinterpret_cast(&Addr), &AddrSize); - - // Add the new client to the temporary array - NewPollFDs.emplace_back(pollfd { -diff --git a/Source/Tools/FEXServer/ProcessPipe.h b/Source/Tools/FEXServer/ProcessPipe.h -index 5c3f4c9b51..e4379bd351 100644 ---- a/Source/Tools/FEXServer/ProcessPipe.h -+++ b/Source/Tools/FEXServer/ProcessPipe.h -@@ -4,7 +4,7 @@ - - namespace ProcessPipe { - bool InitializeServerPipe(); --bool InitializeServerSocket(); -+bool InitializeServerSocket(bool abstract); - void WaitForRequests(); - void SetConfiguration(bool Foreground, uint32_t PersistentTimeout); - void Shutdown(); - -From c3e8cd8d30146a914a1e91140719acbf8fcb7cee Mon Sep 17 00:00:00 2001 -From: Asahi Lina -Date: Wed, 20 Nov 2024 02:05:32 +0900 -Subject: [PATCH 4/4] docs: Document that - std::filesystem::temp_directory_path() is unsafe - ---- - docs/ProgrammingConcerns.md | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/docs/ProgrammingConcerns.md b/docs/ProgrammingConcerns.md -index c43c28a75e..5e8d8d6726 100644 ---- a/docs/ProgrammingConcerns.md -+++ b/docs/ProgrammingConcerns.md -@@ -79,6 +79,9 @@ Use `FHU::Filesystem::GetFilename` instead. - #### std::filesystem::copy_file - Use `FHU::Filesystem::CopyFile` instead. - -+#### std::filesystem::temp_directory_path -+See `GetTempFolder()` in `FEXServerClient.cpp` (split/move to `FHU::Filesystem` if needed by other users). -+ - ### `std::fstream` - This API always allocates memory and should be avoided. - Use a combination of open and fextl::string APIs instead of fstream. diff --git a/app-emulation/FEX/files/FEX-2410-tiny-json-as-static.patch b/app-emulation/FEX/files/FEX-2410-tiny-json-as-static.patch deleted file mode 100644 index bf30915..0000000 --- a/app-emulation/FEX/files/FEX-2410-tiny-json-as-static.patch +++ /dev/null @@ -1,9 +0,0 @@ -diff --git a/External/tiny-json/CMakeLists.txt b/External/tiny-json/CMakeLists.txt -index 8cf0054..a0c6194 100644 ---- a/External/tiny-json/CMakeLists.txt -+++ b/External/tiny-json/CMakeLists.txt -@@ -1,3 +1,3 @@ - set(NAME tiny-json) - set(SRCS tiny-json.c) --add_library(${NAME} ${SRCS}) -+add_library(${NAME} STATIC ${SRCS}) diff --git a/app-emulation/FEX/files/FEX-2410-unvendor-drm-headers.patch b/app-emulation/FEX/files/FEX-2410-unvendor-drm-headers.patch deleted file mode 100644 index 195d95e..0000000 --- a/app-emulation/FEX/files/FEX-2410-unvendor-drm-headers.patch +++ /dev/null @@ -1,92 +0,0 @@ -commit 763000de8d4f8aee1eb0bc0cf36f3f45fba07a1f -Author: Sasha Finkelstein -Date: Wed Aug 21 13:31:16 2024 +0200 - - unvendor drm-headers - -diff --git a/Source/Tools/LinuxEmulation/CMakeLists.txt b/Source/Tools/LinuxEmulation/CMakeLists.txt -index 3076a31..6deb0e6 100644 ---- a/Source/Tools/LinuxEmulation/CMakeLists.txt -+++ b/Source/Tools/LinuxEmulation/CMakeLists.txt -@@ -72,7 +72,6 @@ target_include_directories(LinuxEmulation - PRIVATE - ${CMAKE_BINARY_DIR}/generated - ${CMAKE_CURRENT_SOURCE_DIR}/ -- ${PROJECT_SOURCE_DIR}/External/drm-headers/include/ - ) - - target_include_directories(LinuxEmulation -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Ioctl/drm.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Ioctl/drm.h -index efecf2c..cded3a0 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Ioctl/drm.h -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Ioctl/drm.h -@@ -10,21 +10,21 @@ extern "C" { - // drm headers use a `__user` define that has an address_space attribute. This allows their tooling to see unsafe user-space accesses. - // Define this to nothing so we don't need to modify those headers. - #define __user --#include "fex-drm/drm.h" --#include "fex-drm/drm_mode.h" --#include "fex-drm/i915_drm.h" --#include "fex-drm/amdgpu_drm.h" --#include "fex-drm/lima_drm.h" --#include "fex-drm/panfrost_drm.h" --#include "fex-drm/msm_drm.h" --#include "fex-drm/nouveau_drm.h" --#include "fex-drm/radeon_drm.h" --#include "fex-drm/vc4_drm.h" --#include "fex-drm/v3d_drm.h" --#include "fex-drm/panthor_drm.h" --#include "fex-drm/pvr_drm.h" --#include "fex-drm/virtgpu_drm.h" --#include "fex-drm/xe_drm.h" -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include - } - #include - -diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl/drm.h b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl/drm.h -index ae8b0fa..ddb565f 100644 ---- a/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl/drm.h -+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/x64/Ioctl/drm.h -@@ -7,17 +7,17 @@ - - #include - extern "C" { --#include "fex-drm/drm.h" --#include "fex-drm/drm_mode.h" --#include "fex-drm/i915_drm.h" --#include "fex-drm/amdgpu_drm.h" --#include "fex-drm/lima_drm.h" --#include "fex-drm/panfrost_drm.h" --#include "fex-drm/msm_drm.h" --#include "fex-drm/nouveau_drm.h" --#include "fex-drm/vc4_drm.h" --#include "fex-drm/v3d_drm.h" --#include "fex-drm/virtgpu_drm.h" -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include - } - #include -