From 06747e6cffa6beec1b573d7da28735041e7def55 Mon Sep 17 00:00:00 2001 From: abejgonzalez Date: Fri, 21 Aug 2020 17:27:50 -0700 Subject: [PATCH] Dedup simulation flags --- sims/common-sim-flags.mk | 24 ++++++++++++++++++++++++ sims/verilator/Makefile | 24 ++++-------------------- vcs.mk | 21 +++------------------ 3 files changed, 31 insertions(+), 38 deletions(-) create mode 100644 sims/common-sim-flags.mk diff --git a/sims/common-sim-flags.mk b/sims/common-sim-flags.mk new file mode 100644 index 00000000..1c73a510 --- /dev/null +++ b/sims/common-sim-flags.mk @@ -0,0 +1,24 @@ +#---------------------------------------------------------------------------------------- +# common gcc configuration/optimization +#---------------------------------------------------------------------------------------- +SIM_OPT_CXXFLAGS := -O3 + +SIM_CXXFLAGS = \ + $(CXXFLAGS) \ + $(SIM_OPT_CXXFLAGS) \ + -std=c++11 \ + -I$(RISCV)/include \ + -I$(dramsim_dir) \ + -I$(build_dir) \ + $(EXTRA_SIM_CXXFLAGS) + +SIM_LDFLAGS = \ + $(LDFLAGS) \ + -L$(RISCV)/lib \ + -Wl,-rpath,$(RISCV)/lib \ + -L$(sim_dir) \ + -L$(dramsim_dir) \ + -lfesvr \ + -lpthread \ + -ldramsim \ + $(EXTRA_SIM_LDFLAGS) diff --git a/sims/verilator/Makefile b/sims/verilator/Makefile index 3cc7c18b..211b5676 100644 --- a/sims/verilator/Makefile +++ b/sims/verilator/Makefile @@ -141,35 +141,19 @@ VERILATOR_NONCC_OPTS = \ #---------------------------------------------------------------------------------------- # gcc configuration/optimization #---------------------------------------------------------------------------------------- -# -flto slows down compilation on small-memory and breaks on firesim-manager -CXX_OPT_FLAGS := -O3 +include $(base_dir)/sims/common-sim-flags.mk VERILATOR_CXXFLAGS = \ - $(CXXFLAGS) \ + $(SIM_CXXFLAGS) \ $(RUNTIME_PROFILING_CFLAGS) \ $(TRACING_CFLAGS) \ - $(CXX_OPT_FLAGS) \ - -std=c++11 \ -D__STDC_FORMAT_MACROS \ -DTEST_HARNESS=V$(VLOG_MODEL) \ -DVERILATOR \ - -I$(RISCV)/include \ - -I$(dramsim_dir) \ - -I$(build_dir) \ -include $(build_dir)/$(long_name).plusArgs \ - -include $(build_dir)/verilator.h \ - $(EXTRA_SIM_CXXFLAGS) + -include $(build_dir)/verilator.h -VERILATOR_LDFLAGS = \ - $(LDFLAGS) \ - -L$(RISCV)/lib \ - -Wl,-rpath,$(RISCV)/lib \ - -L$(sim_dir) \ - -L$(dramsim_dir) \ - -lfesvr \ - -lpthread \ - -ldramsim \ - $(EXTRA_SIM_LDFLAGS) +VERILATOR_LDFLAGS = $(SIM_LDFLAGS) VERILATOR_CC_OPTS = \ -CFLAGS "$(VERILATOR_CXXFLAGS)" \ diff --git a/vcs.mk b/vcs.mk index a282aa44..c3ba6da6 100644 --- a/vcs.mk +++ b/vcs.mk @@ -14,25 +14,10 @@ RESET_DELAY ?= 777.7 #---------------------------------------------------------------------------------------- # gcc configuration/optimization #---------------------------------------------------------------------------------------- -CXX_OPT_FLAGS := -O3 +include $(base_dir)/sims/common-sim-flags.mk -VCS_CXXFLAGS = \ - $(CXXFLAGS) \ - $(CXX_OPT_FLAGS) \ - -I$(RISCV)/include \ - -I$(dramsim_dir) \ - -std=c++11 \ - $(EXTRA_SIM_CXXFLAGS) - -VCS_LDFLAGS = \ - $(LDFLAGS) \ - -L$(RISCV)/lib \ - -Wl,-rpath,$(RISCV)/lib \ - -L$(sim_dir) \ - -L$(dramsim_dir) \ - -lfesvr \ - -ldramsim \ - $(EXTRA_SIM_LDFLAGS) +VCS_CXXFLAGS = $(SIM_CXXFLAGS) +VCS_LDFLAGS = $(SIM_LDFLAGS) # vcs requires LDFLAGS to not include library names (i.e. -l needs to be separate) VCS_CC_OPTS = \