Skip to content

fix(Clang&MinGW): Fix Clang and MinGW builds on linux. #303

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

Merged
merged 2 commits into from
May 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/
.cache
.vs
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ message(STATUS "Setting up include directories.")
target_include_directories(${PROJECT_NAME} PRIVATE
"${SRC_DIR}"
"${imgui_SOURCE_DIR}"
"${minhook_SOURCE_DIR}/include"
"${minhook_SOURCE_DIR}/src/hde"
"${gtav_classes_SOURCE_DIR}"
"${minhook_SOURCE_DIR}/include"
"${minhook_SOURCE_DIR}/src/hde"
)

message(STATUS "Setting up linked libraries")
Expand Down
11 changes: 6 additions & 5 deletions cmake/cross-compile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ if(USE_GCC OR USE_CLANG)
set(TOOLCHAIN_PREFIX "x86_64-w64-mingw32" CACHE STRING "Set toolchain. Default: x86_64-w64-mingw32")
message(STATUS "Using ${TOOLCHAIN_PREFIX} toolchain")
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
set(CMAKE_SYSTEM_NAME "Windows")
set(CMAKE_ASM_MASM_COMPILER "uasm")

set(CMAKE_C_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_CXX_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)

Expand All @@ -30,16 +27,20 @@ if(USE_GCC OR USE_CLANG)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fpermissive;-fno-rtti${CXX_FLAGS}>")
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_C_COMPILER_TARGET x86_64-windows-gnu)
set(CMAKE_CXX_COMPILER_TARGET x86_64-windows-gnu)
endif()

if(USE_CLANG)
message(STATUS "Using clang compiler.")
set(CMAKE_C_COMPILER clang)
set(CMAKE_CXX_COMPILER clang++)
set(CMAKE_C_COMPILER_TARGET x86_64-windows-msvc)
set(CMAKE_CXX_COMPILER_TARGET x86_64-windows-msvc)

# Disable RTTI to work around libstdc++ issue https://stackoverflow.com/a/77025827
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fuse-ld=lld;-femulated-tls;-fno-rtti${CXX_FLAGS}>")
add_link_options(-fuse-ld=lld -femulated-tls -fno-rtti)
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:-fuse-ld=lld;-fno-rtti${CXX_FLAGS}>")
add_link_options(-fuse-ld=lld -fno-rtti)
endif()

endif()
2 changes: 1 addition & 1 deletion cmake/json.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include(FetchContent)

message(STATUS "Setting up nlohmann::json")
FetchContent_Declare(json GIT_REPOSITORY "https://github.com/nlohmann/json/" GIT_TAG v3.11.2 GIT_SHALLOW TRUE)
FetchContent_Declare(json GIT_REPOSITORY "https://github.com/nlohmann/json/" GIT_TAG v3.12.0 GIT_SHALLOW TRUE)
option(JSON_MultipleHeaders "Disable nlohmann JSON multi header default." OFF)
FetchContent_MakeAvailable(json)
2 changes: 1 addition & 1 deletion cmake/minhook.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ message(STATUS "Setting up ${LIB_NAME}")
FetchContent_Declare(
${LIB_NAME}
GIT_REPOSITORY https://github.com/TsudaKageyu/minhook.git
GIT_TAG 98b74f1fc12d00313d91f10450e5b3e0036175e3
GIT_TAG 2b003bb063d66f016cc1aef7d63951350ce60f35
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(${LIB_NAME})
2 changes: 1 addition & 1 deletion src/core/frontend/widgets/imgui_bitfield.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace ImGui
}
if (i % 4 == 0)
{
ImGui::Text("%i", i);
ImGui::Text("%zu", i);
ImGui::EndGroup();
}
if (i % 16 != 0)
Expand Down
2 changes: 1 addition & 1 deletion src/core/hooking/CallHook.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace YimMenu
template<typename T>
T GetOriginal()
{
return static_cast<T>(m_OriginalFunction);
return reinterpret_cast<T>(m_OriginalFunction);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/game/features/self/FormatMoney.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ namespace YimMenu::Features
{
if (!formatIntCaller1Hook)
{
formatIntCaller1Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller1, FormatIntHook);
formatIntCaller1Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller1, reinterpret_cast<void*>(FormatIntHook));
}
formatIntCaller1Hook->Enable();
if (!formatIntCaller2Hook)
{
formatIntCaller2Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller2, FormatIntHook);
formatIntCaller2Hook = CallSiteHook::AddHook(Pointers.FormatIntCaller2, reinterpret_cast<void*>(FormatIntHook));
}
formatIntCaller2Hook->Enable();
NativeHooks::AddHook("shop_controller"_J, NativeIndex::SCALEFORM_MOVIE_METHOD_ADD_PARAM_INT, &ScaleformAddIntHook);
Expand Down
4 changes: 2 additions & 2 deletions src/game/frontend/submenus/Debug/Scripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ namespace YimMenu::Submenus

