From dc4460eefd95deb26e86247342ab6a5d9cb8d2d5 Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Tue, 4 Mar 2025 07:57:36 -0800 Subject: [PATCH] Disable alias attribute on macOS clang. (#19) --- XenonRecomp/CMakeLists.txt | 5 +++++ XenonRecomp/recompiler.cpp | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/XenonRecomp/CMakeLists.txt b/XenonRecomp/CMakeLists.txt index 623a06f..f5db6d1 100644 --- a/XenonRecomp/CMakeLists.txt +++ b/XenonRecomp/CMakeLists.txt @@ -19,6 +19,11 @@ target_link_libraries(XenonRecomp PRIVATE if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(XenonRecomp PRIVATE -Wno-switch -Wno-unused-variable -Wno-null-arithmetic) + + # alias attribute not supported on Apple. + if (NOT APPLE) + target_compile_definitions(XenonRecomp PRIVATE XENON_RECOMP_USE_ALIAS) + endif() endif() target_compile_definitions(XenonRecomp PRIVATE _CRT_SECURE_NO_WARNINGS) diff --git a/XenonRecomp/recompiler.cpp b/XenonRecomp/recompiler.cpp index 4f84b5a..5374797 100644 --- a/XenonRecomp/recompiler.cpp +++ b/XenonRecomp/recompiler.cpp @@ -2358,7 +2358,10 @@ bool Recompiler::Recompile(const Function& fn) name = fmt::format("sub_{}", fn.base); } +#ifdef XENON_RECOMP_USE_ALIAS println("__attribute__((alias(\"__imp__{}\"))) PPC_WEAK_FUNC({});", name, name); +#endif + println("PPC_FUNC_IMPL(__imp__{}) {{", name); println("\tPPC_FUNC_PROLOGUE();"); @@ -2419,6 +2422,12 @@ bool Recompiler::Recompile(const Function& fn) println("}}\n"); +#ifndef XENON_RECOMP_USE_ALIAS + println("PPC_WEAK_FUNC({}) {{", name); + println("\t__imp__{}(ctx, base);", name); + println("}}\n"); +#endif + std::swap(out, tempString); if (localVariables.ctr) println("\tPPCRegister ctr{{}};");