projectNe10 / Ne10

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

Why does extern ne10_foo(ne10_t bar) asm ("ne10_foo"); generate compiler error? #163

Closed ChuckNXP closed 7 years ago

ChuckNXP commented 7 years ago

I have downloaded and built the library but I cannot successfully compile an application even from the sample programs because of an error I get in the NE10_*.h header files. The simplest way I can display the error is to just try to compile it with gcc in its home directory. The header files called by NE10.h are located one level above in ../inc. The compiler seems to find them okay:

root@ls2088ardb:/home/chuck/ne10/projectNe10-Ne10-0c9f576/samples# gcc -std=c99 -I../inc NE10_sample_matrix_multiply.c In file included from ../inc/NE10.h:175:0, from NE10_sample_matrix_multiply.c:30: ../inc/NE10_math.h: In function 'ne10_addc_float_neon': ../inc/NE10_math.h:76:139: error: expected declaration specifiers before 'asm' extern ne10_result_t ne10_addc_float_neon (ne10_float32_t dst, ne10_float32_t src, const ne10_float32_t cst, ne10_uint32_t count) asm ("ne10_addc_float_neon");

My question is:

What is asm in this function prototype. I’m thinking this line of code declares an external assembly language function named “ne10_addc_float_neon” but why is that name repeated after the asm (macro?).

Is this supposed to work on the A72? The assembly instructions appear to be for the ARMv7 neon.

I’m sure I have some simple fundamental mistake with the build or link.

joesavage commented 7 years ago

Hi, Chuck.

What is asm in this function prototype. I’m thinking this line of code declares an external assembly language function named “ne10_addc_float_neon” but why is that name repeated after the asm (macro?).

To tell you the truth, I'm not totally sure about this one. As far as I can tell, your analysis of the functionality behind these seems correct, and thus their presence seems unnecessary to me too. Perhaps I'm missing something here though. In your case, I wouldn't expect any problems to arise from ignoring these. With respect to the compiler errors, could you check if using -std=gnu99 resolves the issue? (If so, that's great, but maybe we [Ne10] should also take a look at fixing the header files such that this is not necessary in future.)

Is this supposed to work on the A72? The assembly instructions appear to be for the ARMv7 neon.

I’m sure I have some simple fundamental mistake with the build or link.

Unfortunately, I don't think you're doing anything wrong here. The math and physics modules are currently written in ARMv7 assembly only. This really isn't ideal, and is already logged as something to fix under issue #150.

ChuckNXP commented 7 years ago

-std=gnu99 fixed the troublesome "expected declaration specifiers before 'asm'" errors. Thank you.

I was using -std=c99 but apparently there is something additional in gnu99 that I needed.