RFA: Add test for linker support of -shared

View: New views
5 Messages — Rating Filter:   Alert me  

RFA: Add test for linker support of -shared

by Nick Clifton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Janis,

  I would like to add another new proc to target-supports.exp.  This
  time it is a check for linker support of the -shared command line
  switch.  Not all linkers support this switch, since not all
  toolchains support shared libraries.  (Toolchains for embedded
  processors in particular, such as the RX).

  The intention is to use this proc as a requirement in tests that
  want to use the -shared option, notably the new LTO tests.

  Tested with an rx-elf toolchain (fewer gcc testsuite failures) and
  an i686-pc-linux-gnu toolchain (no regressions).

  OK to apply ?

Cheers
  Nick

gcc/testsuite/ChangeLog
2009-11-03  Nick Clifton  <nickc@...>

        * lib/target-supports.exp
        (check_effective_target_linker_supports_shared): New proc.
        * g++.dg/lto/20081120-1_0.C: Require linker support of
        -shared.
        * g++.dg/lto/20091002-1_0.C: Likewise.
        * g++.dg/lto/20081120-2_0.C: Likewise.
        * g++.dg/lto/20091002-2_0.C: Likewise.
        * g++.dg/lto/20091002-3_0.C: Likewise.
        * g++.dg/lto/20081123_0.C: Likewise.
        * g++.dg/lto/20090313_0.C: Likewise.
        * g++.dg/lto/20081109-1_0.C: Likewise.
        * g++.dg/lto/20081219_0.C: Likewise.
        * g++.dg/lto/20081204-1_0.C: Likewise.
        * g++.dg/lto/20090302_0.C: Likewise.
        * g++.dg/lto/20081119-1_0.C: Likewise.
        * g++.dg/lto/20081118_0.C: Likewise.

Index: testsuite/lib/target-supports.exp
===================================================================
--- testsuite/lib/target-supports.exp (revision 153851)
+++ testsuite/lib/target-supports.exp (working copy)
@@ -669,6 +679,14 @@
     return 0
 }
 
+# Returns true if the linker accepts the -shared option.
+proc check_effective_target_linker_supports_shared { } {
+    return [check_no_compiler_messages linker_supports_shared executable {
+    int foo (void) { return 0; }
+ } "-shared" ]
+}
+
+
 # Return true if the target supports -mpaired-single (as used on MIPS).
 
 proc check_effective_target_mpaired_single { } {

Index: testsuite/g++.dg/lto/20081120-1_0.C
===================================================================
--- testsuite/g++.dg/lto/20081120-1_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081120-1_0.C (working copy)
@@ -1,5 +1,6 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-flto -shared}} }
 extern "C"
 {
  extern __inline __attribute__((__gnu_inline__)) int pthread_equal(int, int)
Index: testsuite/g++.dg/lto/20091002-1_0.C
===================================================================
--- testsuite/g++.dg/lto/20091002-1_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20091002-1_0.C (working copy)
@@ -1,4 +1,5 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-fPIC -flto}} }
 // { dg-extra-ld-options "-fPIC -shared" }
 
Index: testsuite/g++.dg/lto/20081120-2_0.C
===================================================================
--- testsuite/g++.dg/lto/20081120-2_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081120-2_0.C (working copy)
@@ -1,4 +1,5 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-flto -shared}} }
 template < typename > struct Foo
 {
Index: testsuite/g++.dg/lto/20091002-2_0.C
===================================================================
--- testsuite/g++.dg/lto/20091002-2_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20091002-2_0.C (working copy)
@@ -1,4 +1,5 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-fPIC}} }
 // { dg-extra-ld-options "-fPIC -shared" }
 
Index: testsuite/g++.dg/lto/20091002-3_0.C
===================================================================
--- testsuite/g++.dg/lto/20091002-3_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20091002-3_0.C (working copy)
@@ -1,4 +1,5 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-fPIC}} }
 // { dg-extra-ld-options "-fPIC -shared" }
 
