From 24bde5c90de9fe1f6dac426dbe19d1cc38aa2070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalrish=20B=C3=A4akjen?= Date: Tue, 1 Aug 2017 15:32:12 +0200 Subject: [PATCH 1/5] Support specifying CFLAGS in tup.config If CONFIG_CFLAGS is specified in tup.config, then its value is used as our CFLAGS. Otherwise, we provide sensible defaults. Flags which are needed in any case, such as include paths, are added unconditionally. --- Tuprules.tup | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/Tuprules.tup b/Tuprules.tup index 1a18aa842..18fdd336c 100644 --- a/Tuprules.tup +++ b/Tuprules.tup @@ -12,23 +12,13 @@ else CC = gcc endif -ifeq (@(TUP_DEBUG),y) -CFLAGS += -g -else -CFLAGS += -Os -endif - -ifdef AR -AR = @(AR) +CFLAGS += -D_FILE_OFFSET_BITS=64 +CFLAGS += -I$(TUP_CWD)/src +ifdef CFLAGS +CFLAGS += @(CFLAGS) else -AR = ar -endif - CFLAGS += -W CFLAGS += -Wall -ifeq (@(TUP_WERROR),y) -CFLAGS += -Werror -endif CFLAGS += -Wbad-function-cast CFLAGS += -Wcast-align CFLAGS += -Wcast-qual @@ -42,12 +32,13 @@ CFLAGS += -Wstrict-prototypes CFLAGS += -Wwrite-strings CFLAGS += -Wswitch-enum CFLAGS += -fno-common -CFLAGS += -D_FILE_OFFSET_BITS=64 -CFLAGS += -I$(TUP_CWD)/src +CFLAGS += -O2 +endif -ifeq (@(TUP_32_BIT),y) -CFLAGS += -m32 -LDFLAGS += -m32 +ifdef AR +AR = @(AR) +else +AR = ar endif export PKG_CONFIG_PATH From c1f9c7773730600c083aaaec0c55695f0ca7e44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalrish=20B=C3=A4akjen?= Date: Tue, 1 Aug 2017 15:37:14 +0200 Subject: [PATCH 2/5] Support specifying LDFLAGS in tup.config --- Tuprules.tup | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tuprules.tup b/Tuprules.tup index 18fdd336c..519e25fb9 100644 --- a/Tuprules.tup +++ b/Tuprules.tup @@ -35,6 +35,10 @@ CFLAGS += -fno-common CFLAGS += -O2 endif +ifdef LDFLAGS +LDFLAGS += @(LDFLAGS) +endif + ifdef AR AR = @(AR) else From 5f2b91f66c8f2d3b547c63f99d80926a1fbe0d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalrish=20B=C3=A4akjen?= Date: Tue, 1 Aug 2017 15:38:51 +0200 Subject: [PATCH 3/5] configs: Add GCC development config template This template should be a good starting point for those wanting to develop tup. Many diagnostics are enabled, warnings are considered errors, debug information is included and an optimization level which doesn't interfere with debugging is specified. --- configs/gcc-dev.config | 1 + 1 file changed, 1 insertion(+) create mode 100644 configs/gcc-dev.config diff --git a/configs/gcc-dev.config b/configs/gcc-dev.config new file mode 100644 index 000000000..ab2811b8f --- /dev/null +++ b/configs/gcc-dev.config @@ -0,0 +1 @@ +CONFIG_CFLAGS=-W -Wall -Wextra -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings -Wswitch-enum -Werror -fno-common -g -Og From e20b7a5f0c76ad1b4cb6dd8492e3af6fa3d4a8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalrish=20B=C3=A4akjen?= Date: Tue, 1 Aug 2017 15:42:02 +0200 Subject: [PATCH 4/5] configs: Add GCC release config template This template should be a good starting point for those wanting to get a release build of tup. Basic diagnostics are enabled to help catch errors, but the compiler shouldn't otherwise be very strict with these settings. An intermediate optimization level is set. --- configs/gcc-release.config | 1 + 1 file changed, 1 insertion(+) create mode 100644 configs/gcc-release.config diff --git a/configs/gcc-release.config b/configs/gcc-release.config new file mode 100644 index 000000000..72944f41e --- /dev/null +++ b/configs/gcc-release.config @@ -0,0 +1 @@ +CONFIG_CFLAGS=-Wall -fno-common -O2 From 8405f903ecbb232eb6ae214d09682e69ffd1c82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kalrish=20B=C3=A4akjen?= Date: Tue, 1 Aug 2017 16:07:19 +0200 Subject: [PATCH 5/5] configs: Add GCC development LTO config template Like gcc-dev.config, this template should be useful to those wanting to develop tup. The difference in this one is the use of LTO, which can help uncover errors in the code. At least here, tup did not build with these settings; presumably, there's something to fix, and this template is a step in that direction. --- configs/gcc-dev-lto.config | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 configs/gcc-dev-lto.config diff --git a/configs/gcc-dev-lto.config b/configs/gcc-dev-lto.config new file mode 100644 index 000000000..27da74499 --- /dev/null +++ b/configs/gcc-dev-lto.config @@ -0,0 +1,3 @@ +CONFIG_CFLAGS=-W -Wall -Wextra -Wbad-function-cast -Wcast-align -Wcast-qual -Wchar-subscripts -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings -Wswitch-enum -Werror -flto -fno-common -g -Og +CONFIG_AR=gcc-ar +CONFIG_LDFLAGS=-flto -fuse-linker-plugin