Error Building Newlib for arm-none-eabi

R0b0t1 r030t1@gmail.com
Wed Feb 21 07:01:00 GMT 2018


On Tue, Feb 20, 2018 at 11:25 PM, Brian Inglis
<Brian.Inglis@systematicsw.ab.ca> wrote:
> On 2018-02-20 17:33, R0b0t1 wrote:
>> On Mon, Feb 19, 2018 at 10:44 PM, R0b0t1 <r030t1@gmail.com> wrote:
>>> On Mon, Feb 19, 2018 at 8:33 PM, R0b0t1 <r030t1@gmail.com> wrote:
>>>> I am trying to build for arm-none-eabi with GCC.
>>>>
>>>>     ../../source/${dname}/configure \
>>>>         --target=${TARGET} \
>>>>         --prefix=`realpath ../../${DIR_PREFIX}` \
>>>>         --disable-newlib-supplied-syscalls \
>>>>         --enable-newlib-reent-small \
>>>>         --disable-newlib-fvwrite-in-streamio \
>>>>         --disable-newlib-fseek-optimization \
>>>>         --disable-newlib-wide-orient \
>>>>         --disable-newlib-unbuf-stream-opt \
>>>>         --enable-newlib-global-atexit \
>>>>         --enable-newlib-retargetable-locking \
>>>>         --disable-nls
>>>>
>>>>     make -j"${NCPU}" -l"${NCPU}"
>>>>     make install
>>>>
>>>>
>>>> Gives:
>>>>
>>>> In file included from
>>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/ssp/stdio.h:34:0,
>>>>                  from
>>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800,
>>>>                  from
>>>> ../../../../../../source/newlib-3.0.0/newlib/libc/stdio/gets.c:62:
>>>> ../../../../../../source/newlib-3.0.0/newlib/libc/stdio/gets.c:96:1:
>>>> error: expected declaration specifiers or ‘...’ before
>>>> ‘__builtin_object_size’
>>>>  gets (char *buf)
>>>>  ^
>>>>
>>>> I attempted to search for the error, but did not get much of anywhere.
>>>> The GCC mailing list informed me that building all components
>>>> separately may not be the best idea, but I am looking to copy existing
>>>> build systems and to integrate the code into those build systems. In
>>>> which case separate component builds are more convenient, at least for
>>>> now.
>>>>
>>>
>>> Some testing with a default configuration, just setting --target,
>>> leads to more of the same:
>>>
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800:0,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/sprintf.c:572:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/sprintf.c:606:1:
>>> error: expected declaration specifiers or ‘...’ before numeric
>>> constant
>>>  sprintf (char *__restrict str,
>>>  ^
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/ssp/stdio.h:34:0,
>>>                  from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/sprintf.c:572:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/sprintf.c:606:1:
>>> error: expected declaration specifiers or ‘...’ before
>>> ‘__builtin_object_size’
>>>  sprintf (char *__restrict str,
>>>  ^
>>> make[8]: *** [Makefile:1222: lib_a-sprintf.o] Error 1
>>> make[8]: *** Waiting for unfinished jobs....
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/ssp/stdio.h:34:0,
>>>                  from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/gets.c:62:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/gets.c:96:1:
>>> error: expected declaration specifiers or ‘...’ before
>>> ‘__builtin_object_size’
>>>  gets (char *buf)
>>>  ^
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800:0,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/snprintf.c:22:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/snprintf.c:66:1:
>>> error: expected declaration specifiers or ‘...’ before numeric
>>> constant
>>>  snprintf (char *__restrict str,
>>>  ^
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/ssp/stdio.h:34:0,
>>>                  from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/snprintf.c:22:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/snprintf.c:66:1:
>>> error: expected declaration specifiers or ‘...’ before
>>> ‘__builtin_object_size’
>>>  snprintf (char *__restrict str,
>>>  ^
>>> make[8]: *** [Makefile:1096: lib_a-gets.o] Error 1
>>> make[8]: *** [Makefile:1216: lib_a-snprintf.o] Error 1
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800:0,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsprintf.c:25:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsprintf.c:34:1:
>>> error: expected declaration specifiers or ‘...’ before numeric
>>> constant
>>>  vsprintf (char *__restrict str,
>>>  ^
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/ssp/stdio.h:34:0,
>>>                  from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsprintf.c:25:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsprintf.c:34:1:
>>> error: expected declaration specifiers or ‘...’ before
>>> ‘__builtin_object_size’
>>>  vsprintf (char *__restrict str,
>>>  ^
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800:0,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsnprintf.c:25:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsnprintf.c:35:1:
>>> error: expected declaration specifiers or ‘...’ before numeric
>>> constant
>>>  vsnprintf (char *__restrict str,
>>>  ^
>>> In file included from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/ssp/stdio.h:34:0,
>>>                  from
>>> /home/R0b0t1/devel/toolgen/source/newlib-3.0.0/newlib/libc/include/stdio.h:800,
>>>                  from
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsnprintf.c:25:
>>> ../../../../../../../source/newlib-3.0.0/newlib/libc/stdio/vsnprintf.c:35:1:
>>> error: expected declaration specifiers or ‘...’ before
>>> ‘__builtin_object_size’
>>>  vsnprintf (char *__restrict str,
>>>  ^
>
>> I apologize for the updates, but I've just repeated that build with
>> different results. Only the error in gets.c is reported.
>>
>> ../../source/newlib-3.0.0/configure --target=arm-none-eabi
>> --host=x86_64-pc-linux-gnu --prefix=`realpath ../../prefix`
>> --docdir=`realpath ../../prefix/share/doc`
>>
>> I had a similar issue with GCC that was solved with the addition of a
>> configuration flag, but here I am at a loss.
>
> Autoconf 14.1 Specifying target triplets says:
>
> https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Specifying-Target-Triplets.html
>
> --target defaults to --host, --host defaults to --build, so you need to specify
> --build and --host, as --host specifies a cross build, so you probably need to
> use --build=x86_64-pc-linux-gnu --host=arm-none-eabi
>
> Autoconf 18.6.3 Hosts and Cross Compilation explains:
>
> https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Hosts-and-Cross_002dCompilation.html
>
> HTH
>
> --
> Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

Thanks, however:

$ ../../source/newlib-3.0.0/configure --build=x86_64-pc-linux-gnu
--host=arm-none-eabi --target=arm-none-eabi --prefix=`realpath
../../prefix` --docdir=`realpath ../../prefix/share/doc`
--disable-newlib-supplied-syscalls --enable-newlib-reent-small
--disable-newlib-fvwrite-in-streamio
--disable-newlib-fseek-optimization --disable-newlib-wide-orient
--disable-newlib-unbuf-stream-opt --enable-newlib-global-atexit
--enable-newlib-retargetable-locking --disable-nls
checking build system type... x86_64-pc-linux-gnu
checking host system type... arm-none-eabi
checking target system type... arm-none-eabi
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for arm-none-eabi-gcc... arm-none-eabi-gcc
checking for C compiler default output file name...
configure: error: in `/home/R0b0t1/devel/toolgen/build/newlib-3.0.0':
configure: error: C compiler cannot create executables
See `config.log' for more details.


>From a page affiliated with GCC (I think) I read the semantics of the flags as:
  * build - machine producing binaries for
  * host - which runs the compiler to produce binaries for
  * target.

So normally build == host ?= target, but sometimes build != host ==
target, for initial architecture bootstrapping.


The persistence of this problem leads me to think there is a bug in
the newlib autotools configuration, but sadly I do not have any idea
how to troubleshoot that, or why it leads to source errors. I'll hold
off from posting until I get more information. At least one person has
recommended cutting out gets entirely.

Thanks,
     R0b0t1



More information about the Newlib mailing list