re PR lto/61123 (With LTO, -fno-short-enums is ignored, resulting in ABI mis-matching...
authorHale Wang <hale.wang@arm.com>
Fri, 20 Jun 2014 04:52:11 +0000 (04:52 +0000)
committerZhenqiang Chen <zqchen@gcc.gnu.org>
Fri, 20 Jun 2014 04:52:11 +0000 (04:52 +0000)
c-family/ChangeLog
2014-06-20 Hale Wang <hale.wang@arm.com>

PR lto/61123
* c.opt (fshort-enums): Add to LTO.
* c.opt (fshort-wchar): Likewise.

testsuite/ChangeLog
2014-06-20 Hale Wang <hale.wang@arm.com>

* gcc.target/arm/lto/: New folder to verify the LTO option.
* gcc.target/arm/lto/pr61123-enum-size_0.c: New test case.
* gcc.target/arm/lto/pr61123-enum-size_1.c: Likewise.
* gcc.target/arm/lto/lto.exp: New exp file used to test LTO option.
* lib/lto.exp (object-readelf): New procedure.

From-SVN: r211832

gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/lto/lto.exp [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/lto/pr61123-enum-size_0.c [new file with mode: 0644]
gcc/testsuite/gcc.target/arm/lto/pr61123-enum-size_1.c [new file with mode: 0644]
gcc/testsuite/lib/lto.exp

index ffa94ebacf6e47c639fe0684b47b7a7d2face964..d195db74d5a081de0028cd1a92d1b45e7ea5d41f 100644 (file)
@@ -1,3 +1,9 @@
+2014-06-20 Hale Wang <hale.wang@arm.com>
+
+       PR lto/61123
+       * c.opt (fshort-enums): Add to LTO.
+       * c.opt (fshort-wchar): Likewise.
+
 2014-06-16  Marek Polacek  <polacek@redhat.com>
 
        PR c/60439
index 91f8275ef145bffe5ded0e5545f7dff121d4dc0c..73abd26159a501773623e319ce9cf4aad4b6c113 100644 (file)
@@ -1197,11 +1197,11 @@ C ObjC C++ ObjC++ LTO Optimization Var(flag_short_double)
 Use the same size for double as for float
 
 fshort-enums
-C ObjC C++ ObjC++ Optimization Var(flag_short_enums)
+C ObjC C++ ObjC++ LTO Optimization Var(flag_short_enums)
 Use the narrowest integer type possible for enumeration types
 
 fshort-wchar
-C ObjC C++ ObjC++ Optimization Var(flag_short_wchar)
+C ObjC C++ ObjC++ LTO Optimization Var(flag_short_wchar)
 Force the underlying type for \"wchar_t\" to be \"unsigned short\"
 
 fsigned-bitfields
index 5d58712f7e4583ee7bd255584270cb3f9a644963..d6002c1f97284350466837a1c1d2d7f3a9b29535 100644 (file)
@@ -1,3 +1,11 @@
+2014-06-20 Hale Wang <hale.wang@arm.com>
+
+       * gcc.target/arm/lto/: New folder to verify the LTO option.
+       * gcc.target/arm/lto/pr61123-enum-size_0.c: New test case.
+       * gcc.target/arm/lto/pr61123-enum-size_1.c: Likewise.
+       * gcc.target/arm/lto/lto.exp: New exp file used to test LTO option.
+       * lib/lto.exp (object-readelf): New procedure.
+
 2014-06-19  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/61454
diff --git a/gcc/testsuite/gcc.target/arm/lto/lto.exp b/gcc/testsuite/gcc.target/arm/lto/lto.exp
new file mode 100644 (file)
index 0000000..7513411
--- /dev/null
@@ -0,0 +1,59 @@
+# Copyright (C) 2009-2014 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+#
+# Contributed by Diego Novillo <dnovillo@google.com>
+
+
+# Test link-time optimization across multiple files.
+#
+# Programs are broken into multiple files.  Each one is compiled
+# separately with LTO information.  The final executable is generated
+# by collecting all the generated object files using regular LTO or WHOPR.
+
+if $tracelevel then {
+    strace $tracelevel
+}
+
+# Load procedures from common libraries.
+load_lib standard.exp
+load_lib gcc.exp
+
+# Load the language-independent compabibility support procedures.
+load_lib lto.exp
+
+# If LTO has not been enabled, bail.
+if { ![check_effective_target_lto] } {
+    return
+}
+
+gcc_init
+lto_init no-mathlib
+
+# Define an identifier for use with this suite to avoid name conflicts
+# with other lto tests running at the same time.
+set sid "c_lto"
+
+# Main loop.
+foreach src [lsort [find $srcdir/$subdir *_0.c]] {
+    # If we're only testing specific files and this isn't one of them, skip it.
+    if ![runtest_file_p $runtests $src] then {
+       continue
+    }
+
+    lto-execute $src $sid
+}
+
+lto_finish
diff --git a/gcc/testsuite/gcc.target/arm/lto/pr61123-enum-size_0.c b/gcc/testsuite/gcc.target/arm/lto/pr61123-enum-size_0.c
new file mode 100644 (file)
index 0000000..c23f9d8
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -fno-short-enums -Wl,-Ur,--no-enum-size-warning -Os -nostdlib -flto } } } */
+
+#include <stdlib.h>
+
+enum enum_size_attribute
+{
+  small_size, int_size
+};
+
+struct debug_ABI_enum_size
+{
+  enum enum_size_attribute es;
+};
+
+int
+foo1 (struct debug_ABI_enum_size *x)
+{
+  return sizeof (x->es);
+}
+
+/* { dg-final { object-readelf Tag_ABI_enum_size int { target arm_eabi } } } */
diff --git a/gcc/testsuite/gcc.target/arm/lto/pr61123-enum-size_1.c b/gcc/testsuite/gcc.target/arm/lto/pr61123-enum-size_1.c
new file mode 100644 (file)
index 0000000..9561efa
--- /dev/null
@@ -0,0 +1,5 @@
+int
+foo2 (int y)
+{
+  return y*10;
+}
index 997d5a38d109b65129ae0eb9bccacd3cb1b6c54e..5182558c7b72cf5974144ba8ce75591c0483ca32 100644 (file)
@@ -650,3 +650,82 @@ proc scan-symbol { args } {
        fail "scan-symbol $args"
     }
 }
