@evanh said:
File size for -O1 is 84_844 bytes
File size for -O2 is 81_980 bytes
That was for my custom loaded 4-bit SD mode driver.
For the built-in SPI mode driver the sizes are:
File size for -O1 is 71_592 bytes
File size for -O2 is 69_208 bytes
So -O2 shrinks the compiled binary file size by 2864 - 2384 = 480 bytes extra when having the driver as a separate object. Given the custom driver is bigger, a decent amount of that could just be optimising the driver itself.
One was a non-existent symbol being referenced in my driver. I've fixed the bug but am puzzled as to why it didn't produce a compile error when compiling the C version of the SD tester program.
Perhaps the function containing the non-existent symbol was never referenced? If so it can sometimes be skipped at a very early stage so we don't even see those kinds of errors. This is less likely to happen when the function is in an object/struct (because we have to assume all public functions in an object might be called).
The other is include/fcntl.h:56: error: syntax error, unexpected identifier 'mode_t' It's missing an include of it's own I guess. My current fix is to shift the order of includes in my driver. Again, the C version of the tester didn't produce any error here even though it's the identical driver code.
EDIT2: Come to think of it. A compile warning that I'd earlier dismissed shows up this same way - include/filesys/fatfs/fatfs_vfs.c:96: warning: mixing pointer and integer types in return: expected pointer to _struct__vfs but got int
These are both bugs in the header files. I've checked in some fixes. Thanks for catching these!
Comments
That was for my custom loaded 4-bit SD mode driver.
For the built-in SPI mode driver the sizes are:
File size for -O1 is 71_592 bytes
File size for -O2 is 69_208 bytes
So -O2 shrinks the compiled binary file size by 2864 - 2384 = 480 bytes extra when having the driver as a separate object. Given the custom driver is bigger, a decent amount of that could just be optimising the driver itself.
Perhaps the function containing the non-existent symbol was never referenced? If so it can sometimes be skipped at a very early stage so we don't even see those kinds of errors. This is less likely to happen when the function is in an object/struct (because we have to assume all public functions in an object might be called).
These are both bugs in the header files. I've checked in some fixes. Thanks for catching these!