OpenBlas cross compile for Cortex-M4

290 views
Skip to first unread message

Florian Kelber

unread,
Jul 22, 2016, 11:10:09 AM7/22/16
to OpenBLAS-users
Greetings,

I'm trying to cross compile OpenBlas for ARMV7 Cortex-M4F on Gentoo.
Related question: https://groups.google.com/forum/#!topic/openblas-users/LOsILNVmz7s

It seems like arm-none-eabi-gcc tries to compile axpy.c which contains the glib header sys/mman.h which, as far as I know, does not exist for arm-none-eabi since glibc needs an OS (e.g. Linux).
I tried to compile with different -m flags in Makefile.arm and with the default ones. Both throw the same fatal error: sys/mman.h: No such file or directory. I had no problem compiling for my x86 architecture.
The Openblas version is v0.2.18.
Is it possible to compile for the Cortex-M4F architecture ?

I'm grateful for any help I can get.

Thanks in advance !

-------------------------------------------------------------------------------------------

Build command:
make BINARY=32 CC=arm-none-eabi-gcc FC=arm-none-eabi-gfortran HOSTCC=gcc TARGET=ARMV7

Build log:
make[1]: warning: -jN forced in submake: disabling jobserver mode.                                                                                                                                                    
make
[1]: Entering directory '/home/kelber/software/OpenBLAS/interface'          
arm
-none-eabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard -DASMNAME=saxpy -DASMFNAME=saxpy_ -DNAME=saxpy_ -DCNAME=saxpy -DCHAR_NAME=\"saxpy_\" -DCHAR_CNAME=\"saxpy\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c axpy.c -o saxpy.o
arm-none-eabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard -DASMNAME=sswap -DASMFNAME=sswap_ -DNAME=sswap_ -DCNAME=sswap -DCHAR_NAME=\"sswap_\" -DCHAR_CNAME=\"sswap\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c swap.c -o sswap.o
arm-none-eabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard -DASMNAME=scopy -DASMFNAME=scopy_ -DNAME=scopy_ -DCNAME=scopy -DCHAR_NAME=\"scopy_\" -DCHAR_CNAME=\"scopy\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c copy.c -o scopy.o
arm-none-eabi-gcc -O2 -DMAX_STACK_ALLOC=2048 -Wall -DF_INTERFACE_GFORT -fPIC -DSMP_SERVER -DNO_WARMUP -DMAX_CPU_NUMBER=4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard -DASMNAME=sscal -DASMFNAME=sscal_ -DNAME=sscal_ -DCNAME=sscal -DCHAR_NAME=\"sscal_\" -DCHAR_CNAME=\"sscal\" -DNO_AFFINITY -I.. -I. -UDOUBLE  -UCOMPLEX -c scal.c -o sscal.o
In file included from swap.c:40:0:                                              
../common.h:120:22: fatal error: sys/mman.h: No such file or directory          
 #include <sys/mman.h>                                                          
                      ^                                                        
In file included from axpy.c:40:0:                                              
../common.h:120:22: fatal error: sys/mman.h: No such file or directory          
 #include <sys/mman.h>                                                          
                      ^                                                        
compilation terminated.                                                        
compilation terminated.                                                        
Makefile:723: recipe for target 'saxpy.o' failed                                
make[1]: *** [saxpy.o] Error 1                                                  
make[1]: *** Waiting for unfinished jobs....                                    
Makefile:795: recipe for target 'sswap.o' failed                                
make[1]: *** [sswap.o] Error 1                                                  
In file included from copy.c:40:0:                                              
../common.h:120:22: fatal error: sys/mman.h: No such file or directory          
 #include <sys/mman.h>                                                          
                      ^                                                        
compilation terminated.                                                        
Makefile:777: recipe for target 'scopy.o' failed                                
make[1]: *** [scopy.o] Error 1                                                  
In file included from scal.c:40:0:                                              
../common.h:120:22: fatal error: sys/mman.h: No such file or directory          
 #include <sys/mman.h>                                                          
                      ^                                                        
compilation terminated.                                                        
Makefile:750: recipe for target 'sscal.o' failed                                
make[1]: *** [sscal.o] Error 1                                                  
make[1]: Leaving directory '/home/kelber/software/OpenBLAS/interface'          
Makefile:137: recipe for target 'libs' failed                                  
make: *** [libs] Error 1    


Excerpt from Makefile.arm:
ifeq ($(CORE), ARMV7)                                                          
ifeq
($(OSNAME), Android)                                                      
CCOMMON_OPT
+= -marm -mfpu=neon  -mfloat-abi=hard -march=armv7-a -Wl,--no-warn-mismatch
FCOMMON_OPT
+= -marm -mfpu=neon  -mfloat-abi=hard -march=armv7-a -Wl,--no-warn-mismatch
else                                                                            
CCOMMON_OPT
+= -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard          
FCOMMON_OPT
+= -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard          
# CCOMMON_OPT += -marm -mfpu=vfpv3  -mfloat-abi=hard -march=armv7-a            
# FCOMMON_OPT += -marm -mfpu=vfpv3  -mfloat-abi=hard -march=armv7-a            
endif                                                                          
endif


Florian Kelber

unread,
Jul 22, 2016, 11:23:24 AM7/22/16
to OpenBLAS-users
Maybe another useful information: I don't want to run OpenBlas on top of an Operating System but as a static library for a small C program running without OS.
Reply all
Reply to author
Forward
0 new messages