[Bug preprocessor/58939] New: Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors

2013-10-31 Thread chaselton at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58939

Bug ID: 58939
   Summary: Cannot Cross-Build Android Native GCC 4.8 libcpp build
conversion errors
   Product: gcc
   Version: 4.8.0
Status: UNCONFIRMED
  Severity: blocker
  Priority: P3
 Component: preprocessor
  Assignee: unassigned at gcc dot gnu.org
  Reporter: chaselton at gmail dot com

GCC Cross-Tools Version:  
4.8...specifically the Android NDK version 4.8 generated by the
make-standalone-toolchain.sh script

GCC Build System Version:
4.7.2

System:
CentOS 6.2

Configure Options:
 sudo sh ../gcc-4.8/configure --build=x86_64-redhat-linux
--host=arm-linux-androideabi --disable-ld
--with-as=/opt/gcc-4.8/armv1/usr/local/arm-linux-androideabi/bin/as
--with-ld=/opt/gcc-4.8/armv1/usr/local/arm-linux-androideabi/bin/ld
--enable-version-specific-runtime-libs --enable-libmudflap=no --enable-nls=no
--enable-shared --enable-languages=c --disable-libatomic --disable-bootstrap
-disable-gold --disable-libstdcxx --disable-fortran --disable-libssp
--disable-ppl --disable-libquadmath --disable-libquadmath-support
--disable-libada --disable-werror --enable-multilib=no --disable-libgomp
--disable-cloog --with-sysroot=/usr/sysroot
--with-build-time-tools=/opt/centos/devtoolset-1.1/root/usr/bin
CC=arm-linux-androideabi-gcc CFLAGS='-Wall -O2 -mandroid -mbionic'
LDFLAGS=-Wl,--sysroot=/usr/sysroot,--verbose LIBCFLAGS='-O2 -mandroid -mbionic'
LIBCPPFLAGS='-O2 -mandroid -mbionic' LIBCXXFLAGS='-O2 -mandroid -mbionic
-fno-implicit-templates' LIBS='-lgcc -lc -ldl -lm'
CXX=arm-linux-androideabi-g++ AR=arm-linux-androideabi-ar
AS=arm-linux-androideabi-as LD=arm-linux-androideabi-ld
NM=arm-linux-androideabi-nm RANLIB=arm-linux-androideabi-ranlib
STRIP=arm-linux-androideabi-strip OBJCOPY=arm-linux-androideabi-objcopy
OBJDUMP=arm-linux-androideabi-objcopy READELF=arm-linux-androideabi-readelf
LD_FOR_TARGET=arm-linux-androideabi-ld NM_FOR_TARGET=arm-linux-androideabi-nm
CC_FOR_TARGET=arm-linux-androideabi-gcc
CPP_FOR_TARGET=arm-linux-androideabi-gcc
CXX_FOR_TARGET=arm-linux-androideabi-g++
GCC_FOR_TARGET=arm-linux-androideabi-gcc
RANLIB_FOR_TARGET=arm-linux-androideabi-gcc-ranlib
LD_FOR_TARGET=arm-linux-androideabi-ld AS_FOR_TARGET=arm-linux-androideabi-as
NM_FOR_TARGET=arm-linux-androideabi-gcc-nm
AR_FOR_TARGET=arm-linux-androideabi-gcc-ar
READELF_FOR_TARGET=arm-linux-androideabi-readelf
OBJDUMP_FOR_TARGET=arm-linux-androideabi-objdump
STRIP_FOR_TARGET=arm-linux-androideabi-strip

Command Line That Triggers Bug:
When remaking files.o
arm-linux-androideabi-g++  -I../../gcc-4.8/libcpp -I.
-I../../gcc-4.8/libcpp/../include -I../../gcc-4.8/libcpp/include  -g -O2 -W
-Wall -Wno-narrowing -Wwrite-strings -Wmissing-format-attribute -pedantic
-Wno-long-long  -fno-exceptions -fno-rtti -I../../gcc-4.8/libcpp -I.
-I../../gcc-4.8/libcpp/../include -I../../gcc-4.8/libcpp/include  -c -o files.o
-MT files.o -MMD -MP -MF .deps/files.Tpo ../../gcc-4.8/libcpp/files.c

Errors/Warning:
Live child 0x01d15db0 (files.o) PID 27949 
../../gcc-4.8/libcpp/files.c: In function 'bool read_file_guts(cpp_reader*,
_cpp_file*)':
../../gcc-4.8/libcpp/files.c:727:27: error: cannot convert 'long long int*' to
'off_t* {aka long int*}' for argument '7' to 'unsigned char*
_cpp_convert_input(cpp_reader*, const char*, unsigned char*, size_t, size_t,
const unsigned char**, off_t*)'
  &file->st.st_size); 

Additional Notes:
Very new to C, but with the above source, files.c, writing a cast to off_t as
so:
off_t *ot
off_t ot = (off_t) &file->st.st_size;

allows the build to continue but resulting cc1 binary throws a "Bad Address"
when run on host platform
off_t ot = (off_t) file->st.st_size;


[Bug preprocessor/58939] Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors

2013-11-03 Thread chaselton at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58939

--- Comment #1 from chaselton  ---
UPDATE: 
Thanks to Jonathan Wakely and Ian Taylor for providing the codefixes.
This bug is resolved by adding the following to files.c

in lines 715-726:
  if (regular && total != size && STAT_SIZE_RELIABLE (file->st))
cpp_error (pfile, CPP_DL_WARNING,
   "%s is shorter than expected", file->path);
++  off_t ot = file->st.st_size;
  file->buffer = _cpp_convert_input (pfile,
 CPP_OPTION (pfile, input_charset),
 buf, size + 16, total,
 &file->buffer_start,
++ &ot
 /*&file->st.st_size*/);
++  file->st.st_size = ot;
  file->buffer_valid = true;

NOTE:  The following also must be added to macro.c in order for libcpp to build
successfully

in lines 248-253:
if (st)
  {
++  time_t t = (time_t) st->st_mtime;
++  tb = localtime (&t);
  /* tb = localtime (&st->st_mtime); */
  }