ImGui::Text("Thread ID: %d", curThread->m_Context.m_ThreadId);
ImGui::Text("Stack Size: %d", curThread->m_Context.m_StackSize);
ImGui::Text("Stack Pointer: 0x%X", &curThread->m_Context.m_StackPointer);
ImGui::Text("Program Counter: 0x%X", &curThread->m_Context.m_ProgramCounter); // This is not really accurate (always points to the WAIT)
ImGui::Text("Stack Pointer: 0x%X", curThread->m_Context.m_StackPointer);
ImGui::Text("Program Counter: 0x%X", curThread->m_Context.m_ProgramCounter); // This is not really accurate (always points to the WAIT)
if (curThread->m_Context.m_State == rage::scrThread::State::KILLED)
ImGui::Text("Exit Reason: %s", curThread->m_ErrorMessage);
}));
Expand Down
2 changes: 1 addition & 1 deletion src/game/frontend/submenus/Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "game/frontend/items/Items.hpp"
#include "game/frontend/submenus/Network/SavedPlayers.hpp"
#include "game/gta/Network.hpp"
#include "game/frontend/submenus/Network/RandomEvents.hpp"
#include "game/frontend/submenus/network/RandomEvents.hpp"

namespace YimMenu::Submenus
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/gta/Ped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace YimMenu
ENTITY_ASSERT_VALID();
ENTITY_ASSERT_CONTROL();

WEAPON::SET_PED_INFINITE_AMMO(GetHandle(), infinite, NULL);
WEAPON::SET_PED_INFINITE_AMMO(GetHandle(), infinite, 0);
}

void Ped::SetInfiniteClip(bool infinite)
Expand Down
2 changes: 1 addition & 1 deletion src/game/gta/ScriptLocal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <type_traits>
#include <types/script/scrThread.hpp>
#include <core/util/Joaat.hpp>
#include <src/game/gta/Scripts.hpp>
#include <game/gta/Scripts.hpp>

namespace YimMenu
{
Expand Down
2 changes: 1 addition & 1 deletion src/game/gta/data/ScriptNames.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace YimMenu
{
static constexpr std::array scriptNames = {
static constexpr const char* scriptNames[] = {
"abigail1",
"abigail2",
"achievement_controller",
Expand Down
1 change: 0 additions & 1 deletion src/game/hooks/Anticheat/QueueDependency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ namespace YimMenu::Hooks

if (arx_score >= 2)
{
auto from_offset = *reinterpret_cast<std::uint64_t*>(_AddressOfReturnAddress()) - ModuleMgr.Get("GTA5_Enhanced.exe"_J)->Base();
return;
}

Expand Down
1 change: 1 addition & 0 deletions src/types/network/netEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace rage
std::uint32_t m_CxnId; // 0x0044
rage::netEvent* m_This; // 0x0048
uint32_t m_PeerId; // 0x0050
char pad_0084[4]; // 0x0054
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder why GCC wants padding here. Might be a compiler bug

};
static_assert(sizeof(rage::netEvent) == 0x58);

Expand Down
4 changes: 4 additions & 0 deletions src/types/network/netGameEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,10 @@ class CExplosionEvent : public rage::netGameEvent
public:
void Deserialize(rage::datBitBuffer& buffer);

#if !__GNUC__
struct
{
#endif
ExplosionType m_ExplosionType; // 0x30
rage::fvector3 m_Position; // 0x40
uint64_t m_0x50; // 0x50
Expand Down Expand Up @@ -282,7 +284,9 @@ class CExplosionEvent : public rage::netGameEvent
bool m_Expected; // 0xC2 -- for telemetry
uint32_t m_ScriptHash; // 0xC4 -- for telemetry
uint32_t m_ProgramCounter; // 0xC8 -- for telemetry
#if !__GNUC__
};
#endif
uint16_t m_TargetEntity; // 0xD0
uint16_t m_TargetEnt2; // 0xD2
uint16_t m_OwnerNetId; // 0xD4
Expand Down
2 changes: 1 addition & 1 deletion src/types/rage/RTTI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ private: \
virtual bool _0x28(void**) = 0; \
virtual void destructor() = 0; \
\
public:
public:
2 changes: 1 addition & 1 deletion src/types/rage/datBitBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace rage
v11 = 8;
if (size > 8)
{
v12 = 1i64;
v12 = 1;
do
{
if (v12 > v9)
Expand Down