https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61123

--- Comment #2 from Hale Wang <Hale.Wang at arm dot com> ---
(In reply to Richard Biener from comment #1)
> All ABI changing options should be also enabled for LTO and they also deserve
> handling in lto-opts.c (always stream, not only if explicitely set) and
> lto-wrapper.c (diagnose mismatches and force a setting for the link stage).
> 
> At least enabling them for LTO is minimally required, like you suggest.


Hi Richard,

I was dealing with the fno-short-enum bug that LTO ignore the options of
fshort-enum and fshort-wchar(fshort-wchar is similar with fshort-enum). I tried
to fix this bug by adding these options to LTO group. And this solution works.

Right now, I am trying to add some test cases to report some error message for
these cases in the previous gcc versions. And these cases will be passed after
I add these options to LTO group.

For the option of fshort-enum, I catch the Tag_ABI_enum_size from the final
executable. And this test case can work very well now.

But for  the option of fshort-wchar, if I compile the source files without
"-flto" option, I can catch the Tag_ABI_PCS_wchar_t from the final executable.
If I add the "-flto" option to the compile command, the Tag_ABI_PCS_wchar_t is
totally disappeared in the final executable.

So I think this is another bug which means the final executable file (or the
ABI) is different if we add "-flto" or not. 

I generated a minimal example.I have two source files:

wchar_0.c:
         #include <stddef.h>                
         wchar_t         wc0[]=L”abc”;
         const wchar_t   wc1[]=L”abc”; 

wchar_1.c:
         #include <stddef.h>                
         wchar_t               b0[]={ L”abc” };
         const wchar_t   b1[]={ L”abc” }; 

Firstly, I compile these files without “-flto”:

$ arm-none-eabi-gcc  -fshort-wchar  wchar_0.c  wchar_1.c  -Wl,-Ur  -o 
without_flto.o  -nostdlib  -Os
$ arm-none-eabi-readelf  -A  without_flto.o

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "ARM7TDMI"
  Tag_CPU_arch: v4T
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_PCS_wchar_t: 2
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: small
  Tag_ABI_optimization_goals: Aggressive Size


Then I compile these files with –flto:

$ arm-none-eabi-gcc  -fshort-wchar  wchar_0.c  wchar_1.c  -Wl,-Ur  -o 
with_flto.o  -nostdlib  -Os –flto
$ arm-none-eabi-readelf  -A  with_flto.o

Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "ARM7TDMI"
  Tag_CPU_arch: v4T
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: small
  Tag_ABI_optimization_goals: Aggressive Size

So we can see the Tag_ABI_PCS_wchar_t attribute is totally disappeared. 

What do you think about this?

Reply via email to