From cd8f8b845bf392efde43b68eaf2ab0f2ba967aa8 Mon Sep 17 00:00:00 2001 From: Avril Date: Sun, 6 Dec 2020 12:38:30 +0000 Subject: [PATCH] update Makefiles --- Makefile | 6 +++--- Makefile.template | 21 +++++++++++++++++++++ common/include/attrs.h | 1 + day3/Makefile | 6 +++++- day3/day3.cpp | 4 +++- day4/Makefile | 2 ++ 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 Makefile.template diff --git a/Makefile b/Makefile index dce53f3..a8b77e7 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ -COMMON_OPT_FLAGS?= -DFROM_MAIN -O3 -march=native -pipe -flto \ +COMMON_OPT_FLAGS?= -DFROM_MAIN -march=native -flto \ -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \ -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \ -fno-stack-check -fno-strict-aliasing C_OPT_FLAGS?= -CXX_OPT_FLAGS?= -felide-constructors +CXX_OPT_FLAGS?= -felide-constructors -fno-exceptions LD_OPT_FLAGS?=-O3 -flto INCLUDE=$(shell pwd)/common/include -COMMON_FLAGS=-Wall -pedantic $(COMMON_OPT_FLAGS) +COMMON_FLAGS=-pipe -O3 -Wall -Wextra -Wstrict-aliasing -pedantic $(COMMON_OPT_FLAGS) CFLAGS+=$(COMMON_FLAGS) --std=gnu11 $(C_OPT_FLAGS) CXXFLAGS+=$(COMMON_FLAGS) --std=gnu++20 $(CXX_OPT_FLAGS) diff --git a/Makefile.template b/Makefile.template new file mode 100644 index 0000000..20f26d3 --- /dev/null +++ b/Makefile.template @@ -0,0 +1,21 @@ + +OPT_FLAGS?= -march=native -flto \ + -march=native -fgraphite -fopenmp -floop-parallelize-all -ftree-parallelize-loops=4 \ + -floop-interchange -ftree-loop-distribution -floop-strip-mine -floop-block \ + -fno-stack-check -fno-strict-aliasing + +COMMON_FLAGS?=-pipe -O3 -Wall -pedantic -Wextra -Wstrict-aliasing + +C_OPT_FLAGS=$(OPT_FLAGS) +CXX_OPT_FLAGS=$(OPT_FLAGS) -felide-constructors -fno-exceptions +LD_OPT_FLAGS?=-O3 -flto + + +CFLAGS?=$(COMMON_FLAGS) $(C_OPT_FLAGS) --std=gnu11 +CXXFLAGS?=$(COMMON_FLAGS) $(CXX_OPT_FLAGS) --std=gnu++20 +LDFLAGS?=$(LD_OPT_FLAGS) + +.PHONY: all +all: part1 part2 + + diff --git a/common/include/attrs.h b/common/include/attrs.h index f1bcda7..fc465ee 100644 --- a/common/include/attrs.h +++ b/common/include/attrs.h @@ -5,6 +5,7 @@ #define noglobal __attribute__((const)) #define noinline __attribute__((noinline)) #define cold __attribute__((cold)) +#define fall __attribute__((fallthrough)) #ifndef DEBUG #define _force_inline __attribute__((gnu_inline)) inline extern diff --git a/day3/Makefile b/day3/Makefile index e37a3a7..15860fe 100644 --- a/day3/Makefile +++ b/day3/Makefile @@ -7,13 +7,17 @@ C_OPT_FLAGS?= CXX_OPT_FLAGS?= -felide-constructors LD_OPT_FLAGS?=-O3 -flto +INCLUDE=../common/include + COMMON_FLAGS=-Wall -pedantic $(COMMON_OPT_FLAGS) CFLAGS?=$(COMMMON_FLAGS) --std=gnu11 $(C_OPT_FLAGS) CXXFLAGS?=$(COMMON_FLAGS) --std=gnu++20 $(CXX_OPT_FLAGS) LDFLAGS?=$(LD_OPT_FLAGS) -CXXFLAGS+= -fno-exceptions + +CXXFLAGS+= -fno-exceptions -I$(INCLUDE) +CFLAGS+= -I$(INCLUDE) .PHONY: all all: part1 part2 diff --git a/day3/day3.cpp b/day3/day3.cpp index 2d1ceaf..1088dc3 100644 --- a/day3/day3.cpp +++ b/day3/day3.cpp @@ -4,6 +4,8 @@ #include #include +#include + using mod_table = std::vector >; mod_table read_input(const char* _input) @@ -25,7 +27,7 @@ mod_table read_input(const char* _input) { switch(chr) { - case '#': ln[i] = true; + case '#': ln[i] = true; fall; default: i++; break; } } diff --git a/day4/Makefile b/day4/Makefile index 5ffbcb6..9c6ed05 100644 --- a/day4/Makefile +++ b/day4/Makefile @@ -11,11 +11,13 @@ all: part1: $(wildcard src/*.rs) cargo build --release $(addprefix --features ,$(CARGO_FEATURE_FLAGS)) mv -f target/release/day4 $@ + strip $@ .NOTPARALLEL: part2 part2: $(wildcard src/*.rs) cargo build --release --features $@ $(addprefix --features ,$(CARGO_FEATURE_FLAGS)) mv -f target/release/day4 $@ + strip $@ clean: rm -f part{1,2}