From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66691 invoked by alias); 11 Nov 2015 23:16:43 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 66672 invoked by uid 89); 11 Nov 2015 23:16:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_20,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: 17.mo7.mail-out.ovh.net Received: from 17.mo7.mail-out.ovh.net (HELO 17.mo7.mail-out.ovh.net) (188.165.35.227) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 11 Nov 2015 23:16:40 +0000 Received: from mail388.ha.ovh.net (gw6.ovh.net [213.251.189.206]) by mo7.mail-out.ovh.net (Postfix) with ESMTP id 9D710FF865F for ; Thu, 12 Nov 2015 00:16:35 +0100 (CET) Received: from RCM-86.6.27.10 (localhost [127.0.0.1]) by mail388.ha.ovh.net (Postfix) with ESMTPA id 3E7AF320089; Thu, 12 Nov 2015 00:16:34 +0100 (CET) Received: from cpc21-cmbg14-2-0-cust265.5-4.cable.virginm.net ([86.6.27.10]) by ssl0.ovh.net with HTTP (HTTP/1.1 POST); Thu, 12 Nov 2015 00:16:34 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 12 Nov 2015 04:11:00 -0000 From: Olivier MARTIN To: newlib@sourceware.org Cc: olivier@labapart.com Subject: Building newlib for Cortex-M with LLVM Message-ID: <8473a04381ff7d35caa7ea1e8eb08772@labapart.com> X-Sender: olivier@labapart.com User-Agent: Roundcube Webmail/1.1.3 X-Webmail-UserID: olivier@labapart.com X-Ovh-Tracer-Id: 14723111608746012247 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrfeekhedrgeekucetufdoteggodftvfcurfhrohhfihhlvgemucfqggfjnecuuegrihhlohhuthemuceftddtnecu X-SW-Source: 2015/txt/msg00789.txt.bz2 Hello all, recently I found a warning generated by Clang while building my project that is based on Newlib (see https://sourceware.org/ml/newlib/2015/msg00714.html). I was curious... and I was wondering whether I could build newlib with Clang. The answer is probably the one you were expected, no! I am not really familiar with newlib build configuration, I went for the basic steps I found on the Internet: mkdir build-newlib-llvm cd build-newlib-llvm export AS_FOR_TARGET=/home/olivier/Toolchains/gcc-arm-none-eabi-4_9-2014q4/bin/arm-none-eabi-as export CC_FOR_TARGET=/usr/bin/clang-3.6 export CFLAGS_FOR_TARGET="-target arm-none-eabi" export PATH=/home/olivier/Toolchains/gcc-arm-none-eabi-4_9-2014q4/bin:$PATH ../configure --target=arm-none-eabi --prefix=/home/olivier/Toolchains/gcc-arm-none-eabi-4_9-2014q4 --disable-newlib-supplied-syscalls --with-cpu=armv7m --with-mode=thumb --enable-interwork make all There are two issues I manage to isolate. * The first one can be solved. The space in the call of CONCAT2(a, b) by CONCAT() is propagated into the subsequent calls. It means when the strings 'a' and 'b' are concatenated, the space is inserted between both strings - which is not the expected behaviour. The fix would be: --- a/newlib/libc/machine/arm/setjmp.S +++ b/newlib/libc/machine/arm/setjmp.S @@ -3,7 +3,7 @@ Nick Clifton, Cygnus Solutions, 13 June 1997. */ /* ANSI concatenation macros. */ -#define CONCAT(a, b) CONCAT2(a, b) +#define CONCAT(a, b) CONCAT2(a,b) * The second issue is what I believe to be a Clang issue. Clang does not support when macros are defined into inline assembly and used later on. Assembly macros are quite used in the ARM string functions (eg: 'RETURN', 'optpld' macros). I raised a Clang bug for this one: https://llvm.org/bugs/show_bug.cgi?id=25495 I had other issues but they might come from the fact I have not correctly configured newlib for Cortex-M... For instance, the following errors: - libgloss/arm/linux-crt0.c:34:2: error: non-ASM statement in naked function is not supported register int *sp asm("sp"); - libgloss/libnosys/chown.c :1:8: error: unsupported directive '.stabs' .stabs "_chown is not implemented and will always fail",30,0,0,0 - '.syntax divided' is not supported - it is used in newlib/libc/machine/arm/*.S Note: I cannot see the armv7m/thumb/interwork flags to be propagated into the build commands. Any feedback or comment on my investigation are welcome. I am quite happy to try few things. Thanks, --- Olivier MARTIN http://labapart.com - Lab A Part