This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

__DTOR_LIST__ and __CTOR_END__ undeclared when portting to new ARM target


Hi All,

I'm trying to port GCC 5.2.0 (with intention to send it here later)
for new target OS - Phoenix-RTOS. However I'm experiencing compilation
error and I can't figure out why. Port is supposed to work for ARM
Cortex-A5.

Here is my patch, that I try to apply:
---------------------------------------------------------------
diff -Nrdu gcc-5.2.0/config.sub gcc-5.2.0_phoenix/config.sub
--- gcc-5.2.0/config.sub 2015-01-02 10:30:21.000000000 +0100
+++ gcc-5.2.0_phoenix/config.sub 2016-03-31 15:09:01.559741852 +0200
@@ -1527,6 +1527,9 @@
  ;;
  -none)
  ;;
+ -phoenix*)
+ os=-phoenix
+ ;;
  *)
  # Get rid of the `-' at the beginning of $os.
  os=`echo $os | sed 's/[^-]*-//'`
diff -Nrdu gcc-5.2.0/gcc/config/arm/t-phoenix
gcc-5.2.0_phoenix/gcc/config/arm/t-phoenix
--- gcc-5.2.0/gcc/config/arm/t-phoenix 1970-01-01 01:00:00.000000000 +0100
+++ gcc-5.2.0_phoenix/gcc/config/arm/t-phoenix 2016-04-01
14:21:05.808343437 +0200
@@ -0,0 +1,29 @@
+# Copyright (C) 1998-2015 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+MULTILIB_OPTIONS     = marm/mthumb
+MULTILIB_DIRNAMES    = arm thumb
+MULTILIB_EXCEPTIONS  =
+MULTILIB_MATCHES     =
+
+MULTILIB_OPTIONS     += mfloat-abi=hard
+MULTILIB_DIRNAMES    += fpu
+MULTILIB_MATCHES     += mfloat-abi?hard=mhard-float
+
+MULTILIB_OPTIONS     += mno-thumb-interwork/mthumb-interwork
+MULTILIB_DIRNAMES    += normal interwork
diff -Nrdu gcc-5.2.0/gcc/config/phoenix.h gcc-5.2.0_phoenix/gcc/config/phoenix.h
--- gcc-5.2.0/gcc/config/phoenix.h 1970-01-01 01:00:00.000000000 +0100
+++ gcc-5.2.0_phoenix/gcc/config/phoenix.h 2016-04-01 12:54:35.632836509 +0200
@@ -0,0 +1,32 @@
+/* Copyright (C) 1998-2015 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>. */
+
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS()      \
+    do {                                \
+      builtin_define_std ("phoenix");      \
+      builtin_define_std ("unix");      \
+      builtin_assert ("system=phoenix");   \
+      builtin_assert ("system=unix");   \
+    } while(0);
+
+#define STD_LIB_SPEC "%{!shared:%{g*:-lg}
%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
+
+/* This will prevent selecting 'unsigned long int' instead of
'unsigned int' as 'uint32_t' in stdint-newlib.h. */
+#undef STDINT_LONG32
+#define STDINT_LONG32 0
diff -Nrdu gcc-5.2.0/gcc/config.gcc gcc-5.2.0_phoenix/gcc/config.gcc
--- gcc-5.2.0/gcc/config.gcc 2015-07-02 17:53:33.000000000 +0200
+++ gcc-5.2.0_phoenix/gcc/config.gcc 2016-04-06 09:54:51.150181809 +0200
@@ -868,6 +868,11 @@
     *) echo 'Unknown thread configuration for VxWorks'; exit 1 ;;
   esac
   ;;
+*-*-phoenix*)
+  gas=yes
+  gnu_ld=yes
+  default_use_cxa_atexit=yes
+  ;;
 *-*-elf|arc*-*-elf*)
   # Assume that newlib is being used and so __cxa_atexit is provided.
   default_use_cxa_atexit=yes
@@ -1088,6 +1093,10 @@
  esac
  tm_file="${tm_file} arm/aout.h vxworks-dummy.h arm/arm.h"
  ;;
+arm*-*-phoenix*)
+ tm_file="dbxelf.h elfos.h newlib-stdint.h arm/unknown-elf.h
arm/elf.h arm/aout.h phoenix.h arm/arm.h"
+ tmake_file="${tmake_file} arm/t-arm arm/t-phoenix"
+ ;;
 avr-*-rtems*)
  tm_file="elfos.h avr/elf.h avr/avr-arch.h avr/avr.h avr/specs.h
dbxelf.h avr/rtems.h rtems.h newlib-stdint.h"
  tm_defines="${tm_defines} WITH_RTEMS"
