This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to use -fomit-frame-pointer for one file only

Hello,

I am trying to remove the use of the frame pointers for bootloader_util.c because I am getting the error : "r7 cannot be used in asm here", but I only know how to remove the frame pointers to all files by using -fomit-frame-pointer in CFLAGS. How do I make only one single file omit the frame pointers?

Thank you very much for your help!

Parents
  • Hi,

    If you use any optimization except -O0, -fomit-frame-pointer will be used:

    -fomit-frame-pointer

    Don't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions. It also makes debugging impossible on some machines. On some machines, such as the VAX, this flag has no effect, because the standard calling sequence automatically handles the frame pointer and nothing is saved by pretending it doesn't exist. The machine-description macro FRAME_POINTER_REQUIRED controls whether a target machine supports this flag. See Register Usage.

    Enabled at levels -O, -O2, -O3, -Os.

    You can use pragma:

    #pragma GCC push_options
    #pragma GCC optimize ("O0")
    
    ret = do_something();
    
    #pragma GCC pop_options
    

    or if you want to set it on the specific function:

    int some_func(void) __attribute__((optimize("-O0")));
    

    This error is not shown on my end (arm-none-eabi v4.9.3, SDK 10), I even tested with lto set as well.

    What SDK version are you using? And which version of arm-none-eabi are you using?

    Cheers, Håkon

  • I am running sdk9.2 and version 5.2 2015q4 of gnu tools. I do not get the error if I omit the frame pointers, which seems to work fine for now. Thank you very much for the above explanation and link, if I encounter any debugging issues, I'll definitely refer to this!

Reply Children
No Data
Related