This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [AArch64] nosys.specs and printf
Well at least _write is here:
af@af-ubuntu16-vm:~/aarc64-none-elf/bin$ ./aarch64-none-elf-gcc
--specs=nosys.specs test.c
af@af-ubuntu16-vm:~/aarc64-none-elf/bin$ ./aarch64-none-elf-objdump
-dS a.out | grep -A15 \(_write,
_DEFUN (_write, (file, ptr, len),
int file _AND
char *ptr _AND
int len)
{
errno = ENOSYS;
407acc: d0000080 adrp x0, 419000 <object.5047+0x18>
407ad0: 52800b01 mov w1, #0x58 // #88
407ad4: b9006801 str w1, [x0, #104]
return -1;
}
407ad8: 12800000 mov w0, #0xffffffff // #-1
407adc: d65f03c0 ret
0000000000407ae0 <_exit>:
#include <_syslist.h>
And it is worked before (when warning been appeared on link stage) -
main called for printf() and of course nothing were printed out. But
further execution didn't fails.
On Wed, Sep 20, 2017 at 4:40 PM, Tamar Christina
<Tamar.Christina@arm.com> wrote:
> Hi Alex,
>
> I don't believe we want to suppress the warnings, the fact that arm currently does seems
> to me to be a bug rather than a feature. The warnings are there to tell you your application
> will not work if you call any of those functions.
>
> Did you try running the example you're compiling? I'd be surprised if it worked.
>
> Regards,
> Tamar
> ________________________________________
> From: Alexander Fedotov <alfedotov@gmail.com>
> Sent: Wednesday, September 20, 2017 2:19 PM
> To: Tamar Christina
> Cc: newlib@sourceware.org; nd
> Subject: Re: [AArch64] nosys.specs and printf
>
> Hi Tamar
>
> I've managed to suppress this message for nosys and it looks beter to
> me. How do you think about upstream this ?
>
> diff -ruN newlib-2.5.0/libgloss/libnosys/configure.in
> newlib-2.5.0/libgloss/libnosys/configure.in
> --- newlib-2.5.0/libgloss/libnosys/configure.in 2016-12-23
> 05:33:54.000000000 +0300
> +++ newlib-2.5.0/libgloss/libnosys/configure.in 2017-09-20
> 16:15:31.346520052 +0300
> @@ -43,6 +43,8 @@
> ;;
> a29k-amd-udi)
> ;;
> + aarch64*-*-*)
> + ;;
> arc-*-*)
> ;;
> arm*-*-*)
> @@ -88,6 +90,9 @@
>
> dnl Make sure we know if elf format used
> case "${target}" in
> + aarch64*-*-*)
> + #suppress "warning: _close etc is not implemented and will always fail"
> + ;;
> *-*-elf)
> AC_DEFINE(HAVE_ELF)
>
> Alex
>
> On Wed, Sep 20, 2017 at 10:31 AM, Alexander Fedotov <alfedotov@gmail.com> wrote:
>> So can we have approach in aarch64 the same ARM already has? To
>> simplify further support.
>> I know that aarch64 is more preferable with Linux to use. But some
>> customers want to have baremetal with newlib like for ARM.
>>
>> Alex
>>
>> On Tue, Sep 19, 2017 at 5:43 PM, Tamar Christina
>> <Tamar.Christina@arm.com> wrote:
>>> Hi Alex,
>>>
>>> It's not that ARM is working, in the sense it does anything useful,
>>>
>>> It's just that the warnings don't seem to be emitted because the conftests in libgloss/libnosys/configure.in are too simplistic,
>>> for instance it tests for elf platforms by seeing if the target triple ends with "-elf".
>>>
>>> However, just like aarch64, using nosys gives you stubs and not actual code.
>>>
>>> /d/t/g/s/gcc (master ↩☡=) ../../build-arm-none-eabi/install/bin/arm-none-eabi-gcc test.c --specs=nosys.specs
>>> /d/t/g/s/gcc (master ↩☡=) ../../build-arm-none-eabi/install/bin/arm-none-eabi-objdump -d a.out
>>>
>>> ...
>>> 0000b0b4 <_lseek>:
>>> b0b4: e3a02058 mov r2, #88 ; 0x58
>>> b0b8: e59f3008 ldr r3, [pc, #8] ; b0c8 <_lseek+0x14>
>>> b0bc: e3e00000 mvn r0, #0
>>> b0c0: e5832000 str r2, [r3]
>>> b0c4: e12fff1e bx lr
>>> b0c8: 0001b9fc .word 0x0001b9fc
>>>
>>> 0000b0cc <_read>:
>>> b0cc: e3a02058 mov r2, #88 ; 0x58
>>> b0d0: e59f3008 ldr r3, [pc, #8] ; b0e0 <_read+0x14>
>>> b0d4: e3e00000 mvn r0, #0
>>> b0d8: e5832000 str r2, [r3]
>>> b0dc: e12fff1e bx lr
>>> b0e0: 0001b9fc .word 0x0001b9fc
>>> ...
>>>
>>> They all just return -1 and set ERRNO just as expected. https://github.com/eblot/newlib/blob/master/libgloss/libnosys/read.c
>>>
>>> So Aarch64 is actually working as intended, it's ARM that's missing the warnings. And yeah, in order to suppress the warnings
>>> you need to provide an alternate implementation.
>>>
>>> Tamar.
>>> ________________________________________
>>> From: Alexander Fedotov <alfedotov@gmail.com>
>>> Sent: Tuesday, September 19, 2017 2:15 PM
>>> To: Tamar Christina
>>> Subject: Re: [AArch64] nosys.specs and printf
>>>
>>> Hello Tamar
>>>
>>> Well that's sounds to me like newlib completely useless for aarch64 in
>>> current state.
>>> So if I want to use nosys in my way I need to implement empty stubs to
>>> suppress these warnings ? Right ?
>>>
>>> How nosys ARM port is working in such case ?
>>>
>>> BR,
>>> Alex
>>>
>>>
>>> On Tue, Sep 19, 2017 at 2:08 PM, Tamar Christina
>>> <Tamar.Christina@arm.com> wrote:
>>>> Hi Alexander,
>>>>
>>>> I believe your changes to libnosys are correct. We don't actually support nosys on AArch64, enough stuff has been committed for particular use cases but that's about it.
>>>>
>>>> The warnings you get with your libnosys changes are correct in that libnosys doesn't provide any IO functionality, so you don't have open, close, read and write. Which means your printf example won't work and it's just warning you ahead of time.
>>>>
>>>> Kind regards,
>>>> Tamar
>>>> ________________________________________
>>>> From: newlib-owner@sourceware.org <newlib-owner@sourceware.org> on behalf of Alexander Fedotov <alfedotov@gmail.com>
>>>> Sent: Friday, September 15, 2017 11:43:23 AM
>>>> To: newlib@sourceware.org
>>>> Subject: [AArch64] nosys.specs and printf
>>>>
>>>> Hello all
>>>>
>>>> I'm trying to compile following simple program for aarch64 with nosys specs
>>>>
>>>> #include <stdio.h>
>>>> int main(void) {
>>>> printf("hello");
>>>> return 0;
>>>> }
>>>>
>>>> But I've got:
>>>> d:\gcc-6.3-arm64-eabi\bin>aarch64-none-elf-gcc --specs=nosys.specs test.c
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-sbrkr.o):
>>>> In function `_sbrk_r':
>>>> sbrkr.c:(.text._sbrk_r+0x1c): undefined reference to `_sbrk'
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-writer.o):
>>>> In function `_write_r':
>>>> writer.c:(.text._write_r+0x24): undefined reference to `_write'
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-closer.o):
>>>> In function `_close_r':
>>>> closer.c:(.text._close_r+0x1c): undefined reference to `_close'
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-fstatr.o):
>>>> In function `_fstat_r':
>>>> fstatr.c:(.text._fstat_r+0x20): undefined reference to `_fstat'
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-isattyr.o):
>>>> In function `_isatty_r':
>>>> isattyr.c:(.text._isatty_r+0x1c): undefined reference to `_isatty'
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-lseekr.o):
>>>> In function `_lseek_r':
>>>> lseekr.c:(.text._lseek_r+0x24): undefined reference to `_lseek'
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-readr.o):
>>>> In function `_read_r':
>>>> readr.c:(.text._read_r+0x24): undefined reference to `_read'
>>>> collect2.exe: error: ld returned 1 exit status
>>>>
>>>> d:\gcc-6.3-arm64-eabi\bin>aarch64-none-elf-gcc --specs=rdimon.specs test.c
>>>>
>>>> d:\gcc-6.3-arm64-eabi\bin>
>>>>
>>>>
>>>> I tried to reconfigure libnosys in the same way as ARM port:
>>>>
>>>> diff -ruN newlib-2.5.0/libgloss/libnosys/configure
>>>> newlib-2.5.0/libgloss/libnosys/configure
>>>> --- newlib-2.5.0/libgloss/libnosys/configure 2016-12-23
>>>> 05:33:54.000000000 +0300
>>>> +++ newlib-2.5.0/libgloss/libnosys/configure 2017-09-15
>>>> 13:14:56.412457618 +0300
>>>> @@ -2009,6 +2009,8 @@
>>>> ;;
>>>> a29k-amd-udi)
>>>> ;;
>>>> + aarch64*-*-*)
>>>> + ;;
>>>> arc-*-*)
>>>> ;;
>>>> arm*-*-*)
>>>> diff -ruN newlib-2.5.0/libgloss/libnosys/configure.in
>>>> newlib-2.5.0/libgloss/libnosys/configure.in
>>>> --- newlib-2.5.0/libgloss/libnosys/configure.in 2016-12-23
>>>> 05:33:54.000000000 +0300
>>>> +++ newlib-2.5.0/libgloss/libnosys/configure.in 2017-09-14
>>>> 18:32:27.330466884 +0300
>>>> @@ -43,6 +43,8 @@
>>>> ;;
>>>> a29k-amd-udi)
>>>> ;;
>>>> + aarch64*-*-*)
>>>> + ;;
>>>> arc-*-*)
>>>> ;;
>>>> arm*-*-*)
>>>>
>>>> It now compiles so I get final elf, but with warnings:
>>>> d:\gcc-6.3-arm64-eabi\bin>aarch64-none-elf-gcc --specs=nosys.specs test.c
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-closer.o):
>>>> In function `_close_r':
>>>> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/closer.c:53:
>>>> warning: _close is not impl
>>>> emented and will always fail
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-fstatr.o):
>>>> In function `_fstat_r':
>>>> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/fstatr.c:62:
>>>> warning: _fstat is not impl
>>>> emented and will always fail
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-isattyr.o):
>>>> In function `_isatty_r':
>>>> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/isattyr.c:58:
>>>> warning: _isatty is not im
>>>> plemented and will always fail
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-lseekr.o):
>>>> In function `_lseek_r':
>>>> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/lseekr.c:58:
>>>> warning: _lseek is not impl
>>>> emented and will always fail
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-readr.o):
>>>> In function `_read_r':
>>>> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/readr.c:58:
>>>> warning: _read is not implem
>>>> ented and will always fail
>>>> d:/gcc-6.3-arm64-eabi/bin/../lib/gcc/aarch64-none-elf/6.3.1/../../../../aarch64-none-elf/lib\libc.a(lib_a-writer.o):
>>>> In function `_write_r':
>>>> /home/af/GIT/BG/build_gnu/opt/freescale/Earmv8/obj_newlib/aarch64-none-elf/newlib/libc/reent/../../../../../src_newlib/newlib/libc/reent/writer.c:58:
>>>> warning: _write is not impl
>>>> emented and will always fail
>>>>
>>>>
>>>> Hi do I correctly to configure AArch64 nosys ?
>>>
>>>
>>>
>>> --
>>> Best regards,
>>> AF
>>
>>
>>
>> --
>> Best regards,
>> AF
>
>
>
> --
> Best regards,
> AF
--
Best regards,
AF