This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to disable floating-point instruction generation with aarch64 GCC compiler

Dear Sir,

  How to disable floating-point instruction generation with aarch64 GCC compiler ?

  We want to use software to do floating-point calculation.

  But always has error messages as below:

aarch64-linux-gnu-gcc -mcpu=cortex-a53+nofp test.c
test.c: In function 'main':
test.c:24:11: error: '+nofp' feature modifier is incompatible with floating-point code
     float aa = 0.0;
           ^
test.c:28:12: error: '+nofp' feature modifier is incompatible with floating-point argument
         aa += 3.0;
            ^
test.c:28:12: error: '+nofp' feature modifier is incompatible with floating-point argument
test.c:28:12: error: '+nofp' feature modifier is incompatible with floating-point code
test.c:28: confused by earlier errors, bailing out

    Any suggestion is good.

    Thank you.

test.c

#include <stdlib.h>
#include <stdio.h>

/*
 * void main(void)
 *    the application start point for the primary CPU
 *
 *  Inputs
 *    <none>
 *
 *  Returns
 *    subroutine does not return
 */
int main(void)
{
    float aa = 0.0;
    int i;

    for(i = 0; i < 1024; i++) {
        aa += 3.0;
    }  

    if (aa > 1000.0)
        exit(1);
    else
        exit(2);

    return 0;
}

Parents
  • nofp means no floating point at all, it is used to check floating point isn't used by mistake in some place it might cause problems like a device driver. The gcc option you want is -msoft-float, however this is not supported in any build for Aarch64 currently, it is really there for embedded processors that don't support a floating point unit. It wouldn't be hard to support in gcc- but it would require all associated libraries be built with the option as well and that implies a lot of support effort.

Reply
  • nofp means no floating point at all, it is used to check floating point isn't used by mistake in some place it might cause problems like a device driver. The gcc option you want is -msoft-float, however this is not supported in any build for Aarch64 currently, it is really there for embedded processors that don't support a floating point unit. It wouldn't be hard to support in gcc- but it would require all associated libraries be built with the option as well and that implies a lot of support effort.

Children