[sr-dev] git:master: core: Added support for the clang compiler
Marius Zbihlei
marius.zbihlei at 1and1.ro
Fri Sep 14 14:02:14 CEST 2012
On 09/14/2012 01:55 PM, Marius Zbihlei wrote:
> On 09/14/2012 01:30 PM, Daniel-Constantin Mierla wrote:
>> Hello,
>>
>> nice, is everything compiling (at least the standard modules and most
>> commonly used)?
One last thing I've remembered. Because of include directory changes
related to gcc 4.x. now the asm/ headers (among others) are not by
default in the include path, with the except of native gcc. Actually to
fix this one needs to install the gcc-multilib package that allows this,
as /usr/include/asm is only provided by gcc-multilib in order to support
building binaries for an ABI other than the default (e.g., building with
gcc -m32 on amd64)
This should also affect on new system any non-gcc compiler as Intel C
Compiler. Nevertheless gcc-multilib is not a dependency on
build-essential or gcc....
Cheers,
Marius
> Hello,
>
> core, modules-all and some other modules we use seem to work fine. If
> there are problems on architectures (tested linux x86-64) there will be
> ways of fixing it. Tested (after another libkcore commit) with
> registrar, tm, sl, and others and K starts ok.
>
> The fist useful thing is to run the static analysis frontend of clang
>
> scan-build make cfg
> scan-build make
>
> Then run scan-view as outputed bye the previous command to view the
> defects.
>
> Haven't had time to test performance of the binary and compare it with
> the gcc build at same optimization level, but will give it a go in the
> future.
>
> Marius
>> Thanks,
>> Daniel
>>
>> On 9/14/12 12:23 PM, Marius Zbihlei wrote:
>>> Module: sip-router
>>> Branch: master
>>> Commit: 452c543de61d413351a5ac0816adc137d150824b
>>> URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=452c543de61d413351a5ac0816adc137d150824b
>>>
>>> Author: Marius Zbihlei <marius.zbihlei at 1and1.ro>
>>> Committer: Marius Zbihlei <marius.zbihlei at 1and1.ro>
>>> Date: Fri Sep 14 13:17:24 2012 +0300
>>>
>>> core: Added support for the clang compiler
>>>
>>> Support for clang, a C compiler from the LLVM suite has been added.
>>> Install clang and run 'make cfg CC=clang && make' for building. GCC Inline assembly is supported.
>>> TODO: clean warning caused by clang (-Wunused-variable, etc)
>>>
>>> ---
>>>
>>> Makefile.defs | 41 ++++++++++++++++++++++++++++++++++++++++-
>>> 1 files changed, 40 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/Makefile.defs b/Makefile.defs
>>> index b9718fd..9bf78b5 100644
>>> --- a/Makefile.defs
>>> +++ b/Makefile.defs
>>> @@ -321,6 +321,14 @@ ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
>>> MKDEP=$(CC) -MM
>>> endif
>>>
>>> +ifneq (, $(findstring clang, $(CC_LONGVER)))
>>> + #clang should be gcc compatible
>>> + CC_NAME=clang
>>> + CC_FULLVER:=$(shell echo "$(CC_LONGVER)" | head -n 1 | sed -e 's/.*version \([0-9]\.[0-9]\).*/\1/g' )
>>> + CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
>>> + CC_VER=$(CC) $(CC_FULLVER)
>>> + MKDEP=$(CC) -MM
>>> +endif
>>>
>>> ifeq (,$(CC_NAME))
>>> #not found
>>> @@ -866,7 +874,7 @@ ifeq ($(mode), release)
>>> #if i386
>>> ifeq ($(ARCH), i386)
>>> # if gcc
>>> -ifeq ($(CC_NAME), gcc)
>>> +ifeq ($(CC_NAME), gcc)
>>> C_DEFS+=-DCC_GCC_LIKE_ASM
>>> #common stuff
>>> CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE)
>>> @@ -923,6 +931,15 @@ endif # CC_SHORTVER, 4.x
>>> endif # CC_SHORTVER, 4.5+ or 4.2+
>>>
>>> else # CC_NAME, gcc
>>> +ifeq ($(CC_NAME), clang)
>>> +$(call set_if_empty,CPU,athlon64)
>>> + C_DEFS+=-DCC_GCC_LIKE_ASM
>>> + CFLAGS+=-m32
>>> + \
>>> + \
>>> + -mtune=$(CPU)
>>> + LDFLAGS+=-m32
>>> +else # CC_NAME, clang
>>> ifeq ($(CC_NAME), icc)
>>> C_DEFS+=-DCC_GCC_LIKE_ASM
>>> CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
>>> @@ -935,6 +952,7 @@ else
>>> #other compilers
>>> $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
>>> endif #CC_NAME, icc
>>> +endif #CC_NAME, clang
>>> endif #CC_NAME, gcc
>>> endif #ARCH, i386
>>>
>>> @@ -1009,6 +1027,13 @@ endif # CC_SHORTVER, 4.2+
>>> endif # CC_SHORTVER, 4.5+
>>>
>>> else # CC_NAME, gcc
>>> +ifeq ($(CC_NAME), clang)
>>> +$(call set_if_empty,CPU,opteron)
>>> + C_DEFS+=-DCC_GCC_LIKE_ASM
>>> + CFLAGS+=-m64 \
>>> +
>>> + LDFLAGS+=-m64
>>> +else # CC_NAME, clang
>>> ifeq ($(CC_NAME), icc)
>>> C_DEFS+=-DCC_GCC_LIKE_ASM
>>> CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
>>> @@ -1021,6 +1046,7 @@ else
>>> #other compilers
>>> $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
>>> endif #CC_NAME, icc
>>> +endif #CC_NAME, clang
>>> endif #CC_NAME, gcc
>>> endif #ARCH, x86_64
>>>
>>> @@ -1597,6 +1623,14 @@ endif
>>> # the executable file, because it's always loaded at a fixed address
>>> # -andrei
>>>
>>> +ifeq ($(CC_NAME), clang)
>>> + LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
>>> + MOD_LDFLAGS:=-shared $(LDFLAGS)
>>> + LIB_LDFLAGS:=-shared $(LDFLAGS)
>>> + LIB_SONAME=-Wl,-soname,
>>> + LD_RPATH=-Wl,-rpath,
>>> +endif
>>> +
>>> LDFLAGS+= $(LD_EXTRA_OPTS)
>>> MOD_LDFLAGS+= $(LD_EXTRA_OPTS)
>>> LIB_LDFLAGS+= $(LD_EXTRA_OPTS)
>>> @@ -1674,6 +1708,11 @@ ifeq ($(CC_NAME), suncc)
>>> MOD_CFLAGS=-xcode=pic32 $(CFLAGS)
>>> LIB_CFLAGS=-xcode=pic32 $(CFLAGS)
>>> endif
>>> +ifeq ($(CC_NAME), clang)
>>> +MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
>>> +LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
>>> +endif
>>> +
>>> UTILS_CFLAGS=$(CFLAGS)
>>> # LDFLAGS uses for compiling the utils
>>> UTILS_LDFLAGS=$(LDFLAGS)
>>>
>>>
>>> _______________________________________________
>>> sr-dev mailing list
>>> sr-dev at lists.sip-router.org
>>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>
--
Zbihlei Marius
Head of
Linux Development Services Romania
1&1 Internet Development srl Tel KA: 754-9152
Str Mircea Eliade 18 Tel RO: +40-31-223-9152
Sect 1, Bucuresti mailto: marius.zbihlei at 1and1.ro
71295, Romania
More information about the sr-dev
mailing list