From 1b2b20b07d2b2d0386f5cb037621b20467a2b653 Mon Sep 17 00:00:00 2001 From: Jiaqing Zhao Date: Fri, 12 May 2023 09:27:49 +0000 Subject: [PATCH] misc: life_mngr: skip windows build if LDFLAGS contains -z option Linker option "-z,relro" will be automatically added to LDFLAGS when building debian packages. Since x86_64-w64-mingw32-ld does not support "-z" option, it causes failure in building the life_mngr windows exe. And compared with ld, only "-z" option is not supported. This patch fixes it by skipping the windows build of life_mngr if LDFLAGS contains any "-z" option. Tracked-On: #8399 Signed-off-by: Jiaqing Zhao Reviewed-by: Junjie Mao --- misc/services/life_mngr/Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/misc/services/life_mngr/Makefile b/misc/services/life_mngr/Makefile index f64fc8130..1ecd6220e 100644 --- a/misc/services/life_mngr/Makefile +++ b/misc/services/life_mngr/Makefile @@ -40,6 +40,7 @@ LIFEMNGR_LDFLAGS += $(LDFLAGS) # set cross compiler for Windows MINGWIN_CC := x86_64-w64-mingw32-gcc +MINGWIN_LD := x86_64-w64-mingw32-ld CONF_DIR = $(sysconfdir)/life_mngr LM_C_SRCS += monitor.c @@ -63,13 +64,15 @@ all-linux: life_mngr.service # only build for Windows if cross compiler is installed all-win: -ifneq ($(shell which $(MINGWIN_CC)),) +ifeq ($(shell which $(MINGWIN_CC)),) + @echo "WARN: $(MINGWIN_CC) not installed, skipping life_mngr_win.exe" >&2 +else ifneq ($(findstring -z,$(LDFLAGS)),) + @echo "WARN: $(MINGWIN_LD) does not support -z option, skipping life_mngr_win.exe" >&2 +else $(MINGWIN_CC) -g life_mngr_win.c -o $(OUT_DIR)/life_mngr_win.exe -Wall -O2 $(LDFLAGS) -lwsock32 cp COPYING.MinGW-w64-runtime.txt $(OUT_DIR)/COPYING.MinGW-w64-runtime.txt cp s5_trigger_win.py $(OUT_DIR)/s5_trigger_win.py cp system_reboot_trigger_win.py $(OUT_DIR)/system_reboot_trigger_win.py -else - @echo "WARN: $(MINGWIN_CC) not installed, skipping life_mngr_win.exe" >&2 endif clean: