1*4882a593SmuzhiyunFrom 4d3829fa52240c2b7e48770ab19584db33ba7863 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> 3*4882a593SmuzhiyunDate: Fri, 5 Mar 2021 11:17:59 +0100 4*4882a593SmuzhiyunSubject: [PATCH] Makefile: fix support for passing FFLAGS on the make 5*4882a593Smuzhiyun command line 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunWhen openblas is built while passing FFLAGS on the make command line, the 8*4882a593Smuzhiyuncompilation of lapack objects will not contain the flags specified in 9*4882a593SmuzhiyunMakefile but _only_ those passed in FFLAGS. 10*4882a593Smuzhiyun 11*4882a593SmuzhiyunThis can lead to build failure, e.g. because -fPIC is not passed to the 12*4882a593Smuzhiyuncompilation of most lapack objects, but is given to the link command: 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun.../buildroot/output/host/bin/x86_64-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -O2 -DMAX_STACK_ALLOC=2048 -Wall -m64 -DF_INTERFACE_GFORT -fPIC -DNO_WARMUP -DMAX_CPU_NUMBER=4 -DMAX_PARALLEL_NUMBER=1 -DVERSION=\"0.3.9\" -DASMNAME= -DASMFNAME=_ -DNAME=_ -DCNAME= -DCHAR_NAME=\"_\" -DCHAR_CNAME=\"\" -DNO_AFFINITY -I.. -shared -o ../libopenblas_nehalem-r0.3.9.so \ 15*4882a593Smuzhiyun-Wl,--whole-archive ../libopenblas_nehalem-r0.3.9.a -Wl,--no-whole-archive \ 16*4882a593Smuzhiyun-Wl,-soname,libopenblas.so.0 -lm -lgfortran -lm -lgfortran 17*4882a593Smuzhiyun.../buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-musl/9.3.0/../../../../x86_64-buildroot-linux-musl/bin/ld: ../libopenblas_nehalem-r0.3.9.a(sbdsvdx.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC 18*4882a593Smuzhiyun 19*4882a593SmuzhiyunIn the initial support for this principle, added in commit 20*4882a593Smuzhiyund0e731e8b825e7a554f245aa8f1118dcec9e2728, the flags specified in the 21*4882a593Smuzhiyunmakefile were appended to the flags specified on the command-line. 22*4882a593Smuzhiyun 23*4882a593SmuzhiyunFix this situation by using 'override' for 'FFLAGS' in 24*4882a593Smuzhiyunlapack-netlib/make.inc. The flags passed on the command-line are already 25*4882a593Smuzhiyunpart of the LAPACK_FFLAGS variable, so no '+=' is needed here. 26*4882a593Smuzhiyun 27*4882a593SmuzhiyunSigned-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> 28*4882a593Smuzhiyun--- 29*4882a593Smuzhiyun Makefile | 2 +- 30*4882a593Smuzhiyun 1 file changed, 1 insertion(+), 1 deletion(-) 31*4882a593Smuzhiyun 32*4882a593Smuzhiyundiff --git a/Makefile b/Makefile 33*4882a593Smuzhiyunindex fc5fe3f5..8ae1ff47 100644 34*4882a593Smuzhiyun--- a/Makefile 35*4882a593Smuzhiyun+++ b/Makefile 36*4882a593Smuzhiyun@@ -248,7 +248,7 @@ prof_lapack : lapack_prebuild 37*4882a593Smuzhiyun lapack_prebuild : 38*4882a593Smuzhiyun ifeq ($(NOFORTRAN), $(filter 0,$(NOFORTRAN))) 39*4882a593Smuzhiyun -@echo "FC = $(FC)" > $(NETLIB_LAPACK_DIR)/make.inc 40*4882a593Smuzhiyun- -@echo "FFLAGS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc 41*4882a593Smuzhiyun+ -@echo "override FFLAGS = $(LAPACK_FFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc 42*4882a593Smuzhiyun -@echo "POPTS = $(LAPACK_FPFLAGS)" >> $(NETLIB_LAPACK_DIR)/make.inc 43*4882a593Smuzhiyun -@echo "FFLAGS_NOOPT = -O0 $(LAPACK_NOOPT)" >> $(NETLIB_LAPACK_DIR)/make.inc 44*4882a593Smuzhiyun -@echo "PNOOPT = $(LAPACK_FPFLAGS) -O0" >> $(NETLIB_LAPACK_DIR)/make.inc 45*4882a593Smuzhiyun-- 46*4882a593Smuzhiyun2.26.2 47*4882a593Smuzhiyun 48