2013年6月25日火曜日

SystemC-AMS 1.0 with clang

On some system, linking with libsystemc-ams.a compiled with clang may cause multiple definitions. In that case, systemc-ams must be compiled with
-fgnu89-inline option.
 

Howto

 tar zxvf systemcams-1.0.tar.gz 

 cd systemcams-1.0
 ./configure --with-systemc=/your/systemc/path
 make CC="clang -fgnu89-inline"
 make install

configure script ignores environmental variable CFLAGS, so -fgnu89-inline option must be specified during make.

Background

Clang assumes .c file as a C99 source code. Some C program assumes its language is C89 with gnu extension (aka gnu89).
gnu89 and C99 have several differences. The biggest one is a function with 'extern inline'.
In gnu89, functions with 'extern inline' are not necessarily compiled to normal non-inlined function.
In C99, such functions must be also compiled to a normal non-inlined function.
Source code which is expected to be compiled with gnu89 may cause link error of multiple definitions for this case.
If you use inline function in C, use 'static inline'. Its meaning is same for both C99 and gnu89.

0 件のコメント:

コメントを投稿