Force linking of .obj files not directly referenced

This commit is contained in:
Magnus Norddahl 2025-01-05 09:09:00 +01:00
commit c7e1eb5f78
10 changed files with 40 additions and 0 deletions

View file

@ -52,6 +52,8 @@
#include <zmusic.h>
#include "filereadermusicinterface.h"
void LinkMoviePlayer() { }
class MoviePlayer
{
protected:

View file

@ -40,6 +40,7 @@
time_t epochoffset = 0; // epoch start in seconds (0 = January 1st, 1970)
void LinkDate() { }
//==========================================================================
//

View file

@ -81,6 +81,28 @@ AUTOSEG_VARIABLE(CVarDecl, AUTOSEG_VREG)
#undef AUTOSEG_STOP
#undef AUTOSEG_START
void LinkVMThunksActors();
void LinkVMIterators();
void LinkDynArrays();
void LinkMaps();
void LinkDate();
void LinkPPShader();
void LinkMoviePlayer();
void LinkPlayermenu();
void LinkUnreferencedZScriptGlobals()
{
// The linker in C++ only links .obj files from static libraries that it can find direct references to.
// Some source files contain no external references so we have to force the linkage.
LinkVMThunksActors();
LinkVMIterators();
LinkDynArrays();
LinkMaps();
LinkDate();
LinkPPShader();
LinkMoviePlayer();
LinkPlayermenu();
}
void FAutoSeg::Initialize()
{

View file

@ -23,6 +23,8 @@
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
#include "hwrenderer/postprocessing/hw_postprocess.h"
void LinkPPShader() { }
static void ShaderSetEnabled(const FString &shaderName, bool value)
{
for (unsigned int i = 0; i < PostProcessShaders.Size(); i++)

View file

@ -39,6 +39,8 @@
#include "types.h"
#include "v_draw.h"
void LinkDynArrays() { }
// We need one specific type for each of the 8 integral VM types and instantiate the needed functions for each of them.
// Dynamic arrays cannot hold structs because for every type there'd need to be an internal implementation which is impossible.

View file

@ -6,6 +6,7 @@
#include "v_draw.h"
#include "maps.h"
void LinkMaps() { }
//==========================================================================
//

View file

@ -1,4 +1,6 @@
void LinkUnreferencedZScriptGlobals();
#if defined(WIN32)
#define WIN32_MEAN_AND_LEAN
@ -8,6 +10,7 @@ int I_GameMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdS
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE nothing, LPWSTR cmdline, int nCmdShow)
{
LinkUnreferencedZScriptGlobals();
return I_GameMain(hInstance, nothing, cmdline, nCmdShow);
}
@ -17,6 +20,7 @@ int I_GameMain(int argc, char** argv);
int main(int argc, char** argv)
{
LinkUnreferencedZScriptGlobals();
return I_GameMain(argc, argv);
}

View file

@ -41,6 +41,8 @@
#include "vm.h"
#include "d_player.h"
void LinkPlayermenu() { }
EXTERN_CVAR(Int, team)
EXTERN_CVAR(Float, autoaim)
EXTERN_CVAR(Bool, neverswitchonpickup)

View file

@ -30,6 +30,8 @@
#include "g_levellocals.h"
#include "vm.h"
void LinkVMIterators() { }
//==========================================================================
//
// scriptable thinker iterator

View file

@ -57,6 +57,8 @@
#include "gi.h"
#include "shadowinlines.h"
void LinkVMThunksActors() { }
DVector2 AM_GetPosition();
int Net_GetLatency(int *ld, int *ad);
void PrintPickupMessage(bool localview, const FString &str);