+
+# Call pass if object readelf is ok, otherwise fail.
+# example: /* { dg-final { object-readelf Tag_ABI_enum_size int} } */
+proc object-readelf { args } {
+    global readelf
+    global base_dir
+    upvar 2 execname execname
+
+    if { [llength $args] < 2 } {
+       error "object-readelf: too few arguments"
+       return
+    }
+    if { [llength $args] > 3 } {
+       error "object-readelf: too many arguments"
+       return
+    }
+    if { [llength $args] >= 3 } {
+       switch [dg-process-target [lindex $args 2]] {
+           "S" { }
+           "N" { return }
+           "F" { setup_xfail "*-*-*" }
+           "P" { }
+       }
+    }
+
+    # Find size like we find g++ in g++.exp.
+    if ![info exists readelf]  {
+       set readelf [findfile $base_dir/../../../binutils/readelf \
+               $base_dir/../../../binutils/readelf \
+               [findfile $base_dir/../../readelf $base_dir/../../readelf \
+               [findfile $base_dir/readelf $base_dir/readelf \
+               [transform readelf]]]]
+       verbose -log "readelf is $readelf"
+    }
+
+    set what [lindex $args 0]
+    set with [lindex $args 1]
+
+    if ![file_on_host exists $execname] {
+       verbose -log "$execname does not exist"
+       unresolved "object-readelf $what "
+       return
+    }
+
+    set output [remote_exec host "$readelf -A" "$execname"]
+    set status [lindex $output 0]
+    if { $status != 0 } {
+       verbose -log "object-readelf: $readelf failed"
+       unresolved "object-readelf $what $execname"
+       return
+    }
+
+    set text [lindex $output 1]
+    set lines [split $text "\n"]
+
+    set done 0
+    set i 0
+    while { !$done } {
+       set line_tex [lindex $lines $i]
+       if { [llength ${line_tex}] > 1} {
+           incr i
+           if [regexp -- $what $line_tex] {
+               set match [regexp -- $with $line_tex]
+               set done 1
+           }
+       } else {
+           set done 1
+       }
+    }
+
+    verbose -log "$what size is $with;"
+    if { $match == 1 } {
+       pass "object-readelf $what size is correct."
+    } else {
+       fail "object-readelf $what size is incorrect."
+    }
+}
+
+