This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] record extern weak decls in assemble_external
- From: "Rafael Espindola" <espindola at google dot com>
- To: "Diego Novillo" <dnovillo at google dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Thu, 14 Aug 2008 16:03:03 +0100
- Subject: Re: [patch] record extern weak decls in assemble_external
- References: <38a0d8450807240644u34e8a393w4b07d6dc03d3ddee@mail.gmail.com> <38a0d8450807290152i5f34d458q59df1d3a0a99824b@mail.gmail.com> <6dc9ffc80807300843y31312cbdqd30b24962dba1adb@mail.gmail.com> <38a0d8450807300928m10c38a36mf03f8837e215eedc@mail.gmail.com> <38a0d8450807300933u691c4f7axd6e94236a34d96ad@mail.gmail.com> <6dc9ffc80807300940j19e0480bw98cd478779d2465@mail.gmail.com> <38a0d8450807300942v5942cf78j80e670b3c8bb77c@mail.gmail.com> <38a0d8450807300943g72b833c8u4edd987c146eb8ce@mail.gmail.com> <6dc9ffc80807300948q1921bf59j7c383a6c458f41b6@mail.gmail.com> <b798aad50808010700x3f97fdabl277cf2b7319e26d6@mail.gmail.com>
> How did the testing go? Could you post the final form of this patch for review?
My first understanding was that you were referring to the patch that
fixed the build, not the original patch.
An updated patch is attached. I am testing it with a newer trunk.
2008-07-24 Rafael Espindola <espindola@google.com>
* varasm.c (weak_decls): Move earlier in the file.
(assemble_external): Add weak decls to the weak_decls list.
(declare_weak): Don't add decls to the weak_decls list.
>
> Thanks. Diego.
>
Cheers,
--
Rafael Avila de Espindola
Google Ireland Ltd.
Gordon House
Barrow Street
Dublin 4
Ireland
Registered in Dublin, Ireland
Registration Number: 368047
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 941716f..863ffd0 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2286,6 +2286,10 @@ process_pending_assemble_externals (void)
#endif
}
+/* This TREE_LIST contains any weak symbol declarations waiting
+ to be emitted. */
+static GTY(()) tree weak_decls;
+
/* Output something to declare an external symbol to the assembler.
(Most assemblers don't need this, so we normally output nothing.)
Do nothing if DECL is not external. */
@@ -2303,6 +2307,9 @@ assemble_external (tree decl ATTRIBUTE_UNUSED)
if (!DECL_P (decl) || !DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl))
return;
+ if (SUPPORTS_WEAK && DECL_WEAK (decl))
+ weak_decls = tree_cons (NULL, decl, weak_decls);
+
/* We want to output external symbols at very last to check if they
are references or not. */
pending_assemble_externals = tree_cons (0, decl,
@@ -4846,10 +4853,6 @@ output_constructor (tree exp, unsigned HOST_WIDE_INT size,
assemble_zeros (size - total_bytes);
}
-/* This TREE_LIST contains any weak symbol declarations waiting
- to be emitted. */
-static GTY(()) tree weak_decls;
-
/* Mark DECL as weak. */
static void
@@ -4942,12 +4945,7 @@ declare_weak (tree decl)
error ("weak declaration of %q+D must be public", decl);
else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
error ("weak declaration of %q+D must precede definition", decl);
- else if (SUPPORTS_WEAK)
- {
- if (! DECL_WEAK (decl))
- weak_decls = tree_cons (NULL, decl, weak_decls);
- }
- else
+ else if (!SUPPORTS_WEAK)
warning (0, "weak declaration of %q+D not supported", decl);
mark_weak (decl);