projectNe10 / Ne10

An open optimized software library project for the ARM® Architecture
Other
1.46k stars 408 forks source link

cross compiling for bare metal #203

Closed talhaber closed 6 years ago

talhaber commented 6 years ago

I am trying to crosscompile the library for bare metal and incountered a issue in the cmake build stage.

I am using a fedora26 64-bit virtual machine. I use the Linaro-7.3.1-2018.05-i686_aarch64-elf toolchain. cmake 2.8.5.

I took the GNUlinux_config.cmake and updated the settings to the linaro toolchain (CMAKE_C_COMPILER, CMAKE_CXX_COMPILER...).

running "cmake -DCMAKE_TOOLCHAIN_FILE=../GNUlinux_config.cmake .." yields an error: "aarch64-elf-gcc: error: unrecognized command line option '-rdynamic'" it seems the cmake takes this flag from: /usr/share/cmake-2.8/Modules/Platform/Linux-GNU.cmake

I tryied following the advice from: https://stackoverflow.com/questions/10599038/can-i-skip-cmake-compiler-tests-or-avoid-error-unrecognized-option-rdynamic

I set in the tool chain file: SET(CMAKE_SYSTEM_NAME Generic) but but I still see this flag.

where in the library the cmake choose the cmake configuration file (why did it go to Linux-GNU.cmake) and where I can override it so I won't use the -rdynamic option? is there some other way to pass this problem?

talhaber commented 6 years ago

after a while, solved the flag issue! I found the build/CMakeFiles/CMakeSystem.cmake and the CMAKE_CROSSCOMPILING was "FALSE".

still trying to build a working crosscompile cmake files due. it logs somthing like this:

home/......./bin/aarch64-elf-gcc is not able to compile a simple test program. It fails with the compile test program. It fails with the following output: .......... ........... CMakeFiles/cmTryCompileExec.dor/testCCompiler.c.obj -o cmTryCompileExec In function _start: undefined reference to 'initialise_monitor_handles' In function exit: undefined reference to '_exit'

am I missing somting in the configuration? maybe I need to include some additional files from the linaro toolchain, but what and to where?

talhaber commented 6 years ago

if I change the project(NE10 C CXX ASM) to project(NE10 NONE) the test is omitted but it says: "CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly. missing variable is: CMAKE_C_CREATE_STATIC_LIBRARY --Generating done CMake Warninig: Manually-specified variable were not used by the project: CMAKE_TOOLCHAIN_FILE --Build files have been written to :{NE10projet}/build"

the make command yields: Linking C static library libNE10.a Built target NE10

moudles folder was created in build folder but there is no NE10.a file.

how to continue?

talhaber commented 6 years ago

finally, I managed to build the library.

I added the following to the toolchain file:

set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_CROSSCOMPILING 1) set(CMAKE_CXX_COMPILER_WORKS TRUE) set(CMAKE_C_COMPILER_WORKS TRUE) set(CMAKE_ASM_COMPILER_WORKS TRUE)

and it did the trick. you should update the documentation for cross compiling.

oska874 commented 4 years ago

hi, I use your method and the cmake procedure passed,but the make procedure fails. I used the latest NE10 code. Did you encounter the same problem?

I copied some:

/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:61:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC3F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC3F_NEON
     ^
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c: In function 'ne10_addc_vec4f_neon':
/home/vivado/project/Ne10/common/factor.h:254:4: error: unknown type name 'float32x4_t'; did you mean '_Float32x'?
    float32x4_t n_cst = { cst->x, cst->y, cst->z, cst->w }; \
    ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:254:34: warning: excess elements in scalar initializer
    float32x4_t n_cst = { cst->x, cst->y, cst->z, cst->w }; \
                                  ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:254:34: note: (near initialization for 'n_cst')
    float32x4_t n_cst = { cst->x, cst->y, cst->z, cst->w }; \
                                  ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:254:42: warning: excess elements in scalar initializer
    float32x4_t n_cst = { cst->x, cst->y, cst->z, cst->w }; \
                                          ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:254:42: note: (near initialization for 'n_cst')
    float32x4_t n_cst = { cst->x, cst->y, cst->z, cst->w }; \
                                          ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:254:50: warning: excess elements in scalar initializer
    float32x4_t n_cst = { cst->x, cst->y, cst->z, cst->w }; \
                                                  ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:254:50: note: (near initialization for 'n_cst')
    float32x4_t n_cst = { cst->x, cst->y, cst->z, cst->w }; \
                                                  ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:255:4: error: unknown type name 'float32x4_t'; did you mean '_Float32x'?
    float32x4_t n_src; \
    ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:256:4: error: unknown type name 'float32x4_t'; did you mean '_Float32x'?
    float32x4_t n_dst; \
    ^
/home/vivado/project/Ne10/common/macros.h:72:9: note: in expansion of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
         NE10_DstSrcCst_OPERATION_VEC4F_NEON( \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:245:26: error: 'float32_t' undeclared (first use in this function); did you mean 'uint32_t'?
      n_src = vld1q_f32( (float32_t*)src ); \
                          ^
/home/vivado/project/Ne10/common/factor.h:258:6: note: in definition of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
      loopCode; \
      ^~~~~~~~
/home/vivado/project/Ne10/common/macros.h:73:9: note: in expansion of macro 'NE10_DstSrcCst_MAINLOOP_VEC4F_NEON'
         NE10_DstSrcCst_MAINLOOP_VEC4F_NEON(loopCode); \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:245:36: error: expected expression before ')' token
      n_src = vld1q_f32( (float32_t*)src ); \
                                    ^
/home/vivado/project/Ne10/common/factor.h:258:6: note: in definition of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
      loopCode; \
      ^~~~~~~~
/home/vivado/project/Ne10/common/macros.h:73:9: note: in expansion of macro 'NE10_DstSrcCst_MAINLOOP_VEC4F_NEON'
         NE10_DstSrcCst_MAINLOOP_VEC4F_NEON(loopCode); \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
     ^
/home/vivado/project/Ne10/common/factor.h:248:29: error: expected expression before ')' token
      vst1q_f32 ( (float32_t*)dst , n_dst );  /* The main loop iterates through one 4D vector each time */ \
                             ^
/home/vivado/project/Ne10/common/factor.h:258:6: note: in definition of macro 'NE10_DstSrcCst_OPERATION_VEC4F_NEON'
      loopCode; \
      ^~~~~~~~
/home/vivado/project/Ne10/common/macros.h:73:9: note: in expansion of macro 'NE10_DstSrcCst_MAINLOOP_VEC4F_NEON'
         NE10_DstSrcCst_MAINLOOP_VEC4F_NEON(loopCode); \
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/vivado/project/Ne10/modules/math/NE10_addc.neon.c:75:5: note: in expansion of macro 'NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON'
     NE10_DstSrcCst_DO_COUNT_TIMES_VEC4F_NEON
surabhiashok1 commented 2 years ago

Getting similar errors for aarch64