diff mbox

coverage, propagate visibility

Message ID 4EC18F3D.60400@acm.org
State New
Headers show

Commit Message

Nathan Sidwell Nov. 14, 2011, 9:59 p.m. UTC
This patch propagates visibility information in the same way that weakness is 
for externally visible coverage objects.  I don't know whether this will fix the 
reported firefox build failure -- can you try?  Even if it doesn't, I'm pretty 
sure it's an improvement, but I'll leave it for comment before committing eitherway.

built & tested on i686-pc-linux-gnu.

nathan
2011-11-14  Nathan Sidwell  <nathan@acm.org>

	PR gcov-profile/51113
	* coverage.c (build_var): Propagate visibility for public decls.

	testsuite/
	* gcc.misc-tests/gcov-16.c: New.
	* gcc.misc-tests/gcov-17.c: New.
	* g++.dg/gcov/gcov-8.C: New.
	* g++.dg/gcov/gcov-9.C: New.

Comments

Markus Trippelsdorf Nov. 14, 2011, 10:33 p.m. UTC | #1
On 2011.11.14 at 21:59 +0000, Nathan Sidwell wrote:
> This patch propagates visibility information in the same way that weakness is 
> for externally visible coverage objects.  I don't know whether this will fix the 
> reported firefox build failure -- can you try? 

