Re: [Patch] Fix the testcases that use bind_pic_locally

2013-10-08 Thread Vidya Praveen
On Tue, Oct 08, 2013 at 10:30:22AM +0100, Jakub Jelinek wrote:
> On Tue, Oct 08, 2013 at 10:14:59AM +0100, Vidya Praveen wrote:
> > There are several tests that use "dg-add-options bind_pic_locally" in order 
> > to
> > add -fPIE or -fpie when -fPIC or -fpic are used respectively with the 
> > expecta-
> > tion that -fPIE/-fpie will override -fPIC/-fpic. But this doesn't happen 
> > since
> > since -fPIE/-fpie will be added before the -fPIC/-fpic (whether -fPIC/-fpic 
> > is
> > added as a multilib option or through cflags). This is essentially due to 
> > the
> > fact that cflags and multilib flags are added after the options are added 
> > through dg-options, dg-add-options, et al. in default_target_compile 
> > function.
> > 
> > Assuming dg-options or dg-add-options should always win, we can fix this by
> > modifying the order in which they are concatenated at 
> > default_target_compile in
> > target.exp. But this is not recommended since it depends on everyone who 
> > tests
> > upgrading their dejagnu (refer [1]). 
> 
> This looks like a big step backwards and I'm afraid it can break targets
> where -fpic/-fPIC is the default. 

I agree. I didn't think of this. Since the -fPIC/-fpic comes before the 
-fPIE/-fpie
this will work here. In other words, bind_pic_locally is not broken in this 
case.

(This is assuming the -fPIC/-fpic as default option is passed through 
DRIVER_SELF_SPECS or similar).

> If dg-add-options bind_pic_locally must
> add options to the end of command line, then can't you just push the options
> that must go last to some variable other than dg-extra-tool-flags and as we
> override dejagnu's dg-test, put it in our override last (or in whatever
> other method that already added the multilib options)?

Well, multilib options are added at default_target_compile which is in 
target.exp.
If I store the flags in some variable at add_options_for_bind_pic_locally and 
add
it later, it still going to be before default_target_compile is called. 

Hope I understood your suggestion right.

Cheers
VP




Re: [Patch] Fix the testcases that use bind_pic_locally

2013-10-08 Thread Jakub Jelinek
On Tue, Oct 08, 2013 at 10:14:59AM +0100, Vidya Praveen wrote:
> There are several tests that use "dg-add-options bind_pic_locally" in order to
> add -fPIE or -fpie when -fPIC or -fpic are used respectively with the expecta-
> tion that -fPIE/-fpie will override -fPIC/-fpic. But this doesn't happen since
> since -fPIE/-fpie will be added before the -fPIC/-fpic (whether -fPIC/-fpic is
> added as a multilib option or through cflags). This is essentially due to the
> fact that cflags and multilib flags are added after the options are added 
> through dg-options, dg-add-options, et al. in default_target_compile function.
> 
> Assuming dg-options or dg-add-options should always win, we can fix this by
> modifying the order in which they are concatenated at default_target_compile 
> in
> target.exp. But this is not recommended since it depends on everyone who tests
> upgrading their dejagnu (refer [1]). 

This looks like a big step backwards and I'm afraid it can break targets
where -fpic/-fPIC is the default.  If dg-add-options bind_pic_locally must
add options to the end of command line, then can't you just push the options
that must go last to some variable other than dg-extra-tool-flags and as we
override dejagnu's dg-test, put it in our override last (or in whatever
other method that already added the multilib options)?

Jakub


[Patch] Fix the testcases that use bind_pic_locally

2013-10-08 Thread Vidya Praveen
Hello,

There are several tests that use "dg-add-options bind_pic_locally" in order to
add -fPIE or -fpie when -fPIC or -fpic are used respectively with the expecta-
tion that -fPIE/-fpie will override -fPIC/-fpic. But this doesn't happen since
since -fPIE/-fpie will be added before the -fPIC/-fpic (whether -fPIC/-fpic is
added as a multilib option or through cflags). This is essentially due to the
fact that cflags and multilib flags are added after the options are added 
through dg-options, dg-add-options, et al. in default_target_compile function.

Assuming dg-options or dg-add-options should always win, we can fix this by
modifying the order in which they are concatenated at default_target_compile in
target.exp. But this is not recommended since it depends on everyone who tests
upgrading their dejagnu (refer [1]). 

So this patch replaces:

/* { dg-add-options bind_pic_locally } */

with 

/* { dg-skip-if "" { *-*-* } { "-fPIC" "-fpic" } { "" } } */

in all the applicable test files. 

NOTE: There are many files that uses bind_pic_locally but they do PASS whether
or not -fPIE/-fpie is passed. But I've replaced in all the files that uses
bind_pic_locally.

add_options_for_bind_pic_locally should IMO be removed or deprecated since it is
is misleading. I can post a separate patch for this if everyone agrees to it.

References:
[1] http://gcc.gnu.org/ml/gcc/2013-07/msg00281.html
[2] http://gcc.gnu.org/ml/gcc/2013-09/msg00207.html

This issue for obvious reasons, common to all targets. 

Tested for aarch64-none-elf. OK for trunk?