Index: testsuite/g++.dg/lto/20081123_0.C
===================================================================
--- testsuite/g++.dg/lto/20081123_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081123_0.C (working copy)
@@ -1,4 +1,5 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-fwhopr -shared -fPIC}} }
 
 int
Index: testsuite/g++.dg/lto/20090313_0.C
===================================================================
--- testsuite/g++.dg/lto/20090313_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20090313_0.C (working copy)
@@ -1,4 +1,5 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-fwhopr -fPIC}} }
 // { dg-extra-ld-options "-fwhopr -shared" }
 
Index: testsuite/g++.dg/lto/20081109-1_0.C
===================================================================
--- testsuite/g++.dg/lto/20081109-1_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081109-1_0.C (working copy)
@@ -1,5 +1,6 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-fPIC -fwhopr}} }
-// { dg-extra-ld-options "-fPIC -fwhopr -shared -fno-exceptions" }
+// { dg-extra-ld-options "-fPIC -fwhopr shared -fno-exceptions" }
 void func(); class Foo { };
 void bar() { try { func(); } catch (Foo) { } };
Index: testsuite/g++.dg/lto/20081219_0.C
===================================================================
--- testsuite/g++.dg/lto/20081219_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081219_0.C (working copy)
@@ -1,4 +1,5 @@
 // { dg-lto-do link }
+// { dg-require-effective-target linker_supports_shared }
 // { dg-lto-options {{-fPIC -fwhopr -O2}} }
 // { dg-extra-ld-options "-O2 -fPIC -fwhopr -shared" }
 
Index: testsuite/g++.dg/lto/20081204-1_0.C
===================================================================
--- testsuite/g++.dg/lto/20081204-1_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081204-1_0.C (working copy)
@@ -1,4 +1,5 @@
 /* { dg-lto-do link } */
+/* { dg-require-effective-target linker_supports_shared } */
 /* { dg-lto-options {{-fwhopr -fPIC -shared}} } */
 
 /* Tests for the absence during linking of:
Index: testsuite/g++.dg/lto/20090302_0.C
===================================================================
--- testsuite/g++.dg/lto/20090302_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20090302_0.C (working copy)
@@ -1,4 +1,5 @@
 /* { dg-lto-do link } */
