BUILD: Add the original LDFLAGS and sanitizer LDFLAGS to PLUGIN_LDFLAGS

Adding the sanitizer flags to the PLUGIN_LDFLAGS fixes link errors
for the plugins when asan, tsan, or ubsan is enabled.

Adding the original LDFLAGS to PLUGIN_LDFLAGS means we no longer needs
to use both in the link command for plugins.
This commit is contained in:
Thierry Crozat 2022-05-22 23:54:32 +01:00
parent 0f5dd7cd99
commit 4d2bd56cd2
2 changed files with 8 additions and 3 deletions

9
configure vendored
View file

@ -46,6 +46,7 @@ SAVED_WINDRESFLAGS=$WINDRESFLAGS
# Use environment vars if set # Use environment vars if set
CXXFLAGS="$CXXFLAGS $CPPFLAGS" CXXFLAGS="$CXXFLAGS $CPPFLAGS"
PLUGIN_LDFLAGS=$LDFLAGS
# Backslashes into forward slashes: # Backslashes into forward slashes:
# The following OS/2 specific code is performed to deal with handling of backslashes by ksh. # The following OS/2 specific code is performed to deal with handling of backslashes by ksh.
@ -977,7 +978,7 @@ Optional Libraries:
--with-ieee1284-prefix=DIR prefix where libieee1284 is installed (optional) --with-ieee1284-prefix=DIR prefix where libieee1284 is installed (optional)
--enable-opl2lpt enable OPL2LPT support --enable-opl2lpt enable OPL2LPT support
--with-retrowave-prefix=DIR prefix where libretrowave is installed (optional) --with-retrowave-prefix=DIR prefix where libretrowave is installed (optional)
--enable-retrowave enable RetroWave OPL3 support --enable-retrowave enable RetroWave OPL3 support
@ -4201,7 +4202,7 @@ POST_OBJS_FLAGS := -Wl,-no-whole-archive
append_var DEFINES "-DUNCACHED_PLUGINS" append_var DEFINES "-DUNCACHED_PLUGINS"
_mak_plugins=' _mak_plugins='
LDFLAGS += -Wl,-T$(srcdir)/backends/plugins/psp/main_prog.ld -Wl,-zmax-page-size=128 LDFLAGS += -Wl,-T$(srcdir)/backends/plugins/psp/main_prog.ld -Wl,-zmax-page-size=128
PLUGIN_LDFLAGS += -Wl,-T$(srcdir)/backends/plugins/psp/plugin.ld -Wl,-zmax-page-size=128 -lstdc++ PLUGIN_LDFLAGS += -Wl,-T$(srcdir)/backends/plugins/psp/plugin.ld -Wl,-zmax-page-size=128 -lstdc++
' '
;; ;;
*) *)
@ -5988,6 +5989,7 @@ if test "$_enable_asan" = yes ; then
else else
append_var CXXFLAGS "-fsanitize=address -fno-omit-frame-pointer" append_var CXXFLAGS "-fsanitize=address -fno-omit-frame-pointer"
append_var LDFLAGS "-fsanitize=address -fno-omit-frame-pointer" append_var LDFLAGS "-fsanitize=address -fno-omit-frame-pointer"
append_var PLUGIN_LDFLAGS "-fsanitize=address -fno-omit-frame-pointer"
fi fi
fi fi
echo "$_enable_asan" echo "$_enable_asan"
@ -5997,6 +5999,7 @@ echo_n "Enabling Thread Sanitizer... "
if test "$_enable_tsan" = yes ; then if test "$_enable_tsan" = yes ; then
append_var CXXFLAGS "-fsanitize=thread" append_var CXXFLAGS "-fsanitize=thread"
append_var LDFLAGS "-fsanitize=thread" append_var LDFLAGS "-fsanitize=thread"
append_var PLUGIN_LDFLAGS "-fsanitize=thread"
fi fi
echo "$_enable_tsan" echo "$_enable_tsan"
@ -6005,6 +6008,7 @@ echo_n "Enabling Undefined Behavior Sanitizer... "
if test "$_enable_ubsan" = yes ; then if test "$_enable_ubsan" = yes ; then
append_var CXXFLAGS "-fsanitize=undefined" append_var CXXFLAGS "-fsanitize=undefined"
append_var LDFLAGS "-fsanitize=undefined" append_var LDFLAGS "-fsanitize=undefined"
append_var PLUGIN_LDFLAGS "-fsanitize=undefined"
fi fi
echo "$_enable_ubsan" echo "$_enable_ubsan"
@ -6314,6 +6318,7 @@ OBJS += $OBJS
DEFINES += $DEFINES DEFINES += $DEFINES
LDFLAGS += $LDFLAGS LDFLAGS += $LDFLAGS
PLUGIN_LDFLAGS += $PLUGIN_LDFLAGS
$_mak_plugins $_mak_plugins
port_mk = $_port_mk port_mk = $_port_mk

View file

@ -48,7 +48,7 @@ ifdef PLUGIN
PLUGIN-$(MODULE) := plugins/$(PLUGIN_PREFIX)$(notdir $(MODULE))$(PLUGIN_SUFFIX) PLUGIN-$(MODULE) := plugins/$(PLUGIN_PREFIX)$(notdir $(MODULE))$(PLUGIN_SUFFIX)
$(PLUGIN-$(MODULE)): $(MODULE_OBJS-$(MODULE)) $(PLUGIN_EXTRA_DEPS) $(PLUGIN-$(MODULE)): $(MODULE_OBJS-$(MODULE)) $(PLUGIN_EXTRA_DEPS)
$(QUIET)$(MKDIR) plugins $(QUIET)$(MKDIR) plugins
+$(QUIET_PLUGIN)$(LD) $(SAVED_LDFLAGS) $(filter-out $(PLUGIN_EXTRA_DEPS),$+) $(PLUGIN_LDFLAGS) -o $@ +$(QUIET_PLUGIN)$(LD) $(filter-out $(PLUGIN_EXTRA_DEPS),$+) $(PLUGIN_LDFLAGS) -o $@
# Reset PLUGIN var # Reset PLUGIN var
PLUGIN:= PLUGIN:=