Rebased version of previous patch below.
----
From 05c96dad9b26cc1f00831661dc55139dcc9d5680 Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <michael@orlitzky.com>
Date: Thu, 11 Jun 2020 18:32:17 -0400
Subject: [PATCH 1/1] Makefile: don't clobber fortran flags while building
 lapack.

When a user has the FFLAGS environment variable set, it clobbers the
flags used to compile lapack. This can lead to "rare and hard to
reproduce crashes" or test failures, as we have observed in Gentoo.

Issue: https://github.com/xianyi/OpenBLAS/issues/2657
diff --git a/Makefile b/Makefile
index e113026..dd8b655 100644
--- a/Makefile
+++ b/Makefile
@@ -263,7 +263,7 @@ prof_lapack : lapack_prebuild
 lapack_prebuild :
 ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN)))
 	-@echo "FC          = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc
-	-@echo "FFLAGS      = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
+	-@echo "override FFLAGS      = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
 	-@echo "FFLAGS_DRV  = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
 	-@echo "POPTS       = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc
 	-@echo "FFLAGS_NOOPT       = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc
