Skip to content

Commit

Permalink
Disable GCC optimization that prevents mod dlls from unloading after …
Browse files Browse the repository at this point in the history
…engine calls dlclose
  • Loading branch information
SamVanheer committed Dec 13, 2023
1 parent fae5e01 commit 6ed0e67
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6ed0e67

Please sign in to comment.