public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/58939] New: Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors
@ 2013-10-31 12:51 chaselton at gmail dot com
  2013-11-02 22:28 ` [Bug preprocessor/58939] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: chaselton at gmail dot com @ 2013-10-31 12:51 UTC (permalink / raw)
  To: gcc-bugs

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;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug preprocessor/58939] Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors
  2013-10-31 12:51 [Bug preprocessor/58939] New: Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors chaselton at gmail dot com
@ 2013-11-02 22:28 ` redi at gcc dot gnu.org
  2013-11-03 17:27 ` chaselton at gmail dot com
  2021-09-02  2:37 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2013-11-02 22:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58939

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|blocker                     |normal


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug preprocessor/58939] Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors
  2013-10-31 12:51 [Bug preprocessor/58939] New: Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors chaselton at gmail dot com
  2013-11-02 22:28 ` [Bug preprocessor/58939] " redi at gcc dot gnu.org
@ 2013-11-03 17:27 ` chaselton at gmail dot com
  2021-09-02  2:37 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: chaselton at gmail dot com @ 2013-11-03 17:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58939

--- Comment #1 from chaselton <chaselton at gmail dot com> ---
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); */
          }


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug preprocessor/58939] Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors
  2013-10-31 12:51 [Bug preprocessor/58939] New: Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors chaselton at gmail dot com
  2013-11-02 22:28 ` [Bug preprocessor/58939] " redi at gcc dot gnu.org
  2013-11-03 17:27 ` chaselton at gmail dot com
@ 2021-09-02  2:37 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-02  2:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58939

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Interesting POSIX requires st_size to be off_t.  I see it is long long on some
platforms of bionic.

https://android.googlesource.com/platform/bionic/+/refs/heads/master/libc/include/sys/stat.h

I don't know if there is a way to support this correctly.
because using off_t will cause a truncatation.

Likewise for st_mtime too.

I don't know the right away to fix this without major changes to the sources.

So the question becomes do we want to support non-POSIX targets for these
structs here?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-09-02  2:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-31 12:51 [Bug preprocessor/58939] New: Cannot Cross-Build Android Native GCC 4.8 libcpp build conversion errors chaselton at gmail dot com
2013-11-02 22:28 ` [Bug preprocessor/58939] " redi at gcc dot gnu.org
2013-11-03 17:27 ` chaselton at gmail dot com
2021-09-02  2:37 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).