pkgsrc/lang/gcc/patches/patch-af
jtb 3f9c40bb8e Add some patches against basesrc gcc implementing the "if-exists"
function in the specs file.  Enables the linker to pick
up crti.o and crtn.o if they exist.
2003-07-12 08:53:40 +00:00

161 lines
5.3 KiB
Text

$NetBSD: patch-af,v 1.9 2003/07/12 08:53:40 jtb Exp $
--- ../gcc-2.95.3/gcc/config/netbsd.h
+++ ../gcc-2.95.3/gcc/config/netbsd.h.orig
@@ -36,10 +36,13 @@
/* Provide a CPP_SPEC appropriate for NetBSD. Current we just deal with
- the GCC option `-posix'. */
+ the GCC option `-posix'. We also deal with -pthread, which is required
+ for the 2.95.3 STL to work. */
#undef CPP_SPEC
-#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE}"
+#define CPP_SPEC \
+ "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \
+ %{pthread:-D_REENTRANT -D_PTHREADS}"
/* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal
with the options for generating PIC code. */
@@ -54,7 +57,8 @@
#undef LIB_SPEC
#define LIB_SPEC \
- "%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}} \
+ "%{pthread:%{!p:%{!pg:-lpthread}}%{p:-lpthread_p}%{pg:-lpthread_p}} \
+ %{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}} \
%{!shared:%{!symbolic:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}}"
/* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude
@@ -64,7 +68,7 @@
#ifdef NETBSD_NATIVE
#define LIBGCC_SPEC "%{!symbolic:%{!shared:%{!p:%{!pg:-lgcc}}}%{shared:-lgcc_pic}%{p:-lgcc_p}%{pg:-lgcc_p}}"
#else
-#define LIBGCC_SPEC "%{!shared:%{!symbolic:-lgcc}}"
+#define LIBGCC_SPEC "%{!symbolic:%{!shared:-lgcc}%{shared:-lgcc_pic}}"
#endif
/* #ifdef NETBSD_AOUT */
@@ -147,6 +151,96 @@
#define ASM_DECLARE_RESULT(FILE, RESULT)
#endif
+/* NetBSD a.out support begins here. */
+
+#ifndef NETBSD_ELF
+
+#undef DWARF_DEBUGGING_INFO /* XXX */
+#undef DWARF2_DEBUGGING_INFO /* XXX */
+
+/* Write the extra assembler code needed to declare a function properly.
+ Some svr4 assemblers need to also have something extra said about the
+ function's return value. We allow for that here. */
+
+#undef ASM_DECLARE_FUNCTION_NAME
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
+ do { \
+ fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ putc (',', FILE); \
+ fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
+ putc ('\n', FILE); \
+ ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
+ ASM_OUTPUT_LABEL(FILE, NAME); \
+ } while (0)
+
+/* Write the extra assembler code needed to declare an object properly. */
+
+#undef ASM_DECLARE_OBJECT_NAME
+#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
+ do { \
+ fprintf (FILE, "\t%s\t ", TYPE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ putc (',', FILE); \
+ fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
+ putc ('\n', FILE); \
+ size_directive_output = 0; \
+ if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
+ { \
+ size_directive_output = 1; \
+ fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
+ } \
+ ASM_OUTPUT_LABEL(FILE, NAME); \
+ } while (0)
+
+/* Output the size directive for a decl in rest_of_decl_compilation
+ in the case where we did not do so before the initializer.
+ Once we find the error_mark_node, we know that the value of
+ size_directive_output was set
+ by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
+
+#undef ASM_FINISH_DECLARE_OBJECT
+#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
+do { \
+ char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
+ if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
+ && ! AT_END && TOP_LEVEL \
+ && DECL_INITIAL (DECL) == error_mark_node \
+ && !size_directive_output) \
+ { \
+ size_directive_output = 1; \
+ fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
+ assemble_name (FILE, name); \
+ fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
+ } \
+ } while (0)
+
+/* This is how to declare the size of a function. */
+
+#undef ASM_DECLARE_FUNCTION_SIZE
+#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
+ do { \
+ if (!flag_inhibit_size_directive) \
+ { \
+ char label[256]; \
+ static int labelno; \
+ labelno++; \
+ ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
+ ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
+ fprintf (FILE, "\t%s\t ", SIZE_ASM_OP); \
+ assemble_name (FILE, (FNAME)); \
+ fprintf (FILE, ","); \
+ assemble_name (FILE, label); \
+ fprintf (FILE, "-"); \
+ assemble_name (FILE, (FNAME)); \
+ putc ('\n', FILE); \
+ } \
+ } while (0)
+
+#endif
+
/* NetBSD ELF support begins here. */
#ifdef NETBSD_ELF
@@ -167,6 +261,7 @@
%{!pg: \
%{p:gcrt0%O%s} \
%{!p:crt0%O%s}}} \
+ %:if-exists(crti%O%s) \
%{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}"
/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF targets. Here we
@@ -175,13 +270,14 @@
#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
- "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
+ "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
+ %:if-exists(crtn%O%s)"
/* Provide a LINK_SPEC appropriate for a NetBSD ELF target. */
#undef LINK_SPEC
#define LINK_SPEC \
- "%{assert*} \
+ "%{assert*} %{R*} \
%{shared:-shared} \
%{!shared: \
-dc -dp \