Problems with Newlib built with Clang for Cortex-M

Jangseop Shin <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CAGeQp6AvA6xp4avb8S1pPAazBfcwc0iFGk=gzMCP_ye4E4HCCw@mail.gmail.com>
Hello, I'm doing a project using RIOT-OS on Cortex-M.
I would like to instrument the code that are linked into the final binary
using LLVM. Since RIOT-OS uses newlib, I tried to compile newlib using
Clang.

I used the GNU ARM Embedded Toolchain (gcc-arm-none-eabi-7-2018-q2-update)
with 20180831 snapshot of newlib, clang-7.0.0, and RIOT-OS 2018.10 branch.

First there were a few compile errors.
(libgloss/arm/linux-syscalls0.S - GLOBAL => global  on line 105
liggloss/libnosys/warning.h -  define stub_warning as null
newlib/libc/machine/arm/strlen-thumb2-Os.S) - ldrb.w => ldrb (line 48)

(The fact that these are all quite old files gives me a feeling that newlib
is not really serious about supporting Clang??)

After I fixed the errors I could get the library file.
But when I tried to run the application on Cortex-M3 (Arduino-due board),
some of the app crash or produce incorrect results.
One of the bug I suspect is with newlib/libc/stdlib/dtoa.c  file, since it
makes my system halt when I try to print floating point number.
(I looked up the internet and added -fno-strict-aliasing flag to cflags
with no luck.)
When I replaced that specific object file in the libc library with the
gcc-compiled one, the app does not crash. (However, it still produces
incorrect results)
Replacing libm with the gcc-compiled version corrected the results to some
extent, but the floating point numbers are randomly printed with wrong sign.

I would very much appreciate any help on this issue.

Regards,
Jangseop
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.