Re: error linking lto1 for target avr

2011-11-26 Thread Wim Lewis
FWIW, I ran into this error today as well. I did some brief bisection
to try to narrow down the source; it looks like it broke in r181378:

181736 - undefined reference to c_addr_space_name
181523 - undefined reference to c_addr_space_name
181440 - undefined reference to c_addr_space_name
181395 - undefined reference to c_addr_space_name
181383 - undefined reference to c_addr_space_name
181378 - undefined reference to c_addr_space_name
181377 - compiles
181375 - compiles

I'm configuring with --disable-libquadmath --disable-nls --target=avr 
--program-prefix=avr- --enable-languages=c,lto .

-- 
   Wim Lewis , Seattle, WA, USA. PGP keyID 27F772C1


Re: error linking lto1 for target avr

2011-11-26 Thread Georg-Johann Lay

Sean D'Epagnier schrieb:

I have the latest gcc from svn, and with "configure --target=avr 
--enable-languages=c":

When building with "make" eventually I get:

gcc   -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing 
-Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes 
-Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros 
-Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common  
-DHAVE_CONFIG_H  -o lto1 \
		lto/lto-lang.o lto/lto.o lto/lto-object.o attribs.o main.o tree-browser.o libbackend.a libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a   -lmpc -lmpfr -lgmp -rdynamic -ldl  -L../zlib -lz libcommon.a ../libcpp/libcpp.a   ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a 
libbackend.a(avr.o): In function `avr_pgm_check_var_decl':

/home/sean/build/gcc-svn/build-avr-nofixed/gcc/../../gcc/config/avr/avr.c:6652: 
undefined reference to `c_addr_space_name'
/home/sean/build/gcc-svn/build-avr-nofixed/gcc/../../gcc/config/avr/avr.c:6649: 
undefined reference to `c_addr_space_name'
libbackend.a(avr.o): In function `avr_insert_attributes':
/home/sean/build/gcc-svn/build-avr-nofixed/gcc/../../gcc/config/avr/avr.c:6690: 
undefined reference to `c_addr_space_name'
libbackend.a(avr.o): In function `avr_out_lpm':
/home/sean/build/gcc-svn/build-avr-nofixed/gcc/../../gcc/config/avr/avr.c:2352: 
undefined reference to `c_addr_space_name'
collect2: ld returned 1 exit status

avr.c uses c_addr_space_name to get the names of address spaces for 
diagnostics.  GCC's build machinery does not arrange for this symbol

to be available when linking lto1.  If configured with --disable-lto,
the compiler builds, but lto is unavailable.

This issue is causing trouble for people building the avr toolchain,
and will likely affect other targets as they adopt the use of
c_addr_space_name.  Please suggest a fix.

Sean


In avr.c there is:

...
#include "c-family/c-common.h"
...

/* Sanity check NODE so that all pointers targeting address space
   go along with CONST qualifier.  Writing to this address spaces should
   be detected and complained about as early as possible.  */

static bool
avr_pgm_check_var_decl (tree node)
{
  const char *reason = NULL;

  addr_space_t as = ADDR_SPACE_GENERIC;

  gcc_assert (as == 0);

  if (avr_log.progmem)
avr_edump ("%?: %t\n", node);

  switch (TREE_CODE (node))
{
default:
  break;

case VAR_DECL:
  if (as = avr_nonconst_pointer_addrspace (TREE_TYPE (node)), as)
reason = "variable";
  break;

case PARM_DECL:
  if (as = avr_nonconst_pointer_addrspace (TREE_TYPE (node)), as)
reason = "function parameter";
  break;

case FIELD_DECL:
  if (as = avr_nonconst_pointer_addrspace (TREE_TYPE (node)), as)
reason = "structure field";
  break;

case FUNCTION_DECL:
  if (as = avr_nonconst_pointer_addrspace (TREE_TYPE (TREE_TYPE 
(node))),

  as)
reason = "return type of function";
  break;

case POINTER_TYPE:
  if (as = avr_nonconst_pointer_addrspace (node), as)
reason = "pointer";
  break;
}

  if (reason)
{
  if (TYPE_P (node))
error ("pointer targeting address space %qs must be const in %qT",
   c_addr_space_name (as), node);
  else
error ("pointer targeting address space %qs must be const in %s 
%q+D",

   c_addr_space_name (as), reason, node);
}

  return reason == NULL;
}

Is the problem some missing dependencies in the build machinery for LTO? 
Or must target.c not call functions from c-family/c-common.h?


I configure with --disable-lto because LTO fails in canadian cross 
builds, see http://sourceware.org/PR12742


Johann



Re: error linking lto1 for target avr

2011-11-26 Thread Steven Bosscher
> In avr.c there is:
>
> ...
> #include "c-family/c-common.h"
> ...

That is the problem: avr.c should be language independent. Here you
are trying to link code calling C-family functions in a non-C language
(lto1 is just another front end for gcc, just like
cc1/cc1plus/etc...).

You should use extra target files for language specific target code.
Plenty examples in config/*/*-c.* ...

Ciao!
Steven


gcc-4.7-20111126 is now available

2011-11-26 Thread gccadmin
Snapshot gcc-4.7-2026 is now available on
  ftp://gcc.gnu.org/pub/gcc/snapshots/4.7-2026/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 4.7 SVN branch
with the following options: svn://gcc.gnu.org/svn/gcc/trunk revision 181745

You'll find:

 gcc-4.7-20111126.tar.bz2 Complete GCC

  MD5=48fc89937334522d4e250b5167f92289
  SHA1=98513592f42fbafeddd1a09cdd6aa0b085db2a88

Diffs from 4.7-2019 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-4.7
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.