Public bug reported:

The rules files specifies the following optimization flasg for the
regular and nano buiLds respectively:

CFLAGS := CFLAGS="-g -O2 -ffunction-sections -fdata-sections"
CFLAGS_NANO := CFLAGS="-g -Os -ffunction-sections -fdata-sections -fshort-wchar"

(https://git.launchpad.net/ubuntu/+source/newlib/tree/debian/rules#n21)

However, these flags are not applied to the actual target files, only to host 
tool builds, it seems.
This can be confirmed by examining the resulting libc:

$ objdump -t /usr/lib/arm-none-eabi/newlib/thumb/v7/nofp/libc.a | grep ' printf'
00000000 l    df *ABS*  00000000 printf.c
00000021 g     F .text  00000028 printf


Note that printf is placed in the .text section (along with all other 
functions) - this would not be the case had -ffunction-sections been passed 
during build, in that case printif would be placed into ist own unique 
.text.printf section. This also means that -Os is not applied to nano builds.

To pass flags to the target build one needs to use CFLAGS_FOR_TARGET
instead.

CFLAGS := CFLAGS= CFLAGS_FOR_TARGET="-g -O2 -ffunction-sections -fdata-sections"
CFLAGS_NANO := CFLAGS= CFLAGS_FOR_TARGET="-g -Os -ffunction-sections 
-fdata-sections -fshort-wchar"

Note that CFLAGS also needs to be set, even if to an empty value.

** Affects: newlib (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2086618

Title:
  Compiler optimization flags are not applied correctly

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/newlib/+bug/2086618/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to