From: Jérôme Benoit Date: Wed, 15 Mar 2017 10:42:43 +0000 (+0100) Subject: TP 13 exo1: Add LTO and GOLD support to the Makefile build options X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=25dc671f8b36ed62a1d2b689347902a122493782;p=TD_C.git TP 13 exo1: Add LTO and GOLD support to the Makefile build options Signed-off-by: Jérôme Benoit --- diff --git a/TP_11/exo2/Makefile b/TP_11/exo2/Makefile index 73f0988..d1ca467 100644 --- a/TP_11/exo2/Makefile +++ b/TP_11/exo2/Makefile @@ -50,7 +50,7 @@ OPTI_FLAG = -O3 endif # Putting header files in the source directory is not the purpose of this INCLUDES variable -INCLUDES := $(INCLUDES) -I$(SRC_PATH) -I$(LIBRARY_PATH) +INCLUDES := $(INCLUDES) -I$(LIBRARY_PATH) CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES) LIBCFLAGS := -fPIC $(CFLAGS) LDFLAGS := $(LDFLAGS) $(STRIP_FLAG) diff --git a/TP_13/exo1/Makefile b/TP_13/exo1/Makefile index fd95878..0e2661f 100644 --- a/TP_13/exo1/Makefile +++ b/TP_13/exo1/Makefile @@ -21,8 +21,8 @@ BINARY_NAME=exo1 SRC_PATH:=src LIBRARY_NAME=libexo1 LIBRARY_PATH:=lib -BUILD_TYPE=debug -#BUILD_TYPE=release +#BUILD_TYPE=debug +BUILD_TYPE=release # ==================================== # DO NOT CHANGE STUFF BEYOND THIS LINE @@ -42,18 +42,31 @@ BUILDDIR := .build/debug DEBUG_FLAG = -g STRIP_FLAG = OPTI_FLAG = -O0 +LTO_SUPPORT = no +GOLD_SUPPORT = no else BUILDDIR := .build/release DEBUG_FLAG = STRIP_FLAG = -s OPTI_FLAG = -O3 +LTO_SUPPORT = yes +GOLD_SUPPORT = yes +endif + +ifeq ($(LTO_SUPPORT),yes) +CFLAGS_LTO = -flto -ffat-lto-objects +LDFLAGS_LTO = -fuse-linker-plugin -flto +endif + +ifeq ($(GOLD_SUPPORT),yes) +LDFLAGS_GOLD = -fuse-ld=gold endif # Putting header files in the source directory is not the purpose of this INCLUDES variable INCLUDES := $(INCLUDES) -I$(LIBRARY_PATH) -CFLAGS := $(CFLAGS) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES) +CFLAGS := $(CFLAGS) $(CFLAGS_LTO) $(WARN_FLAGS) $(STD_FLAG) $(OPTI_FLAG) $(DEBUG_FLAG) $(INCLUDES) LIBCFLAGS := -fPIC $(CFLAGS) -LDFLAGS := $(LDFLAGS) $(STRIP_FLAG) +LDFLAGS := $(LDFLAGS) $(LDFLAGS_LTO) $(LDFLAGS_GOLD) $(STRIP_FLAG) LIBLDFLAGS := -shared $(LDFLAGS) STATICLIBLDFLAGS := -static $(LDFLAGS) LDLIBS := $(LDLIBS) -L$(LIBRARY_PATH) -l$(BINARY_NAME) diff --git a/TP_13/exo1/lib/utils.c b/TP_13/exo1/lib/utils.c index fbd7e01..5139bae 100644 --- a/TP_13/exo1/lib/utils.c +++ b/TP_13/exo1/lib/utils.c @@ -17,7 +17,7 @@ void swap_ptr(void* v1, void* v2) { void handle_prompt_error(int errno) { if (errno != 0) { printf("\nMerci de saisir un nombre entier, exiting\n"); - /* it's somewhat violent but better than looping forever */ + /* it's somewhat violent but better than looping forever */ exit(EXIT_FAILURE); } }