Re: RFA: PR 66655: Use COFF/PE weak symbols

2016-01-07 Thread Jeff Law

On 01/07/2016 05:15 AM, Nick Clifton wrote:

Hi Jeff,



The attached patch adds the test derived from the BZ.  There is one
small problem - I could not find a way to stop the additional source
file from being compiled as a test on its own.



I think for C++ code it's usually worked around by naming the
additional-source file with ".cc" rather than .C.  Can you give that a
quick whirl and see if that avoids having the additional file used as a
a test on its own?


Thanks - that worked. :-)

Revised test attached.  OK to apply ?

Yes.

jeff



Re: RFA: PR 66655: Use COFF/PE weak symbols

2016-01-07 Thread Nick Clifton

Hi Jeff,



The attached patch adds the test derived from the BZ.  There is one
small problem - I could not find a way to stop the additional source
file from being compiled as a test on its own.



I think for C++ code it's usually worked around by naming the
additional-source file with ".cc" rather than .C.  Can you give that a
quick whirl and see if that avoids having the additional file used as a
a test on its own?


Thanks - that worked. :-)

Revised test attached.  OK to apply ?

Cheers
  Nick

--- /dev/null	2016-01-07 09:30:14.144966933 +
+++ gcc/testsuite/g++.dg/pr66655.C	2016-01-07 12:13:15.757187619 +
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-additional-sources "pr66655_1.cc" } */
+
+#include "pr66655.h"
+
+extern "C" void abort (void);
+
+#define COOKIE 0xabcd0123
+
+int
+g (void)
+{
+  return COOKIE;
+}
+
+extern int f (void);
+
+int
+main (void)
+{
+  S::set(0);
+  if (f () != COOKIE)
+abort ();
+  return 0;
+}
--- /dev/null	2016-01-07 09:30:14.144966933 +
+++ gcc/testsuite/g++.dg/pr66655_1.cc	2016-01-07 12:04:30.586623022 +
@@ -0,0 +1,14 @@
+#include "pr66655.h"
+
+extern int g (void);
+
+int S::i;
+
+int
+f (void)
+{
+  int ret = g ();
+
+  S::set (ret);
+  return ret;
+}
--- /dev/null	2016-01-07 09:30:14.144966933 +
+++ gcc/testsuite/g++.dg/pr66655.h	2016-01-05 10:41:45.629561622 +
@@ -0,0 +1,5 @@
+struct S
+{
+  static int i;
+  static void set (int ii) { i = -ii; }
+};


Re: RFA: PR 66655: Use COFF/PE weak symbols

2016-01-05 Thread Jeff Law

On 01/05/2016 04:03 AM, Nick Clifton wrote:

Hi Jeff,


You probably know the capabilities of COFF/PE better than I, so the
patch itself is fine.


Thanks - committed.


Is there any way that test can be shoved into our dejagnu testing
harness?  I think we've got support somewhere for tests which require
multiple input files.


dg-additional-sources is the command that you are thinking about.

That's it!




The attached patch adds the test derived from the BZ.  There is one
small problem - I could not find a way to stop the additional source
file from being compiled as a test on its own.  When I investigated
however it seems that is a common problem for all tests that use
additional source files, so I do not think that it is a big issue.
I think for C++ code it's usually worked around by naming the 
additional-source file with ".cc" rather than .C.  Can you give that a 
quick whirl and see if that avoids having the additional file used as a 
a test on its own?


Thanks,
jeff


Re: RFA: PR 66655: Use COFF/PE weak symbols

2016-01-05 Thread Nick Clifton

Hi Jeff,


You probably know the capabilities of COFF/PE better than I, so the
patch itself is fine.


Thanks - committed.


Is there any way that test can be shoved into our dejagnu testing
harness?  I think we've got support somewhere for tests which require
multiple input files.


dg-additional-sources is the command that you are thinking about.


The attached patch adds the test derived from the BZ.  There is one 
small problem - I could not find a way to stop the additional source 
file from being compiled as a test on its own.  When I investigated 
however it seems that is a common problem for all tests that use 
additional source files, so I do not think that it is a big issue.


