-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sasha Finkelstein <[email protected]>
- Loading branch information
1 parent
4aa4e7b
commit c38642f
Showing
6 changed files
with
454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,328 @@ | ||
# 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 | ||
" | ||
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
DIST FEX-2409.tar.gz 2065576 BLAKE2B fce15a72f6268d988508481c86f5d9fa7fc9f89360f51691188bd4848a1111701b71765efe1e1a6585001415dee2970849d05da5ea85f06bbbac283edfb4b36a SHA512 91927eed83d2efb11ce929c7469c76ae244f06656f380a1bd34c4cdaf5ea5321b0976fc57b4f76dc48d87f29e095e37dd5226ee7bde756c354b62a5f4ebce790 | ||
DIST FEX-2410.tar.gz 2065522 BLAKE2B 8e4e32f6777dff592172d2e45e82bf9456f10bb1e2f18a189cab50f0d97c63891b420fc53bc9d2785b77d50dc859bd7e90e3dcf698c23772be72c11fda631cf6 SHA512 df4b85b03acb6246295c912b87f9b7a8998033f6daaaea0ef463cfff52de914c680ea27da4b97e294fc97565f39c95763015568d150917050f8e62f7a4537d74 | ||
DIST Vulkan-Headers-29f979ee5aa58b7b005f805ea8df7a855c39ff37.tar.gz 2359246 BLAKE2B 4208b0837789cb26bcb5309d8f1f56aa58dca2f06f61557b6624aa9e63566e62b1e544da33050a48489e58c3e71022ff58dd10ebca00008105c8a909cc07a44c SHA512 15618de42ee2bc019053f00e51afdf37dbdedc1ce6ec18e806e169ba002ac7720c8b3c75e57adb01e56d2c0f5888ddf6418f688bcb666859549befdfa3beb8b5 | ||
DIST Vulkan-Headers-31aa7f634b052d87ede4664053e85f3f4d1d50d3.tar.gz 2253807 BLAKE2B 8acbebf02f73fba915c041165ce5cb9177a2c23af94feaa4490adbdc09f5aee1683a4d93b07db30df5b810cd13c30a5cba19ece8424e9a600be57bb3055c40d3 SHA512 8df8622a9694572d5186397bd5838def975129c6369755f6fc82ac03a452e58faf563ae41eda4d2b85fa528cdd755840f39b11a3fe5d48a1c9ab92ce7acb38d9 | ||
DIST cpp-optparse-eab4212ae864ba64306f0fe87f102e66cb5a3617.tar.gz 13162 BLAKE2B a1baf212e684d355e312b867c9c046d3b9946a71b0ed1c6a6322f6eb16bdb88f9ffb1f2201baf5ff06ddb0068bab42f2b8cbff9d3e79103e4148b7b100d0593e SHA512 12bb88cc26642b8951cb9cdd7c02e2690303da021d781ad49f41d5cc222eeb3cad955023cbe132d70be155962bad045d071c0af804ec515d8890026c344f23a9 | ||
DIST imgui-4c986ecb8d2807087fd8e34894d1e7a138bc2f1d.tar.gz 2582472 BLAKE2B 43f327d38334211eeef6156567f8a09f95ac38d1cd339f7e813a8c267db6a9bb76485a665c58ac9669888f70f8ff4b7b29e4e60192234f945491222e594c4bcd SHA512 7ffc128ec52e3f67d0a8dec9c7fc02141afa27b04179bc27e9cba064a199053a1aaceee99b0e670ad458264fed9eb31cc82f01f3b247de031ef2c0a592371ef7 | ||
DIST jemalloc-02ca52b5fefc0ccd0d2c4eaa1d17989cdd641927.tar.gz 847982 BLAKE2B 7676066b106af133bb7dab4518aa63fe10341cf86175f8ed664b4850f240535c2107698876e9406a0f36e312f89cdb6785393e3883c212fd9cba3031047814ce SHA512 b15e1fdcff9f593dbaca88337a2ab784cb66491ef8794f72fbf67617c1f396c57ba1664deb53fa18e5c21a4bd777809ae4c03b1ce48f6e80ccabbcbd7668651d | ||
DIST jemalloc-7ae889695b8bebdc67c004c2c9c8d2e57748d2ab.tar.gz 847970 BLAKE2B 03ff7d1e221c73a07bbe7c9b3cdac81b7629601eea530c867101cd03a83042cbe7034ecfc7724ff0278bb829bba18e2196f471cd786b3a4a7f97a412121cb2a5 SHA512 58259c7cbc3f117138bb047799cf8c1ebeaec1f81f72678ee75216f74b53a7b1bdb4087113353bceb3edd94322e7e0689a0874910dc9a7cbfefd026ee782739b | ||
DIST jemalloc-glibc-404353974e335fb771562249163e2ea62c558e7e.tar.gz 825252 BLAKE2B deec3bbccbe898af2875e184c2fd350ebaa082b241f32f2f14eafe9cab00e531ee21d7a505845f85fb476b12f5299ce030a7074598603a238b0e3619b875ba49 SHA512 9902c1c8be69a09eeaa55e163216ca3c4b4eb12767c62032f07249cd7de1770f74364c309656a94a64afeaf25901042d8cab6bc5b706f35566c503b1750bbffd | ||
DIST jemalloc-glibc-888181c5f7072ab1bd7aa7aca6d9f85816a95c43.tar.gz 825240 BLAKE2B 63ed3d08a6f0532520b859ebfaf0b3842dad804018014990c9c2e0c75786e44f5d5d0743f003446497aa3961e4712ca213650ec4bfe145850b393b9d888c0034 SHA512 89944779596d541fa941896186cb5d9c00e32e483002619429da5b37e5a6f59e1181c7878513da5b33e3680fb93d1488841e5e64c83c949127009f6741df6c62 | ||
DIST libfmt-11.0.2.tar.gz 700956 BLAKE2B c1f7998e68770bbb93ab7211a18b4930727699b340b2f2e15dedc83e55ff02400cfd363abaec1bf63a0165f8c21cc515a4aa23c4f3bc2e65b6fbc041781f0379 SHA512 47ff6d289dcc22681eea6da465b0348172921e7cafff8fd57a1540d3232cc6b53250a4625c954ee0944c87963b17680ecbc3ea123e43c2c822efe0dc6fa6cef3 | ||
DIST robin-map-d5683d9f1891e5b04e3e3b2192b5349dc8d814ea.tar.gz 70652 BLAKE2B 03ca6c6c333661ece0ac818d43eee37ead3e0a0acb71c45df201bff30715db89b8f2be3f5bac0991379327f2fac4273ba1bd3d6c4102e5a472a7c7567fae4651 SHA512 23fe18c7d2dda9bc4216201a7e5935c8dc9f51066173e95d514360e3310c994c4dc7786a33f43cb7d15dcceb913375a48b8c02529eacde58c0a80f0e91e9b94d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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}) |
Oops, something went wrong.