-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library Forwarding: Make building on weak cross-compiling setups easier #3597
Draft
neobrain
wants to merge
3
commits into
FEX-Emu:main
Choose a base branch
from
neobrain:feature_libfwd_build
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,108 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(FEXLibWrappers) | ||
|
||
set(CMAKE_CXX_STANDARD 20) | ||
set(FEX_PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) | ||
|
||
add_subdirectory(Generator) | ||
|
||
# Two methods of building guest library wrappers are supported: | ||
# - build as part of the main project (recommended) | ||
# - build in isolation from a dedicated build folder | ||
# The second method is useful when it's difficult to set up a full | ||
# cross-compiling environment targeting x86. In those cases, guest library | ||
# compilation can be moved to a different machine / VM. | ||
if (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) | ||
# When included during a regular FEX build, build both guest and host libs | ||
# unless requested otherwise | ||
set(BUILD_HOST_LIBS TRUE) | ||
# BUILD_GUEST_LIBS from parent project | ||
|
||
# However, include targets for IDE integration of guest libs | ||
add_subdirectory(GuestLibs) | ||
else() | ||
# When included on our own, only build guest libraries | ||
set(BUILD_HOST_LIBS FALSE) | ||
set(BUILD_GUEST_LIBS TRUE) | ||
endif() | ||
|
||
if (BUILD_HOST_LIBS) | ||
# Targets for building host libraries and for IDE integration | ||
add_subdirectory(HostLibs) | ||
endif() | ||
|
||
if (BUILD_GUEST_LIBS) | ||
# Targets for building guest libraries | ||
include(ExternalProject) | ||
|
||
ExternalProject_Add(guest-libs | ||
PREFIX Guest/guest-libs | ||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/GuestLibs" | ||
BINARY_DIR "../Guest" | ||
CMAKE_ARGS | ||
"-DBITNESS=64" | ||
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" | ||
"-DBUILD_FEX_LINUX_TESTS=${BUILD_FEX_LINUX_TESTS}" | ||
"-DENABLE_CLANG_THUNKS=${ENABLE_CLANG_THUNKS}" | ||
"-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${FEX_PROJECT_SOURCE_DIR}/toolchain_x86_64.cmake" | ||
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" | ||
"-DFEX_PROJECT_SOURCE_DIR=${FEX_PROJECT_SOURCE_DIR}" | ||
"-DGENERATOR_EXE=$<TARGET_FILE:thunkgen>" | ||
"-DX86_DEV_ROOTFS=${X86_DEV_ROOTFS}" | ||
INSTALL_COMMAND "" | ||
BUILD_ALWAYS ON | ||
DEPENDS thunkgen | ||
) | ||
|
||
ExternalProject_Add(guest-libs-32 | ||
PREFIX Guest_32/guest-libs-32 | ||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/GuestLibs" | ||
BINARY_DIR "../Guest_32" | ||
CMAKE_ARGS | ||
"-DBITNESS=32" | ||
"-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" | ||
"-DBUILD_FEX_LINUX_TESTS=${BUILD_FEX_LINUX_TESTS}" | ||
"-DENABLE_CLANG_THUNKS=${ENABLE_CLANG_THUNKS}" | ||
"-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${FEX_PROJECT_SOURCE_DIR}/toolchain_x86_32.cmake" | ||
"-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" | ||
"-DFEX_PROJECT_SOURCE_DIR=${FEX_PROJECT_SOURCE_DIR}" | ||
"-DGENERATOR_EXE=$<TARGET_FILE:thunkgen>" | ||
"-DX86_DEV_ROOTFS=${X86_DEV_ROOTFS}" | ||
INSTALL_COMMAND "" | ||
BUILD_ALWAYS ON | ||
DEPENDS thunkgen | ||
) | ||
|
||
install( | ||
CODE "MESSAGE(\"-- Installing: guest-libs\")" | ||
CODE " | ||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} --build . --target install | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Guest | ||
)" | ||
DEPENDS guest-libs | ||
) | ||
|
||
install( | ||
CODE "MESSAGE(\"-- Installing: guest-libs-32\")" | ||
CODE " | ||
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} --build . --target install | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Guest_32 | ||
)" | ||
DEPENDS guest-libs-32 | ||
) | ||
|
||
if (TARGET uninstall) | ||
add_custom_target(uninstall_guest-libs | ||
COMMAND ${CMAKE_COMMAND} "--build" "." "--target" "uninstall" | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Guest | ||
) | ||
|
||
add_custom_target(uninstall_guest-libs-32 | ||
COMMAND ${CMAKE_COMMAND} "--build" "." "--target" "uninstall" | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Guest_32 | ||
) | ||
|
||
add_dependencies(uninstall uninstall_guest-libs) | ||
add_dependencies(uninstall uninstall_guest-libs-32) | ||
endif () | ||
endif() |
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something's off about this. I'm getting weird RPATH errors without
../
, but with../
it's clearly putting the data in the wrong folder.