+/* { dg-require-effective-target linker_supports_shared } */
 /* { dg-lto-options {{-fPIC -fwhopr -shared}} } */
 struct Foo {
   bool Mumble();
Index: testsuite/g++.dg/lto/20081119-1_0.C
===================================================================
--- testsuite/g++.dg/lto/20081119-1_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081119-1_0.C (working copy)
@@ -1,4 +1,5 @@
 /* { dg-lto-do link } */
+/* { dg-require-effective-target linker_supports_shared } */
 /* { dg-lto-options {{-fPIC -fwhopr -shared}} } */
 
 #include "20081119-1.h"
Index: testsuite/g++.dg/lto/20081118_0.C
===================================================================
--- testsuite/g++.dg/lto/20081118_0.C (revision 153851)
+++ testsuite/g++.dg/lto/20081118_0.C (working copy)
@@ -1,4 +1,5 @@
 /* { dg-lto-do link } */
+/* { dg-require-effective-target linker_supports_shared } */
 /* { dg-lto-options {{-fPIC -fwhopr -shared}} } */
 
 /* We used to ICE because of dangling pointers.  */
 

Re: RFA: Add test for linker support of -shared

by Andrew Pinski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 3, 2009 at 7:58 AM, Nick Clifton <nickc@...> wrote:
> Hi Janis,
>  Tested with an rx-elf toolchain (fewer gcc testsuite failures) and
>  an i686-pc-linux-gnu toolchain (no regressions).
>
>  OK to apply ?

Most of the g++.dg/lto testcases should be switched over to use -r
-nostdlib like what was done for the gcc.dg/lto side.

Thanks,
Andrew Pinski

Re: RFA: Add test for linker support of -shared

by Nick Clifton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Andrew,

> Most of the g++.dg/lto testcases should be switched over to use -
> -nostdlib like what was done for the gcc.dg/lto side.


OK, how about the attached patch ?

Tested with an rx-elf toolchain and an i686-pc-linux-gnu toolchain, with
no regressions.

Cheers
   Nick

gcc/testsuite/ChangeLog
2009-11-04  Nick Clifton  <nickc@...>

        * g++.dg/lto/20091002-1_0.C: Replace -shared with -r -nostlib.
        * g++.dg/lto/20081120-1_0.C: Likewise.
        * g++.dg/lto/20091002-2_0.C: Likewise.
        * g++.dg/lto/20081120-2_0.C: Likewise.
        * g++.dg/lto/20091002-3_0.C: Likewise.
        * g++.dg/lto/20081123_0.C: Likewise.
        * g++.dg/lto/20090313_0.C: Likewise.
        * g++.dg/lto/20081109-1_0.C: Likewise.
        * g++.dg/lto/20081219_0.C: Likewise.
        * g++.dg/lto/20081204-1_0.C: Likewise.
        * g++.dg/lto/20090302_0.C: Likewise.
        * g++.dg/lto/20081119-1_0.C: Likewise.
        * g++.dg/lto/20081118_0.C: Likewise.

Index: gcc/testsuite/g++.dg/lto/20091002-1_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20091002-1_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20091002-1_0.C (working copy)
@@ -1,6 +1,6 @@
 // { dg-lto-do link }
 // { dg-lto-options {{-fPIC -flto}} }
-// { dg-extra-ld-options "-fPIC -shared" }
+// { dg-extra-ld-options "-fPIC -r -nostdlib" }
 
 namespace std __attribute__ ((__visibility__ ("default")))
 {
Index: gcc/testsuite/g++.dg/lto/20081120-1_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081120-1_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081120-1_0.C (working copy)
@@ -1,5 +1,5 @@
 // { dg-lto-do link }
-// { dg-lto-options {{-flto -shared}} }
+// { dg-lto-options {{-flto -r -nostdlib}} }
 extern "C"
 {
  extern __inline __attribute__((__gnu_inline__)) int pthread_equal(int, int)
Index: gcc/testsuite/g++.dg/lto/20091002-2_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20091002-2_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20091002-2_0.C (working copy)
@@ -1,6 +1,6 @@
 // { dg-lto-do link }
 // { dg-lto-options {{-fPIC}} }
-// { dg-extra-ld-options "-fPIC -shared" }
+// { dg-extra-ld-options "-fPIC -r -nostdlib" }
 
 class DataArray {
     int max() const    { }
Index: gcc/testsuite/g++.dg/lto/20081120-2_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081120-2_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081120-2_0.C (working copy)
@@ -1,5 +1,5 @@
 // { dg-lto-do link }
-// { dg-lto-options {{-flto -shared}} }
+// { dg-lto-options {{-flto -r -nostdlib}} }
 template < typename > struct Foo
 {
  inline void rdstate() {
Index: gcc/testsuite/g++.dg/lto/20091002-3_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20091002-3_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20091002-3_0.C (working copy)
@@ -1,6 +1,6 @@
 // { dg-lto-do link }
 // { dg-lto-options {{-fPIC}} }
-// { dg-extra-ld-options "-fPIC -shared" }
+// { dg-extra-ld-options "-fPIC -r -nostdlib" }
 
 template < class T >
 class DataArray {
Index: gcc/testsuite/g++.dg/lto/20081123_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081123_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081123_0.C (working copy)
@@ -1,5 +1,5 @@
 // { dg-lto-do link }
-// { dg-lto-options {{-fwhopr -shared -fPIC}} }
+// { dg-lto-options {{-fwhopr -r -nostdlib -fPIC}} }
 
 int
 f(void)
Index: gcc/testsuite/g++.dg/lto/20090313_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20090313_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20090313_0.C (working copy)
@@ -1,5 +1,5 @@
 // { dg-lto-do link }
 // { dg-lto-options {{-fwhopr -fPIC}} }
-// { dg-extra-ld-options "-fwhopr -shared" }
+// { dg-extra-ld-options "-fwhopr -r -nostdlib" }
 
 int X;
Index: gcc/testsuite/g++.dg/lto/20081109-1_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081109-1_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081109-1_0.C (working copy)
@@ -1,5 +1,5 @@
 // { dg-lto-do link }
 // { dg-lto-options {{-fPIC -fwhopr}} }
-// { dg-extra-ld-options "-fPIC -fwhopr -shared -fno-exceptions" }
+// { dg-extra-ld-options "-fPIC -fwhopr -r -nostdlib -fno-exceptions" }
 void func(); class Foo { };
 void bar() { try { func(); } catch (Foo) { } };
Index: gcc/testsuite/g++.dg/lto/20081219_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081219_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081219_0.C (working copy)
@@ -1,6 +1,6 @@
 // { dg-lto-do link }
 // { dg-lto-options {{-fPIC -fwhopr -O2}} }
-// { dg-extra-ld-options "-O2 -fPIC -fwhopr -shared" }
+// { dg-extra-ld-options "-O2 -fPIC -fwhopr -r -nostdlib" }
 
 typedef long int ptrdiff_t;
 extern "C"
Index: gcc/testsuite/g++.dg/lto/20081204-1_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081204-1_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081204-1_0.C (working copy)
@@ -1,5 +1,5 @@
 /* { dg-lto-do link } */
-/* { dg-lto-options {{-fwhopr -fPIC -shared}} } */
+/* { dg-lto-options {{-fwhopr -fPIC -r -nostdlib}} } */
 
 /* Tests for the absence during linking of:
    lto1: error: type of '_ZTVN10__cxxabiv120__si_class_type_infoE' does
Index: gcc/testsuite/g++.dg/lto/20090302_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20090302_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20090302_0.C (working copy)
@@ -1,5 +1,5 @@
 /* { dg-lto-do link } */
-/* { dg-lto-options {{-fPIC -fwhopr -shared}} } */
+/* { dg-lto-options {{-fPIC -fwhopr -r -nostdlib}} } */
 struct Foo {
   bool Mumble();
   static void Bar() { if (foo_->Mumble()) foo_ = 0; }
Index: gcc/testsuite/g++.dg/lto/20081119-1_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081119-1_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081119-1_0.C (working copy)
@@ -1,5 +1,5 @@
 /* { dg-lto-do link } */
-/* { dg-lto-options {{-fPIC -fwhopr -shared}} } */
+/* { dg-lto-options {{-fPIC -fwhopr -r -nostdlib}} } */
 
 #include "20081119-1.h"
 
Index: gcc/testsuite/g++.dg/lto/20081118_0.C
===================================================================
--- gcc/testsuite/g++.dg/lto/20081118_0.C (revision 153890)
+++ gcc/testsuite/g++.dg/lto/20081118_0.C (working copy)
@@ -1,5 +1,5 @@
 /* { dg-lto-do link } */
-/* { dg-lto-options {{-fPIC -fwhopr -shared}} } */
+/* { dg-lto-options {{-fPIC -fwhopr -r -nostdlib}} } */
 
 /* We used to ICE because of dangling pointers.  */
 

Re: RFA: Add test for linker support of -shared

by Andrew Pinski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 4, 2009 at 4:25 AM, Nick Clifton <nickc@...> wrote:
> Hi Andrew,
>
>> Most of the g++.dg/lto testcases should be switched over to use -
>> -nostdlib like what was done for the gcc.dg/lto side.
>
>
> OK, how about the attached patch ?

I cannot approve this but this would have been the patch I would do.

Thanks,
Andrew Pinski

Re: RFA: Add test for linker support of -shared

by Richard Guenther-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 4, 2009 at 7:49 PM, Andrew Pinski <pinskia@...> wrote:

> On Wed, Nov 4, 2009 at 4:25 AM, Nick Clifton <nickc@...> wrote:
>> Hi Andrew,
>>
>>> Most of the g++.dg/lto testcases should be switched over to use -
>>> -nostdlib like what was done for the gcc.dg/lto side.
>>
>>
>> OK, how about the attached patch ?
>
> I cannot approve this but this would have been the patch I would do.

The patch is ok.

Thanks,
Richard.

> Thanks,
> Andrew Pinski
>