Finally At A Nice Point

This commit is contained in:
TheBrokenRail 2024-06-08 16:30:39 -04:00
parent d52c16e722
commit a0f32a15a7
18 changed files with 71 additions and 75 deletions

6
.gitmodules vendored
View File

@ -22,6 +22,6 @@
[submodule "dependencies/symbol-processor/src"] [submodule "dependencies/symbol-processor/src"]
path = dependencies/symbol-processor/src path = dependencies/symbol-processor/src
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/symbol-processor.git url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/symbol-processor.git
[submodule "dependencies/trampoline/src"] [submodule "dependencies/runtime/src"]
path = dependencies/trampoline/src path = dependencies/runtime/src
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/trampoline.git url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/runtime.git

View File

@ -38,12 +38,6 @@ else()
set(BUILD_MEDIA_LAYER_CORE "${BUILD_ARM_COMPONENTS}") set(BUILD_MEDIA_LAYER_CORE "${BUILD_ARM_COMPONENTS}")
endif() endif()
# Trampoline Host
set(MCPI_USE_TRAMPOLINE_HOST FALSE)
if(BUILD_NATIVE_COMPONENTS AND (MCPI_USE_MEDIA_LAYER_TRAMPOLINE OR NOT IS_ARM_TARGETING))
set(MCPI_USE_TRAMPOLINE_HOST TRUE)
endif()
# Specify Variant Name # Specify Variant Name
set(MCPI_VARIANT_NAME "minecraft-pi-reborn") set(MCPI_VARIANT_NAME "minecraft-pi-reborn")
if(MCPI_SERVER_MODE) if(MCPI_SERVER_MODE)

View File

