diff --git a/Makefile b/Makefile index 928a4c4..18f0733 100644 --- a/Makefile +++ b/Makefile @@ -26,33 +26,27 @@ CXX = g++ INCLUDES = -Iinclude OUTPUT = stocksim CXXFLAGS += -Wall -Wextra -pedantic -std=c++17 -Werror -g \ - -Wcast-qual -Wundef -Wswitch -Wshadow -Wold-style-cast + -Wcast-qual -Wundef -Wswitch -Wshadow # -Wconversion -Wfloat-equal # -fsanitize=address -fsanitize=undefined -# MinGW does not support -static-pie ifeq ($(OS),Windows_NT) # -pthread needed for clang++ on Windows ifeq ($(CXX),clang++) -CXXFLAGS += -pthread -endif -CXXFLAGS += -static -else ifeq ($(CXX),g++) -ifeq ($(shell uname),Linux) -CXXFLAGS += -static-pie -fPIE + CXXFLAGS += -pthread endif + CXXFLAGS += -static endif -# Security flags for Linux ifeq ($(shell uname),Linux) ifneq ($(CXX),cosmoc++) -CXXFLAGS += -z noexecstack -z relro -z now + CXXFLAGS += -z relro -z now -static-pie -fPIE endif endif # Clang will warn about unused command line arguments. ifeq ($(CXX),clang++) -CXXFLAGS += -Wno-error=unused-command-line-argument + CXXFLAGS += -Wno-error=unused-command-line-argument endif default: stocksim @@ -139,14 +133,14 @@ endif # -GL can further reduce size, but more likely to flag as malicious msvc: src/*.cpp include/*.h clean - cl -std:c++17 -EHsc -utf-8 -Iinclude -W1 -WX -O1 -guard:cf -MP \ + cl -std:c++17 -EHsc -utf-8 $(INCLUDES) -W1 -WX -O1 -guard:cf -MP \ src/*.cpp -Fe:$(OUTPUT) rm *.obj || true format-check: clang-format --dry-run --Werror src/*.cpp include/*.h clang-tidy src/*.cpp --checks=performance-*,-performance-avoid-endl,readability-*,bugprone-*,portability-*,cert-* \ - --fix-errors --fix-notes --format-style=file -- -Iinclude + --fix-errors --fix-notes --format-style=file -- $(INCLUDES) input-check: echo -e "1\ntest\nX\nY\n" | ./$(OUTPUT) @@ -157,11 +151,11 @@ input-check: # cosmopolitan c++ compiler does not support -flto and stack protector ifeq ($(MAKECMDGOALS),release) ifneq ($(CXX),cosmoc++) -CXXFLAGS += -fstack-protector-strong + CXXFLAGS += -fstack-protector-strong ifneq ($(CXX),clang++) -CXXFLAGS += -flto + CXXFLAGS += -flto else ifneq ($(OS),Windows_NT) -CXXFLAGS += -flto + CXXFLAGS += -flto endif endif endif diff --git a/src/main.cpp b/src/main.cpp index fc1e47d..9fdf2a9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,18 +19,10 @@ program. If not, see . #include "file_io.h" #include "format.h" #include "graph.h" +#include "nonstdlibs/VariadicTable.h" #include "random_price.h" #include "stock.h" -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" -#endif -#include "nonstdlibs/VariadicTable.h" -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - #include #include #include