Tested with no regressions on an x86_64-pc-linux-gnu toolchain.

OK to apply ?

Cheers
  Nick

gcc/testsuite/ChangeLog
2016-01-05  Nick Clifton  

PR target/66655
* g++.dg/pr66655.C: New test.
* g++.dg/pr66655_1.C: Additional source file for the test.
* g++.dg/pr66655.h: Header file for the test.
--- /dev/null	2016-01-05 08:31:00.212966083 +
+++ gcc/testsuite/g++.dg/pr66655.C	2016-01-05 10:42:01.769654305 +
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-additional-sources "pr66655_1.C" } */
+
+#include "pr66655.h"
+
+extern "C" void abort (void);
+
+#define COOKIE 0xabcd0123
+
+int
+g (void)
+{
+  return COOKIE;
+}
+
+extern int f (void);
+
+int
+main (void)
+{
+  S::set(0);
+  if (f () != COOKIE)
+abort ();
+  return 0;
+}
--- /dev/null	2016-01-05 08:31:00.212966083 +
+++ gcc/testsuite/g++.dg/pr66655_1.C	2016-01-05 10:41:23.266433205 +
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include "pr66655.h"
+
+extern int g (void);
+
+int S::i;
+
+int
+f (void)
+{
+  int ret = g ();
+
+  S::set (ret);
+  return ret;
+}
--- /dev/null	2016-01-05 08:31:00.212966083 +
+++ gcc/testsuite/g++.dg/pr66655.h	2016-01-05 10:41:45.629561622 +
@@ -0,0 +1,5 @@
+struct S
+{
+  static int i;
+  static void set (int ii) { i = -ii; }
+};


Re: RFA: PR 66655: Use COFF/PE weak symbols

2016-01-01 Thread Jeff Law

On 12/22/2015 03:17 AM, Nick Clifton wrote:

Hi Guys,

   The patch below is a proposed fix for PR 66655.  The issue I believe
   is not that the ming32 definition of bind_local_p is wrong, but rather
   that G++ thinks that it cannot make the decl weak even though
   bind_local_p says that it should.  The answer is to define
   MAKE_DECL_ONE_ONLY using the COFF/PE weak symbol support now available
   in gas and the linker.  Doing this allows the test to pass.

   OK to apply ?

Cheers
   Nick

gcc/ChangeLog
2015-12-22  Nick Clifton  

PR target/66655
* config/i386/cygming.h (MAKE_DECL_ONE_ONLY): Use weak symbol
support, if available.
You probably know the capabilities of COFF/PE better than I, so the 
patch itself is fine.


Is there any way that test can be shoved into our dejagnu testing 
harness?  I think we've got support somewhere for tests which require 
multiple input files.


Jeff


RFA: PR 66655: Use COFF/PE weak symbols

2015-12-22 Thread Nick Clifton
Hi Guys,

  The patch below is a proposed fix for PR 66655.  The issue I believe
  is not that the ming32 definition of bind_local_p is wrong, but rather
  that G++ thinks that it cannot make the decl weak even though
  bind_local_p says that it should.  The answer is to define
  MAKE_DECL_ONE_ONLY using the COFF/PE weak symbol support now available
  in gas and the linker.  Doing this allows the test to pass.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2015-12-22  Nick Clifton  

PR target/66655
* config/i386/cygming.h (MAKE_DECL_ONE_ONLY): Use weak symbol
support, if available.

Index: config/i386/cygming.h
===
--- config/i386/cygming.h   (revision 231898)
+++ config/i386/cygming.h   (working copy)
@@ -432,6 +432,10 @@
   fputc ('\n', (FILE));   \
 } \
   while (0)
+
+/* Make use of the weak support for ONE_ONLY decls.  */
+#undef  MAKE_DECL_ONE_ONLY
+#define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
 #endif /* HAVE_GAS_WEAK */
 
 /* FIXME: SUPPORTS_WEAK && TARGET_HAVE_NAMED_SECTIONS is true,