The patch doesn't help unfortunately. I still get the same
"error: hidden symbol '_ZN2js11WeakMapBaseD0Ev' is not defined locally"
messages when linking (firefox's) js.
Nathan Sidwell Nov. 15, 2011, 7:09 a.m. UTC | #2
On 11/14/11 22:33, Markus Trippelsdorf wrote:
> On 2011.11.14 at 21:59 +0000, Nathan Sidwell wrote:
>> This patch propagates visibility information in the same way that weakness is
>> for externally visible coverage objects.  I don't know whether this will fix the
>> reported firefox build failure -- can you try?
>
> The patch doesn't help unfortunately. I still get the same
> "error: hidden symbol '_ZN2js11WeakMapBaseD0Ev' is not defined locally"
> messages when linking (firefox's) js.

bum.  I'm not sure how my patch could have changed the set of emitted functions 
-- gonna need a testcase.   With a working toolchain, what object file(s) 
contain the definition of _ZN2js11WeakMapBaseD0Ev?  Can you provide that file's 
preprocessed source and the exact compile line?
Markus Trippelsdorf Nov. 15, 2011, 7:55 a.m. UTC | #3
On 2011.11.15 at 07:09 +0000, Nathan Sidwell wrote:
> On 11/14/11 22:33, Markus Trippelsdorf wrote:
> > On 2011.11.14 at 21:59 +0000, Nathan Sidwell wrote:
> >> This patch propagates visibility information in the same way that weakness is
> >> for externally visible coverage objects.  I don't know whether this will fix the
> >> reported firefox build failure -- can you try?
> >
> > The patch doesn't help unfortunately. I still get the same
> > "error: hidden symbol '_ZN2js11WeakMapBaseD0Ev' is not defined locally"
> > messages when linking (firefox's) js.
> 
> bum.  I'm not sure how my patch could have changed the set of emitted functions 
> -- gonna need a testcase.   With a working toolchain, what object file(s) 
> contain the definition of _ZN2js11WeakMapBaseD0Ev?  Can you provide that file's 
> preprocessed source and the exact compile line?

Nothing changed the set of emitted functions. The error message above
was just an example. Will post the full error message in the PR (51113).
I will also try to come up with a smaller testcase.
Nathan Sidwell Nov. 15, 2011, 8:10 a.m. UTC | #4
On 11/15/11 07:55, Markus Trippelsdorf wrote:

> Nothing changed the set of emitted functions. The error message above
> was just an example. Will post the full error message in the PR (51113).
> I will also try to come up with a smaller testcase.

Something's changed the linkage of ZN2js11WeakMapBaseD0Ev though.  Where is it 
being emitted?  Anyway, a small testcase would certainly be helpful.
diff mbox

Patch

Index: coverage.c
===================================================================
--- coverage.c	(revision 181347)
+++ coverage.c	(working copy)
@@ -674,6 +674,13 @@  build_var (tree fn_decl, tree type, int
     {
       TREE_PUBLIC (var) = TREE_PUBLIC (fn_decl);
       TREE_STATIC (var) = TREE_STATIC (fn_decl);
+      if (TREE_PUBLIC (var))
+	{
+	  DECL_WEAK (var) = DECL_WEAK (fn_decl);
+	  DECL_VISIBILITY (var) = DECL_VISIBILITY (fn_decl);
+	  DECL_VISIBILITY_SPECIFIED (var)
+	    = DECL_VISIBILITY_SPECIFIED (fn_decl);
+	}
     }
   TREE_ADDRESSABLE (var) = 1;
   DECL_ALIGN (var) = TYPE_ALIGN (type);
@@ -688,7 +695,6 @@  build_var (tree fn_decl, tree type, int
   if (TREE_PUBLIC (var))
     DECL_ASSEMBLER_NAME (var);    
 
-  DECL_WEAK (var) = TREE_PUBLIC (var) && DECL_WEAK (fn_decl);
   DECL_COMDAT (var) = DECL_COMDAT (fn_decl);
   DECL_COMDAT_GROUP (var) = DECL_COMDAT_GROUP (fn_decl);
 
Index: testsuite/gcc.misc-tests/gcov-16.c
===================================================================
--- testsuite/gcc.misc-tests/gcov-16.c	(revision 0)
+++ testsuite/gcc.misc-tests/gcov-16.c	(revision 0)
@@ -0,0 +1,10 @@ 
+/* Test visibility is copied */
+
+/* { dg-options "-fprofile-arcs -fvisibility=hidden" } */
+/* { dg-require-visibility "" } */
+
+void Foo ()
+{
+}
+
+ /* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */
Index: testsuite/gcc.misc-tests/gcov-17.c
===================================================================
--- testsuite/gcc.misc-tests/gcov-17.c	(revision 0)
+++ testsuite/gcc.misc-tests/gcov-17.c	(revision 0)
@@ -0,0 +1,10 @@ 
+/* Test visibility is copied */
+
+/* { dg-options "-fprofile-arcs" } */
+/* { dg-require-visibility "" } */
+
+void __attribute__ ((visibility ("hidden"))) Foo ()
+{
+}
+
+/* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */
Index: testsuite/g++.dg/gcov/gcov-8.C
===================================================================
--- testsuite/g++.dg/gcov/gcov-8.C	(revision 0)
+++ testsuite/g++.dg/gcov/gcov-8.C	(revision 0)
@@ -0,0 +1,13 @@ 
+/* { dg-options "-fprofile-arcs -fvisibility=hidden" } */
+/* { dg-require-visibility "" } */
+
+struct __attribute__((visibility ("hidden"))) X
+{
+  void Fink ();
+};
+
+void X::Fink ()
+{
+}
+
+/* { dg-final { scan-assembler "\\.hidden\t__gcov___ZN1X4FinkEv" } } */
Index: testsuite/g++.dg/gcov/gcov-9.C
===================================================================
--- testsuite/g++.dg/gcov/gcov-9.C	(revision 0)
+++ testsuite/g++.dg/gcov/gcov-9.C	(revision 0)
@@ -0,0 +1,15 @@ 
+/* { dg-options "-fprofile-arcs -fvisibility-inlines-hidden" } */
+/* { dg-require-visibility "" } */
+
+inline void Boo ()
+{
+}
+
+extern "C" void (*Foo ()) ()
+{
+  return Boo;
+}
+
+/* { dg-final { scan-assembler "\\.hidden\t__gcov___Z3Boov" } } */
+/* { dg-final { scan-assembler "__gcov__Foo:" } } */
+/* { dg-final { scan-assembler-not "\\.hidden\t__gcov__Foo" } } */