re PR target/42457 (AVR fails to build with other than C family languages)
authorAndy Hutchinson <hutchinsonandy@gcc.gnu.org>
Thu, 24 Dec 2009 20:32:38 +0000 (20:32 +0000)
committerAndy Hutchinson <hutchinsonandy@gcc.gnu.org>
Thu, 24 Dec 2009 20:32:38 +0000 (20:32 +0000)
2009-12-24  Andy Hutchinson  <hutchinsonandy@gcc.gnu.org>

PR target/42457
* config/avr/avr.c (avr_extra_arch_macro): Remove static.
(avr_cpu_cpp_builtins): Remove.
* config/avr/avr.h (avr_extra_arch_macro): Add prototype.
* config/avr/avr-c.c: New File.
(avr_cpu_cpp_builtins) : Add.
* config/avr/t-avr: Add make information for avr-c.
* config.gcc (avr-*-*): Include avr-c.o as c and cpp object.

From-SVN: r155460

gcc/ChangeLog
gcc/config.gcc
gcc/config/avr/avr-c.c [new file with mode: 0644]
gcc/config/avr/avr.c
gcc/config/avr/avr.h
gcc/config/avr/t-avr

index 786021818a6d434d92135fdcbaf655f84547ffe3..e0a5ae34d388fe6a9f12fc2d6df2225b8c94b849 100644 (file)
@@ -1,3 +1,14 @@
+2009-12-24  Andy Hutchinson  <hutchinsonandy@gcc.gnu.org>
+
+       PR target/42457
+       * config/avr/avr.c (avr_extra_arch_macro): Remove static.
+       (avr_cpu_cpp_builtins): Remove.
+       * config/avr/avr.h (avr_extra_arch_macro): Add prototype.
+       * config/avr/avr-c.c: New File.
+       (avr_cpu_cpp_builtins) : Add.
+       * config/avr/t-avr: Add make information for avr-c.
+       * config.gcc (avr-*-*): Include avr-c.o as c and cpp object. 
+
 2009-12-24  Andy Hutchinson  <hutchinsonandy@gcc.gnu.org>
 
        PR target/35013, 27192
index d319157a4492e9167868661befe410ef7bffaa76..59fa4d78d9c3e7731043e76132e226f8a47b239a 100644 (file)
@@ -266,6 +266,11 @@ arm*-*-*)
        c_target_objs="arm-c.o"
        cxx_target_objs="arm-c.o"
        ;;
+avr-*-*)
+       cpu_type=avr
+       c_target_objs="avr-c.o"
+       cxx_target_objs="avr-c.o"
+       ;;
 bfin*-*)
        cpu_type=bfin
        ;;
diff --git a/gcc/config/avr/avr-c.c b/gcc/config/avr/avr-c.c
new file mode 100644 (file)
index 0000000..05c9496
--- /dev/null
@@ -0,0 +1,85 @@
+/* Copyright (C) 2009\r
+   Free Software Foundation, Inc.\r
+   Contributed by Anatoly Sokolov (aesok@post.ru)\r
+\r
+   This file is part of GCC.\r
+\r
+   GCC is free software; you can redistribute it and/or modify\r
+   it under the terms of the GNU General Public License as published by\r
+   the Free Software Foundation; either version 3, or (at your option)\r
+   any later version.\r
+   \r
+   GCC is distributed in the hope that it will be useful,\r
+   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+   GNU General Public License for more details.\r
+   \r
+   You should have received a copy of the GNU General Public License\r
+   along with GCC; see the file COPYING3.  If not see\r
+   <http://www.gnu.org/licenses/>.  */\r
+\r
+\r
+#include "config.h"\r
+#include "system.h"\r
+#include "coretypes.h"\r
+#include "tm.h"\r
+#include "tm_p.h"\r
+#include "regs.h"\r
+#include "c-common.h"\r
+\r
+\r
+/* Not included in avr.c since this requires C front end.  */\r
+\r
+/* Worker function for TARGET_CPU_CPP_BUILTINS.  */\r
+\r
+void\r
+avr_cpu_cpp_builtins (struct cpp_reader *pfile)\r
+{\r
+  builtin_define_std ("AVR");\r
+\r
+  if (avr_current_arch->macro)\r
+    cpp_define (pfile, avr_current_arch->macro);\r
+  if (avr_extra_arch_macro)\r
+    cpp_define (pfile, avr_extra_arch_macro);\r
+  if (avr_current_arch->have_elpm)\r
+    cpp_define (pfile, "__AVR_HAVE_RAMPZ__");\r
+  if (avr_current_arch->have_elpm)\r
+    cpp_define (pfile, "__AVR_HAVE_ELPM__");\r
+  if (avr_current_arch->have_elpmx)\r
+    cpp_define (pfile, "__AVR_HAVE_ELPMX__");\r
+  if (avr_current_arch->have_movw_lpmx)\r
+    {\r
+      cpp_define (pfile, "__AVR_HAVE_MOVW__");\r
+      cpp_define (pfile, "__AVR_HAVE_LPMX__");\r
+    }\r
+  if (avr_current_arch->asm_only)\r
+    cpp_define (pfile, "__AVR_ASM_ONLY__");\r
+  if (avr_current_arch->have_mul)\r
+    {\r
+      cpp_define (pfile, "__AVR_ENHANCED__");\r
+      cpp_define (pfile, "__AVR_HAVE_MUL__");\r
+    }\r
+  if (avr_current_arch->have_jmp_call)\r
+    {\r
+      cpp_define (pfile, "__AVR_MEGA__");\r
+      cpp_define (pfile, "__AVR_HAVE_JMP_CALL__");\r
+    }\r
+  if (avr_current_arch->have_eijmp_eicall)\r
+    {\r
+      cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__");\r
+      cpp_define (pfile, "__AVR_3_BYTE_PC__");\r
+    }\r
+  else\r
+    {\r
+      cpp_define (pfile, "__AVR_2_BYTE_PC__");\r
+    }\r
+\r
+  if (avr_current_device->short_sp)\r
+    cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");\r
+  else\r
+    cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");\r
+\r
+  if (TARGET_NO_INTERRUPTS)\r
+    cpp_define (pfile, "__NO_INTERRUPTS__");\r
+}\r
+\r
index eff2179b93d62b233d74fb0c37d3e973105bfe13..83ee0efe0ccad0a4bbf1ff1c5b3a3c10f8d7261f 100644 (file)
@@ -105,7 +105,7 @@ static GTY(()) rtx zero_reg_rtx;
 static const char *const avr_regnames[] = REGISTER_NAMES;
 
 /* Preprocessor macros to define depending on MCU type.  */