Cheers
VP

---

gcc/testsuite/ChangeLog:

2013-10-08  Vidya Praveen  

* gcc.dg/inline-33.c: Remove bind_pic_locally and skip if -fPIC/-fpic
is used.
* gcc.dg/ipa/ipa-3.c: Likewise.
* gcc.dg/ipa/ipa-5.c: Likewise.
* gcc.dg/ipa/ipa-7.c: Likewise.
* gcc.dg/ipa/ipcp-2.c: Likewise.
* gcc.dg/ipa/ipcp-agg-1.c: Likewise.
* gcc.dg/ipa/ipcp-agg-2.c: Likewise.
* gcc.dg/ipa/ipcp-agg-6.c: Likewise.
* gcc.dg/ipa/ipa-1.c: Likewise.
* gcc.dg/ipa/ipa-2.c: Likewise.
* gcc.dg/ipa/ipa-4.c: Likewise.
* gcc.dg/ipa/ipa-8.c: Likewise.
* gcc.dg/ipa/ipacost-2.c: Likewise.
* gcc.dg/ipa/ipcp-1.c: Likewise.
* gcc.dg/ipa/ipcp-4.c: Likewise.
* gcc.dg/ipa/ipcp-agg-3.c: Likewise.
* gcc.dg/ipa/ipcp-agg-4.c: Likewise.
* gcc.dg/ipa/ipcp-agg-5.c: Likewise.
* gcc.dg/ipa/ipcp-agg-7.c: Likewise.
* gcc.dg/ipa/ipcp-agg-8.c: Likewise.
* gcc.dg/ipa/pr56988.c: Likewise.
* g++.dg/ipa/iinline-1.C: Likewise.
* g++.dg/ipa/iinline-2.C: Likewise.
* g++.dg/ipa/iinline-3.C: Likewise.
* g++.dg/ipa/inline-1.C: Likewise.
* g++.dg/ipa/inline-2.C: Likewise.
* g++.dg/ipa/inline-3.C: Likewise.
* g++.dg/other/first-global.C: Likewise.
* g++.dg/parse/attr-externally-visible-1.C: Likewise.
* g++.dg/torture/pr40323.C: Likewise.
* g++.dg/torture/pr55260-1.C: Likewise.
* g++.dg/torture/pr55260-2.C: Likewise.
* g++.dg/tree-ssa/inline-1.C: Likewise.
* g++.dg/tree-ssa/inline-2.C: Likewise.
* g++.dg/tree-ssa/inline-3.C: Likewise.
* g++.dg/tree-ssa/nothrow-1.C: Likewise.
* gcc.dg/tree-ssa/inline-3.c: Likewise.
* gcc.dg/tree-ssa/inline-4.c: Likewise.
* gcc.dg/tree-ssa/ipa-cp-1.c: Likewise.
* gcc.dg/tree-ssa/local-pure-const.c: Likewise.
* gfortran.dg/whole_file_5.f90: Likewise.
* gfortran.dg/whole_file_6.f90: Likewise.
diff --git a/gcc/testsuite/g++.dg/ipa/iinline-1.C b/gcc/testsuite/g++.dg/ipa/iinline-1.C
index 9f99893..e4daa8c 100644
--- a/gcc/testsuite/g++.dg/ipa/iinline-1.C
+++ b/gcc/testsuite/g++.dg/ipa/iinline-1.C
@@ -2,7 +2,7 @@
inlining..  */
 /* { dg-do compile } */
 /* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining"  } */
-/* { dg-add-options bind_pic_locally } */
+/* { dg-skip-if "" { *-*-* } { "-fPIC" "-fpic" } { "" } } */
 
 extern void non_existent (const char *, int);
 
diff --git a/gcc/testsuite/g++.dg/ipa/iinline-2.C b/gcc/testsuite/g++.dg/ipa/iinline-2.C
index 670a5dd..64a4dce 100644
--- a/gcc/testsuite/g++.dg/ipa/iinline-2.C
+++ b/gcc/testsuite/g++.dg/ipa/iinline-2.C
@@ -2,7 +2,7 @@
inlining..  */
 /* { dg-do compile } */
 /* { dg-options "-O3 -fdump-ipa-inline -fno-early-inlining"  } */
-/* { dg-add-options bind_pic_locally } */
+/* { dg-skip-if "" { *-*-* } { "-fPIC" "-fpic" } { "" } } */
 
 extern void non_existent (const char *, int);
 
diff --git a/gcc/testsuite/g++.dg/ipa/iinline-3.C b/gcc/testsuite/g++.dg/ipa/iinline-3.C
index 3daee9a..0d59969 100644
--- a/gcc/testsuite/g++.dg/ipa/iinline-3.C
+++ b/gcc/testsuite/g++.dg/ipa/iinline-3.C
@@ -2,7 +2,7 @@
parameters which have been modified.  */
 /* { dg-do run } */
 /* { dg-options "-O3 -fno-early-inlining"  } */
-/* { dg-add-options bind_pic_locally } */
+/* { dg-skip-if "" { *-*-* } { "-fPIC" "-fpic" } { "" } } */
 
 ex