From e42d9f224a4ef2784f8fd43f9f4f5c593a7ddd57 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Thu, 13 Jun 2013 23:29:07 -0700 Subject: [PATCH] configure: Fully separate CFLAGS/LDFLAGS between fips and libfips The top-level program and the underlying library have fundamentally different requirements. For example, the top-level program needs to link against libtalloc and libelf but the library does not. Previously, the necessary flags for both were mixed together in CONFIGURE_CFLAGS and CONFIGURE_LDFLAGS. This caused the library to unnecessarily link against libtalloc and libelf, (which in turn caused problems since the library is compiled as both 32-bit and 64-bit but the system may not provide both 32- and 64-bit versions of these libraries). By splitting things up into separate FIPS_LDFLAGS vs. LIBFIPS_LDFLAGS, etc. we can keep the dependencies down to what is really required and eliminate several sprious failure cases. --- Makefile.local | 21 ++++++++++++--------- configure | 10 +++++++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/Makefile.local b/Makefile.local index 179700e..7914718 100644 --- a/Makefile.local +++ b/Makefile.local @@ -3,9 +3,12 @@ include Makefile.release # Smash together user's values with our extra values -FINAL_CFLAGS = -DFIPS_VERSION=$(VERSION) $(CFLAGS) $(WARN_CFLAGS) $(CONFIGURE_CFLAGS) $(extra_cflags) -FINAL_FIPS_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(CONFIGURE_LDFLAGS) -FINAL_LIBFIPS_LDFLAGS = $(LDFLAGS) $(CONFIGURE_LDFLAGS) -ldl +FINAL_FIPS_CFLAGS = -DFIPS_VERSION=$(VERSION) $(CFLAGS) $(FIPS_CFLAGS) $(extra_cflags) +FINAL_FIPS_LDFLAGS = $(LDFLAGS) $(AS_NEEDED_LDFLAGS) $(FIPS_LDFLAGS) + +FINAL_LIBFIPS_CFLAGS = $(CFLAGS) $(LIBFIPS_CFLAGS) $(extra_cflags) +FINAL_LIBFIPS_LDFLAGS = $(LDFLAGS) $(LIBFIPS_LDFLAGS) -ldl + FINAL_FIPS_LINKER = CC ALL_TARGETS = fips @@ -55,15 +58,15 @@ quiet ?= $($(shell echo $1 | sed -e s'/ .*//')) %-32.o: %.c $(global_deps) @mkdir -p .deps/$(@D) - $(call quiet,CC $(CFLAGS) -m32) -c $(FINAL_CFLAGS) -m32 $< -o $@ -MD -MP -MF .deps/$*.d + $(call quiet,CC $(CFLAGS) -m32) -c $(FINAL_LIBFIPS_CFLAGS) -m32 $< -o $@ -MD -MP -MF .deps/$*.d %-64.o: %.c $(global_deps) @mkdir -p .deps/$(@D) - $(call quiet,CC $(CFLAGS) -m64) -c $(FINAL_CFLAGS) -m64 $< -o $@ -MD -MP -MF .deps/$*.d + $(call quiet,CC $(CFLAGS) -m64) -c $(FINAL_LIBFIPS_CFLAGS) -m64 $< -o $@ -MD -MP -MF .deps/$*.d %.o: %.c $(global_deps) @mkdir -p .deps/$(@D) - $(call quiet,CC $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d + $(call quiet,CC $(CFLAGS)) -c $(FINAL_FIPS_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d .PHONY : clean clean: @@ -82,7 +85,7 @@ fips_srcs = \ fips_modules = $(fips_srcs:.c=.o) fips: $(fips_modules) - $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS)) $(FINAL_CFLAGS) $^ $(FINAL_FIPS_LDFLAGS) -o $@ + $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS)) $(FINAL_FIPS_CFLAGS) $^ $(FINAL_FIPS_LDFLAGS) -o $@ # GL-wrapper library, libfips LIBRARY_LINK_FLAGS = -shared -Wl,--version-script=libfips.sym @@ -107,10 +110,10 @@ libfips_32_modules = $(libfips_srcs:.c=-32.o) libfips_64_modules = $(libfips_srcs:.c=-64.o) libfips-32.so: $(libfips_32_modules) libfips.sym - $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS) -m32) -o $@ $(FINAL_CFLAGS) -m32 $(libfips_32_modules) $(LIBRARY_LINK_FLAGS) $(FINAL_LIBFIPS_LDFLAGS) + $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS) -m32) -o $@ $(FINAL_LIBFIPS_CFLAGS) -m32 $(libfips_32_modules) $(LIBRARY_LINK_FLAGS) $(FINAL_LIBFIPS_LDFLAGS) libfips-64.so: $(libfips_64_modules) libfips.sym - $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS) -m64) -o $@ $(FINAL_CFLAGS) -m64 $(libfips_64_modules) $(LIBRARY_LINK_FLAGS) $(FINAL_LIBFIPS_LDFLAGS) + $(call quiet,$(FINAL_FIPS_LINKER) $(CFLAGS) -m64) -o $@ $(FINAL_LIBFIPS_CFLAGS) -m64 $(libfips_64_modules) $(LIBRARY_LINK_FLAGS) $(FINAL_LIBFIPS_LDFLAGS) .PHONY: install install: all diff --git a/configure b/configure index c584c93..3a6a597 100755 --- a/configure +++ b/configure @@ -538,9 +538,13 @@ EGL_CFLAGS = ${egl_cflags} # Flags needed to have linker link only to necessary libraries AS_NEEDED_LDFLAGS = ${as_needed_ldflags} -# Combined flags for compiling and linking against all of the above -CONFIGURE_CFLAGS = \$(TALLOC_CFLAGS) \$(LIBELF_CFLAGS) \$(GL_CFLAGS) \$(EGL_CFLAGS) -CONFIGURE_LDFLAGS = \$(TALLOC_LDFLAGS) \$(LIBELF_LDFLAGS) +# Flags needed to compile the fips binary +FIPS_CFLAGS = \$(WARN_CFLAGS) \$(TALLOC_CFLAGS) \$(LIBELF_CFLAGS) +FIPS_LDFLAGS = \$(WARN_CFLAGS) \$(TALLOC_LDFLAGS) \$(LIBELF_LDFLAGS) + +# Flags needed to compile the libfips libraries +LIBFIPS_CFLAGS = \$(GL_CFLAGS) \$(EGL_CFLAGS) +LIBFIPS_LDFLAGS = EOF # construct config.h -- 2.43.0