From 3fdd7328a2f901db16305827ad664abc7736cd83 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Jan 2021 06:41:28 -0800 Subject: build: support linker flags/libs separation. Our build system lumps all linker options together. The correct way is that linker flags are separated info flags and libs. Also, we respond to the LDFLAGS variable but ignore LDLIBS which is incorrect. Other issues are fixed. All that is fixed here. * Makefile (TXR_CFLAGS): Interpolate $(CFLAGS) last, so that options coming from CFLAGS can override previous options. (TXR_LDFLAGS): Interpolate $(LDFLAGS) last; same reason. (TXR_LDLIBS): New variable. (LINK_PROG): Put $(TXR_LDFLAGS) with the options, before the -o, and put $(TXR_LDLIBS) at the end. * configure (conf_ldlibs, platform_ldlibs): New variables. (usage text): Document platform-ldlibs and adjust documentation of platform-ldflags. (gen_config_make): Generate PLATFORM_LDLIBS and CONF_LDLIBS now needed by Makefile. (mainline): Adjusts various recipes to use conf_ldlibs instead of conf_ldflags, or in some cases both. In the case of libffi where we use pkg-config, we use the special pgk-config options to separately extract the flags and libs. We use EXTRA_LDLIBS instead of EXTRA_LDFLAGS in some conftest invocations, as necessary. --- Makefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 35f95b5c..1c67c488 100644 --- a/Makefile +++ b/Makefile @@ -29,13 +29,12 @@ -include config.make VERBOSE := -TXR_CFLAGS := $(CFLAGS) -TXR_CFLAGS += -iquote . $(if $(top_srcdir), -iquote $(top_srcdir)) \ +TXR_CFLAGS := -iquote . $(if $(top_srcdir), -iquote $(top_srcdir)) \ $(LANG_FLAGS) $(DIAG_FLAGS) \ - $(DBG_FLAGS) $(PLATFORM_CFLAGS) $(EXTRA_FLAGS) + $(DBG_FLAGS) $(PLATFORM_CFLAGS) $(EXTRA_FLAGS) $(CFLAGS) TXR_CFLAGS := $(filter-out $(REMOVE_FLAGS),$(TXR_CFLAGS)) -TXR_LDFLAGS := $(LDFLAGS) -TXR_LDFLAGS += -lm $(CONF_LDFLAGS) $(PLATFORM_LDFLAGS) $(EXTRA_LDFLAGS) +TXR_LDFLAGS := $(CONF_LDFLAGS) $(PLATFORM_LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS) +TXR_LDLIBS := -lm $(CONF_LDLIBS) $(PLAFORM_LDLIBS) $(EXTRA_LDLIBS) $(LDLIBS) ifneq ($(subst g++,@,$(notdir $(TXR_CC))),$(notdir $(TXR_CC))) TXR_CFLAGS := $(filter-out -Wmissing-prototypes -Wstrict-prototypes,$(TXR_CFLAGS)) @@ -139,7 +138,7 @@ endef define LINK_PROG $(call ABBREVN,LINK) -$(call SH,$(TXR_CC) $(1) $(TXR_CFLAGS) -o $@ $^ $(TXR_LDFLAGS)) +$(call SH,$(TXR_CC) $(1) $(TXR_CFLAGS) $(TXR_LDFLAGS) -o $@ $^ $(TXR_LDLIBS)) endef define WINDRES -- cgit v1.2.3