From 6ed0e670000a1b04364f5b4a9bab5ce78d366144 Mon Sep 17 00:00:00 2001 From: Sam V Date: Wed, 13 Dec 2023 20:03:44 +0100 Subject: [PATCH] Disable GCC optimization that prevents mod dlls from unloading after engine calls dlclose --- linux/Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linux/Makefile b/linux/Makefile index a566758..47aa76e 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -43,9 +43,12 @@ BASE_CFLAGS=-std=c++17 -fpermissive -fno-strict-aliasing -fno-exceptions -fexpen BASE_CFLAGS+=-DNDEBUG -DPOSIX -D_POSIX -DLINUX -D_LINUX -DGNUC -DNO_MALLOC_OVERRIDE -DCLIENT_WEAPONS # flifetime-dse=1 is needed to disable a compiler optimization that optimizes out std::memset calls in CBaseEntity::operator new -# See https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flifetime-dse for more information about the flifetime-dse flag +# See https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-flifetime-dse for more information about this flag +# fno-gnu-unique is needed to disable a compiler optimization that prevents dlclose from unloading mod dlls, +# causing them to retain state and crash when the engine tries to access memory in an invalid way +# See https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-gnu-unique for more informatio about this flag ifeq "$(COMPILER)" "g++" - BASE_CFLAGS+=-flifetime-dse=1 + BASE_CFLAGS+=-flifetime-dse=1 -fno-gnu-unique endif SHLIBEXT=so