diff -Nrdu gcc-5.2.0/libgcc/config/arm/t-phoenix
gcc-5.2.0_phoenix/libgcc/config/arm/t-phoenix
--- gcc-5.2.0/libgcc/config/arm/t-phoenix 1970-01-01 01:00:00.000000000 +0100
+++ gcc-5.2.0_phoenix/libgcc/config/arm/t-phoenix 2016-04-05
10:31:15.881370580 +0200
@@ -0,0 +1 @@
+HOST_LIBGCC2_CFLAGS += -mthumb-interwork
diff -Nrdu gcc-5.2.0/libgcc/config.host gcc-5.2.0_phoenix/libgcc/config.host
--- gcc-5.2.0/libgcc/config.host 2015-06-25 19:55:02.000000000 +0200
+++ gcc-5.2.0_phoenix/libgcc/config.host 2016-04-05 10:37:14.127783472 +0200
@@ -408,6 +408,10 @@
  tmake_file="$tmake_file t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp"
  unwind_header=config/arm/unwind-arm.h
  ;;
+arm*-*-phoenix*)
+ tmake_file="t-hardfp t-softfp arm/t-arm arm/t-elf arm/t-softfp arm/t-phoenix"
+ extra_parts="crtbegin.o crtend.o crti.o crtn.o"
+ ;;
 avr-*-rtems*)
  tmake_file="$tmake_file avr/t-avr avr/t-rtems t-fpbit"
  tm_file="$tm_file avr/avr-lib.h"
---------------------------------------------------------------

And here is compilation error:
---------------------------------------------------------------
Adding multilib support to Makefile in
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc
with_multisubdir=thumb/fpu/interwork
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:
In function '__do_global_dtors_aux':
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:404:26:
error: '__DTOR_LIST__' undeclared (first use in this function)
     static func_ptr *p = __DTOR_LIST__ + 1;
                          ^
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:404:26:
note: each undeclared identifier is reported only once for each
function it appears in
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:
In function '__do_global_ctors_aux':
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:706:12:
error: '__CTOR_END__' undeclared (first use in this function)
   for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
            ^
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:706:12:
note: each undeclared identifier is reported only once for each
function it appears in
Makefile:983: recipe for target 'crtbegin.o' failed
make[2]: *** [crtbegin.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Makefile:986: recipe for target 'crtend.o' failed
make[2]: *** [crtend.o] Error 1
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:
In function '__do_global_dtors_aux':
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:404:26:
error: '__DTOR_LIST__' undeclared (first use in this function)
     static func_ptr *p = __DTOR_LIST__ + 1;
                          ^
/home/kuba/Projects/phoenix-rtos/toolchain/arm/gcc-5.2.0/libgcc/crtstuff.c:404:26:
note: each undeclared identifier is reported only once for each
function it appears in
Makefile:983: recipe for target 'crtbegin.o' failed
make[4]: *** [crtbegin.o] Error 1
Makefile:1154: recipe for target 'multi-do' failed
make[3]: *** [multi-do] Error 1
Makefile:117: recipe for target 'all-multi' failed
make[2]: *** [all-multi] Error 2
Makefile:10963: recipe for target 'all-target-libgcc' failed
make[1]: *** [all-target-libgcc] Error 2
Makefile:87: recipe for target 'toolchain' failed
make: *** [toolchain] Error 2
---------------------------------------------------------------

I have noticed, that hacking gcc/config/arm/arm.h like this, does the trick:

diff -Nrdu gcc-5.2.0/gcc/config/arm/arm.h gcc-5.2.0_phoenix/gcc/config/arm/arm.h
--- gcc-5.2.0/gcc/config/arm/arm.h 2015-02-26 05:03:22.000000000 +0100
+++ gcc-5.2.0_phoenix/gcc/config/arm/arm.h 2016-04-06 10:01:20.728612662 +0200
@@ -1905,7 +1905,7 @@
 #else /* !defined (IN_LIBGCC2) */
 /* In libgcc, CTORS_SECTION_ASM_OP must be a compile-time constant,
    so we cannot use the definition above.  */
-# ifdef __ARM_EABI__
+# if 0 /* def __ARM_EABI__ */
 /* The .ctors section is not part of the EABI, so we do not define
    CTORS_SECTION_ASM_OP when in libgcc; that prevents crtstuff
    from trying to use it.  We do define it when doing normal

I call configure like this:
./configure --target=$CROSS_TARGET --prefix=$TOOLCHAIN_ROOT
--enable-languages=c --disable-libssp --with-gmp=$TOOLCHAIN_ROOT
--with-mpfr=$TOOLCHAIN_ROOT --with-mpc=$TOOLCHAIN_ROOT --disable-nls
--with-newlib --with-sysroot=${TOOLCHAIN_ROOT}${CROSS_TARGET}
--with-arch=armv7-a --with-fpu=neon-vfpv4 --with-mode=thumb
--with-abi=aapcs --enable-interwork

Can anyone help me?
Thanks,
Jakub Sejdak


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]