@ -49,6 +49,7 @@ if("${toolchain_dir}/bin/arm-none-linux-gnueabihf-gcc" IS_NEWER_THAN "${sysroot_
file(REMOVE_RECURSE "${sysroot_dir}/usr/lib/gconv") file(REMOVE_RECURSE "${sysroot_dir}/usr/lib/gconv")
# Strip Files # Strip Files
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir}/*") file(GLOB_RECURSE files LIST_DIRECTORIES FALSE "${sysroot_dir}/*")
foreach(file IN LISTS files) foreach(file IN LISTS files)
execute_process(COMMAND "${toolchain_dir}/bin/arm-none-linux-gnueabihf-strip" "${file}" RESULT_VARIABLE ret) execute_process(COMMAND "${toolchain_dir}/bin/arm-none-linux-gnueabihf-strip" "${file}" RESULT_VARIABLE ret)
@ -59,6 +60,7 @@ if("${toolchain_dir}/bin/arm-none-linux-gnueabihf-gcc" IS_NEWER_THAN "${sysroot_
endif() endif()
endforeach() endforeach()
endif() endif()
endif()
# Install Sysroot (Skipping Empty Directories) # Install Sysroot (Skipping Empty Directories)
function(install_arm_sysroot) function(install_arm_sysroot)

View File

@ -16,8 +16,8 @@ endif()
if(BUILD_NATIVE_COMPONENTS OR (BUILD_MEDIA_LAYER_CORE AND NOT MCPI_HEADLESS_MODE)) if(BUILD_NATIVE_COMPONENTS OR (BUILD_MEDIA_LAYER_CORE AND NOT MCPI_HEADLESS_MODE))
add_subdirectory(LIEF) add_subdirectory(LIEF)
endif() endif()
# Trampoline # Extra Runtime
add_subdirectory(trampoline) add_subdirectory(runtime)
# GLFW # GLFW
if(BUILD_MEDIA_LAYER_CORE AND NOT MCPI_HEADLESS_MODE) if(BUILD_MEDIA_LAYER_CORE AND NOT MCPI_HEADLESS_MODE)
add_subdirectory(glfw) add_subdirectory(glfw)

16
dependencies/runtime/CMakeLists.txt vendored Normal file
View File

@ -0,0 +1,16 @@
project(runtime)
## Extra Runtime
# QEMU
set(QEMU_VERSION "9.0.0")
set(RUNTIME_QEMU_ARCHIVE "${CMAKE_CURRENT_SOURCE_DIR}/../../archives/qemu-${QEMU_VERSION}.tar.xz")
if(NOT BUILD_NATIVE_COMPONENTS)
set(TRAMPOLINE_HEADERS_ONLY TRUE)
endif()
# Build
add_subdirectory(src)
# Install
install_runtime("${MCPI_BIN_DIR}" "${MCPI_LEGAL_DIR}")

1
dependencies/runtime/src vendored Submodule

@ -0,0 +1 @@
Subproject commit e6839074fd2eec91c5bb2e08705f2f235a568f74

View File

@ -1,16 +0,0 @@
project(trampoline)
## Trampoline Host
# QEMU
set(QEMU_VERSION "9.0.0")
set(TRAMPOLINE_QEMU_ARCHIVE "${CMAKE_CURRENT_SOURCE_DIR}/../../archives/qemu-${QEMU_VERSION}.tar.xz")
if(NOT MCPI_USE_TRAMPOLINE_HOST)
set(TRAMPOLINE_HEADERS_ONLY TRUE)
endif()
# Build
add_subdirectory(src)
# Install
install_trampoline("${MCPI_BIN_DIR}" "${MCPI_LEGAL_DIR}")

@ -1 +0,0 @@
Subproject commit 50d94d52998ba361c5d89d1b21f7eafd972f3f4e

View File

@ -19,10 +19,7 @@ if(NOT MCPI_SERVER_MODE)
src/client/available-feature-flags # Show In IDE src/client/available-feature-flags # Show In IDE
) )
endif() endif()
target_link_libraries(launcher reborn-util LIB_LIEF) target_link_libraries(launcher reborn-util LIB_LIEF trampoline-headers)
if(MCPI_USE_TRAMPOLINE_HOST)
target_link_libraries(launcher trampoline-headers)
endif()
# RPath # RPath
set_target_properties(launcher PROPERTIES INSTALL_RPATH "$ORIGIN/lib/native") set_target_properties(launcher PROPERTIES INSTALL_RPATH "$ORIGIN/lib/native")
target_link_options(launcher PRIVATE "LINKER:--disable-new-dtags") target_link_options(launcher PRIVATE "LINKER:--disable-new-dtags")

View File

@ -10,7 +10,6 @@
#include "patchelf.h" #include "patchelf.h"
#define MCPI_BINARY "minecraft-pi" #define MCPI_BINARY "minecraft-pi"
#define QEMU_BINARY "qemu-arm"
#define REQUIRED_PAGE_SIZE 4096 #define REQUIRED_PAGE_SIZE 4096
@ -151,14 +150,6 @@ void bootstrap() {
mcpi_ld_path += binary_directory + "/sysroot/usr/lib:"; mcpi_ld_path += binary_directory + "/sysroot/usr/lib:";
mcpi_ld_path += binary_directory + "/sysroot/usr/lib/arm-linux-gnueabihf:"; mcpi_ld_path += binary_directory + "/sysroot/usr/lib/arm-linux-gnueabihf:";
#endif #endif
// Add Host LD_LIBRARY_PATH
{
char *value = getenv("LD_LIBRARY_PATH");
if (value != nullptr && strlen(value) > 0) {
mcpi_ld_path += value;
}
}
} }
} }
@ -177,12 +168,12 @@ void bootstrap() {
// Arguments // Arguments
std::vector<std::string> args; std::vector<std::string> args;
// Use Trampoline Host If Needed // Use Extra If Needed
#ifdef MCPI_USE_TRAMPOLINE_HOST #ifdef MCPI_BUILD_RUNTIME
args.push_back("trampoline"); args.push_back("runtime");
#endif #endif
// Fix QEMU Bug // Fix QEMU Bug
#ifdef MCPI_USE_QEMU #ifdef MCPI_RUNTIME_IS_QEMU
args.push_back("-B"); args.push_back("-B");
args.push_back("0x40000"); // Arbitrary Value (Aligns To 4k And 16k Page Sizes) args.push_back("0x40000"); // Arbitrary Value (Aligns To 4k And 16k Page Sizes)
#endif #endif

View File

@ -8,6 +8,7 @@
#include <poll.h> #include <poll.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/prctl.h>
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
@ -110,6 +111,9 @@ void setup_crash_report() {
// Create New Process Group // Create New Process Group
setpgid(0, 0); setpgid(0, 0);
// Kill Child If Parent Exits First
prctl(PR_SET_PDEATHSIG, SIGKILL);
// Continue Execution // Continue Execution
} else { } else {
// Parent Process // Parent Process

View File

@ -2,10 +2,6 @@
#include <libreborn/libreborn.h> #include <libreborn/libreborn.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef MCPI_USE_NATIVE_TRAMPOLINE
#include <trampoline/types.h>
#endif
#include "bootstrap.h" #include "bootstrap.h"
#include "options/parser.h" #include "options/parser.h"
#include "crash-report.h" #include "crash-report.h"
@ -28,9 +24,6 @@ static void setup_environment(const options_t &options) {
#else #else
bind_to_env("_MCPI_ONLY_GENERATE", options.only_generate); bind_to_env("_MCPI_ONLY_GENERATE", options.only_generate);
#endif #endif
#ifdef MCPI_USE_NATIVE_TRAMPOLINE
bind_to_env(TRAMPOLINE_USE_PIPES_ENV, !options.use_ptrace_trampoline);
#endif
// GTK Dark Mode // GTK Dark Mode
#ifndef MCPI_HEADLESS_MODE #ifndef MCPI_HEADLESS_MODE

View File

@ -73,14 +73,6 @@ std::string bootstrap_mods(const std::string &binary_directory) {
load(preload, mods_folder); load(preload, mods_folder);
} }
// Add LD_PRELOAD
{
const char *value = getenv("LD_PRELOAD");
if (value != nullptr && strlen(value) > 0) {
preload += value;
}
}
// Return // Return
return preload; return preload;
} }

View File

@ -10,6 +10,3 @@ OPTION(benchmark, "benchmark", -7, "Run Benchmark")
#else #else
OPTION(only_generate, "only-generate", -8, "Generate World And Exit") OPTION(only_generate, "only-generate", -8, "Generate World And Exit")
#endif #endif
#ifdef MCPI_USE_NATIVE_TRAMPOLINE
OPTION(use_ptrace_trampoline, "use-ptrace-trampoline", -9, "Use PTrace For Calling Host Functions Instead Of Pipes")
#endif

View File

@ -13,6 +13,5 @@
#cmakedefine MCPI_VARIANT_NAME "@MCPI_VARIANT_NAME@" #cmakedefine MCPI_VARIANT_NAME "@MCPI_VARIANT_NAME@"
#cmakedefine MCPI_SDK_DIR "@MCPI_SDK_DIR@" #cmakedefine MCPI_SDK_DIR "@MCPI_SDK_DIR@"
#cmakedefine MCPI_SKIN_SERVER "@MCPI_SKIN_SERVER@" #cmakedefine MCPI_SKIN_SERVER "@MCPI_SKIN_SERVER@"
#cmakedefine MCPI_USE_TRAMPOLINE_HOST
#cmakedefine MCPI_DISCORD_INVITE "@MCPI_DISCORD_INVITE@" #cmakedefine MCPI_DISCORD_INVITE "@MCPI_DISCORD_INVITE@"
#cmakedefine MCPI_DOCUMENTATION "@MCPI_DOCUMENTATION@" #cmakedefine MCPI_DOCUMENTATION "@MCPI_DOCUMENTATION@"

View File

@ -319,6 +319,23 @@ CALL_GL_POINTER(41, glTexCoordPointer)
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
void glDisableClientState(const GLenum array) { void glDisableClientState(const GLenum array) {
gl_state.get_array_enabled(array) = false; gl_state.get_array_enabled(array) = false;
// Not needed when using compatibility layer
#ifndef MCPI_USE_GLES1_COMPATIBILITY_LAYER
switch (array) {
case GL_VERTEX_ARRAY: {
gl_array_details.glVertexPointer.size = -1;
break;
}
case GL_COLOR_ARRAY: {
gl_array_details.glColorPointer.size = -1;
break;
}
case GL_TEXTURE_COORD_ARRAY: {
gl_array_details.glTexCoordPointer.size = -1;
break;
}
}
#endif
} }
#endif #endif
@ -349,6 +366,12 @@ void glBindBuffer(const GLenum target, const GLuint buffer) {
} else { } else {
ERR("Unsupported Buffer Binding: %u", target); ERR("Unsupported Buffer Binding: %u", target);
} }
// Not needed when using compatibility layer
#ifndef MCPI_USE_GLES1_COMPATIBILITY_LAYER
gl_array_details.glVertexPointer.size = -1;
gl_array_details.glColorPointer.size = -1;
gl_array_details.glTexCoordPointer.size = -1;
#endif
} }
#endif #endif
@ -676,6 +699,10 @@ static int get_glGetIntegerv_params_size(GLenum pname) {
#endif #endif
CALL(61, glGetIntegerv, void, (GLenum pname, GLint *params)) CALL(61, glGetIntegerv, void, (GLenum pname, GLint *params))
#ifdef MEDIA_LAYER_TRAMPOLINE_GUEST #ifdef MEDIA_LAYER_TRAMPOLINE_GUEST
if (pname == GL_TEXTURE_BINDING_2D) {
params[0] = gl_state.bound_texture;
return;
}
trampoline(false, pname, uint32_t(params)); trampoline(false, pname, uint32_t(params));
#else #else
GLenum pname = args.next<GLenum>(); GLenum pname = args.next<GLenum>();

View File

@ -69,7 +69,7 @@ uint32_t _raw_trampoline(const uint32_t id, const bool allow_early_return, const
// Configure Method // Configure Method
static int use_syscall = -1; static int use_syscall = -1;
if (use_syscall == -1) { if (use_syscall == -1) {
use_syscall = getenv(TRAMPOLINE_USE_PIPES_ENV) == nullptr; use_syscall = getenv(TRAMPOLINE_ARGUMENTS_PIPE_ENV) == nullptr;
} }
// Use Correct Method // Use Correct Method
if (use_syscall) { if (use_syscall) {

View File

@ -1,3 +1,3 @@
extends Tile; extends Tile;
vtable 0x110fd0; vtable 0x111ec0;