Showing posts with label gcc. Show all posts
Showing posts with label gcc. Show all posts

Wednesday, May 10, 2017

Compiling SystemC-2.2.0 with newer versions of GCC

When trying to make SystemC-2.2 with newer (post 4.7?) versions of GCC, the process fails with the following error:

In file included from ../../../src/sysc/datatypes/bit/sc_bv_base.h:47:0,
                 from ../../../src/sysc/datatypes/bit/sc_lv_base.h:50,
                 from sc_signal.cpp:95:
../../../src/sysc/datatypes/bit/sc_bit_proxies.h:698:16: error: reference ‘m_obj’ cannot be declared ‘mutable’ [-fpermissive]
     mutable X& m_obj;
                ^
../../../src/sysc/datatypes/bit/sc_bit_proxies.h:1175:18: error: reference ‘m_left’ cannot be declared ‘mutable’ [-fpermissive]
     mutable X&   m_left;
                  ^
../../../src/sysc/datatypes/bit/sc_bit_proxies.h:1176:18: error: reference ‘m_right’ cannot be declared ‘mutable’ [-fpermissive]
     mutable Y&   m_right;
                  ^
../../../src/sysc/datatypes/bit/sc_bit_proxies.h:1178:18: error: reference ‘m_refs’ cannot be declared ‘mutable’ [-fpermissive]
     mutable int& m_refs;

The error is caused by the increasingly strict parser in GCC; syntax that used to be OK is now failing to compile.

To fix the issue simply set the EXTRA_CXXFLAGS environment variable to -fpermissive, then configure again with ./configure, then recompile with make.

Tuesday, August 2, 2011

except.c: undefined reference to `libc_name_p'

When cross-compiling GCC 4.5.1 I got this error. Seems to be caused by not having gperf installed:

gperf -o -C -E -k '1-6,$' -j1 -D -N 'libc_name_p' -L ANSI-C \
../../gcc-4.5.1/gcc/cp/cfns.gperf > ../../gcc-4.5.1/gcc/cp/cfns.h
/bin/sh: gperf: command not found
make[1]: *** [../../gcc-4.5.1/gcc/cp/cfns.h] Error 127

Further attempts to compile will find an empty gcc-4.5.1/gcc/cp/cfns.h file and the undefined reference error will be thrown:

cp/except.o: In function `nothrow_libfn_p':
../../gcc-4.5.1/gcc/cp/except.c:***: undefined reference to `libc_name_p'
collect2: ld returned 1 exit status

Solution:
  1. Remove gcc/cp/cfns.h
  2. Install gperf
  3. Run make again to correctly generate the cfns.h file.