From 296af1ce268c943f6a2b884409efcb1d2571867d Mon Sep 17 00:00:00 2001
From: Nathaniel Graff <nathaniel.graff@sifive.com>
Date: Mon, 17 Jun 2019 14:44:39 -0700
Subject: Reorder CFLAGS for benchmarks

Add benchmark flags after loading the flags for the configuration so
that the benchmarks can override the configuration's flags.

Signed-off-by: Nathaniel Graff <nathaniel.graff@sifive.com>
---
 scripts/standalone.mk | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/scripts/standalone.mk b/scripts/standalone.mk
index d0740cd..a29bce4 100644
--- a/scripts/standalone.mk
+++ b/scripts/standalone.mk
@@ -50,12 +50,10 @@ endif
 endif
 
 ifeq ($(PROGRAM),coremark)
-ifeq ($(CONFIGURATION),release)
 ifeq ($(LINK_TARGET),)
 LINK_TARGET = ramrodata
 endif
 endif
-endif
 
 ifeq ($(LINK_TARGET),)
 LINK_TARGET = default
@@ -121,6 +119,27 @@ RISCV_CCASFLAGS += --specs=nano.specs
 RISCV_CFLAGS    += --specs=nano.specs
 RISCV_CXXFLAGS  += --specs=nano.specs
 
+# Turn on garbage collection for unused sections
+RISCV_LDFLAGS += -Wl,--gc-sections
+# Turn on linker map file generation
+RISCV_LDFLAGS += -Wl,-Map,$(PROGRAM).map
+# Turn off the C standard library
+RISCV_LDFLAGS += -nostartfiles -nostdlib
+# Find the archive files and linker scripts
+RISCV_LDFLAGS += -L$(sort $(dir $(abspath $(filter %.a,$^)))) -T$(abspath $(filter %.lds,$^))
+
+# Link to the relevant libraries
+RISCV_LDLIBS += -Wl,--start-group -lc -lgcc -lmetal -lmetal-gloss -Wl,--end-group
+
+# Load the configuration Makefile
+CONFIGURATION_FILE = $(wildcard $(CONFIGURATION).mk)
+ifeq ($(words $(CONFIGURATION_FILE)),0)
+$(error Unable to find the Makefile $(CONFIGURATION).mk for CONFIGURATION=$(CONFIGURATION))
+endif
+include $(CONFIGURATION).mk
+
+# Benchmark CFLAGS go after loading the CONFIGURATION so that they can override the optimization level
+
 ifeq ($(PROGRAM),dhrystone)
 ifeq ($(DHRY_OPTION),)
 # Ground rules (default)
@@ -144,25 +163,6 @@ endif
 RISCV_XCFLAGS += -DITERATIONS=$(TARGET_CORE_ITERS)
 endif
 
-# Turn on garbage collection for unused sections
-RISCV_LDFLAGS += -Wl,--gc-sections
-# Turn on linker map file generation
-RISCV_LDFLAGS += -Wl,-Map,$(PROGRAM).map
-# Turn off the C standard library
-RISCV_LDFLAGS += -nostartfiles -nostdlib
-# Find the archive files and linker scripts
-RISCV_LDFLAGS += -L$(sort $(dir $(abspath $(filter %.a,$^)))) -T$(abspath $(filter %.lds,$^))
-
-# Link to the relevant libraries
-RISCV_LDLIBS += -Wl,--start-group -lc -lgcc -lmetal -lmetal-gloss -Wl,--end-group
-
-# Load the configuration Makefile
-CONFIGURATION_FILE = $(wildcard $(CONFIGURATION).mk)
-ifeq ($(words $(CONFIGURATION_FILE)),0)
-$(error Unable to find the Makefile $(CONFIGURATION).mk for CONFIGURATION=$(CONFIGURATION))
-endif
-include $(CONFIGURATION).mk
-
 #############################################################
 # Software
 #############################################################
-- 
cgit v1.2.3