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.

2013年6月12日水曜日

SystemC-2.3 with Clang

Clang is a compiler which features fast compile, friendly error messages and high-compatibility with the latest C++ standard.
SystemC-2.2 can not be compiled with clang due to syntax violation of SystemC library.
Such violations are fixed in SystemC-2.3 but not perfect.
Clang emits warnings with -Wall and -Wextra option.
It is important to set the warning level higher to keep code clean.
If warnings are emitted at the library, warnings of user code may be concealed by them.
This is why libraries must be warning-free.

I wrote small patch to suppress such warnings.
https://github.com/yTakatsukasa/misc/tree/master/systemc-2.3_clang

Apply systemc-2.3_clang.patch before configure., then build it as usual.
 
  1. tar zxvf systemc-2.3.0.tgz
  2. patch -p0 < systemc-2.3_clang.patch
  3. cd systemc-2.3.0
  4. env CC=clang CXX=clang++ CPP="clang -E" ./configure
  5. make
  6. make install

2013年6月10日月曜日

JCPU shows pretty good performance

I changed the name or QCPU (in previous post) to JCPU, because noun QCPU is already used in a FA industry. 'J' derives from JIT (Just In Time compilation).
Only limited instructions are implemented, but now it can execute simple program.
I tested with a bubble sort with printf and get the result of more than 100 million instructions / sec without any optimization techniques.
Exceptions, MMU and supervisor mode is still unimplemented. These feature will decrease the performance. I hope I can cancel these negative effect with optimization.

(2013/06/12 update)
very primitive version can be seen at https://github.com/yTakatsukasa/JCPU

2013年6月3日月曜日

Started a new project : QCPU

I started a new project QCPU, which is a fast processor model using LLVM.
There are several related projects like QEMU, libcpu, and ArchC.
QEMU is mature project and supporting many architectures.
So I had been struggling for 2-3 weeks to cut out the processor model from QEMU., but QEMU is written in C and uses a lot of C macro tricks, so many files that are not necessary for processor models. Finally I gave up to cut out from QEMU. But the project name QCPU still derives from QEMU even though no source code of QEMU is used any more.

libcpu uses LLVM, but it does not looks to be actively developed.

ArchC is ongoing ambitions project. But it does not look focusing a performance.

So I started by myself.

I want to achieve the following points in QCPU.
  • Performance
  • Clean C++ code, no static/global object
  • Multi-instance friendly

According to the result of LLVM-QEMU of GSoC2007, it will be very difficult to get the similar performance as QEMU, but it's OK because this is just a hobby.

Currently only several instructions of openrisc is implemented.
  • Implement all instruction of OpenRISC
  • Support more archtectures (arm, mips, ppc, xtensa)
  • Implement MMU emulation framework
  • GDB stub
  • Performance optimization

I hope I can make the initial version in public in this month. The license will be GPL.