-static const char *avr_extra_arch_macro;
+const char *avr_extra_arch_macro;
 
 /* Current architecture.  */
 const struct base_arch_s *avr_current_arch;
@@ -223,59 +223,6 @@ avr_override_options (void)
   init_machine_status = avr_init_machine_status;
 }
 
-/* Worker function for TARGET_CPU_CPP_BUILTINS.  */
-
-void
-avr_cpu_cpp_builtins (struct cpp_reader *pfile)
-{
-  builtin_define_std ("AVR");
-
-  if (avr_current_arch->macro)
-    cpp_define (pfile, avr_current_arch->macro);
-  if (avr_extra_arch_macro)
-    cpp_define (pfile, avr_extra_arch_macro);
-  if (avr_current_arch->have_elpm)
-    cpp_define (pfile, "__AVR_HAVE_RAMPZ__");
-  if (avr_current_arch->have_elpm)
-    cpp_define (pfile, "__AVR_HAVE_ELPM__");
-  if (avr_current_arch->have_elpmx)
-    cpp_define (pfile, "__AVR_HAVE_ELPMX__");
-  if (avr_current_arch->have_movw_lpmx)
-    {
-      cpp_define (pfile, "__AVR_HAVE_MOVW__");
-      cpp_define (pfile, "__AVR_HAVE_LPMX__");
-    }
-  if (avr_current_arch->asm_only)
-    cpp_define (pfile, "__AVR_ASM_ONLY__");
-  if (avr_current_arch->have_mul)
-    {
-      cpp_define (pfile, "__AVR_ENHANCED__");
-      cpp_define (pfile, "__AVR_HAVE_MUL__");
-    }
-  if (avr_current_arch->have_jmp_call)
-    {
-      cpp_define (pfile, "__AVR_MEGA__");
-      cpp_define (pfile, "__AVR_HAVE_JMP_CALL__");
-    }
-  if (avr_current_arch->have_eijmp_eicall)
-    {
-      cpp_define (pfile, "__AVR_HAVE_EIJMP_EICALL__");
-      cpp_define (pfile, "__AVR_3_BYTE_PC__");
-    }
-  else
-    {
-      cpp_define (pfile, "__AVR_2_BYTE_PC__");
-    }
-
-  if (avr_current_device->short_sp)
-    cpp_define (pfile, "__AVR_HAVE_8BIT_SP__");
-  else
-    cpp_define (pfile, "__AVR_HAVE_16BIT_SP__");
-
-  if (TARGET_NO_INTERRUPTS)
-    cpp_define (pfile, "__NO_INTERRUPTS__");
-}
-
 /*  return register class from register number.  */
 
 static const enum reg_class reg_class_tab[]={
index 2e885604333197bdfc6a2f2f5af9297c921600a6..265c16155f3cb936c16f357c43c8f17981366dc1 100644 (file)
@@ -97,6 +97,8 @@ struct mcu_type_s {
   const char *const library_name; 
 };
 
+/* Preprocessor macros to define depending on MCU type.  */
+extern const char *avr_extra_arch_macro;
 extern const struct base_arch_s *avr_current_arch;
 extern const struct mcu_type_s *avr_current_device;
 extern const struct mcu_type_s avr_mcu_types[];
index 58656179b8a2b2ad43c0530992e193f65a9c40ec..91d1fe86fbc8d05024bba291864113b2e0a06411 100644 (file)
@@ -24,6 +24,13 @@ driver-avr.o: $(srcdir)/config/avr/driver-avr.c \
 avr-devices.o: $(srcdir)/config/avr/avr-devices.c \
   $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
        $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+       
+
+avr-c.o: $(srcdir)/config/avr/avr-c.c \
+  $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
+       $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+       
+
 
 LIB1ASMSRC = avr/libgcc.S
 LIB1ASMFUNCS = \