Wednesday, May 10, 2017

Error compiling SystemC-2.2 with GCC 4.9

GCC now requires some headers to be explicitly defined (whereas in the past they were implicitly included when some functions were used). When trying to compile SystemC-2.2.0 with GCC 4.9 (or latter) the following error is raised:

g++ -I. -I. -I. -I../../../src  -fpermissive  -Wall -DSC_USE_PTHREADS -DSC_INCLUDE_FX -O3 -c -o sc_utils_ids.o `test -f 'sc_utils_ids.cpp' || echo './'`sc_utils_ids.cpp
sc_utils_ids.cpp: In function ‘int sc_core::initialize()’:
sc_utils_ids.cpp:109:36: error: ‘getenv’ is not a member of ‘std’
     const char* deprecation_warn = std::getenv("SC_DEPRECATION_WARNINGS");


This can be solved removing the std:: before getenv, and adding the #include <stdlib.h> header.

In addition to this, #include <string.h> must be also included, otherwise the following error is raised:

sc_utils_ids.cpp: In function ‘int sc_core::initialize()’:
sc_utils_ids.cpp:110:69: error: ‘strcmp’ was not declared in this scope
     if ( (deprecation_warn!=0) && !strcmp(deprecation_warn,"DISABLE") )

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.

Wednesday, December 21, 2016

GEM5 for SPARC error: "Can't find file 'reset_new.bin' on path."

If you have tried emulating a full disk image for SPARC using GEM5 you may have found the following error:
 IOError: Can't find file 'reset_new.bin' on path.
If you have already followed the instructions to get additional files in the GEM5 site, you already have added the OpenSPARC 1.5 architecture files to the M5 path. Currently the direct link to the files is here.

Once you decompressed the files in OpenSPARCT1_Arch.1.5/S10image/ to your M5 path (by default /dist/m5/system/binaries/) you may still get the same error when trying to run the simulation. This is solved by renaming the following files:

mv /dist/m5/system/binaries/reset.bin /dist/m5/system/binaries/reset_new.bin
mv /dist/m5/system/binaries/q.bin /dist/m5/system/binaries/q_new.bin
mv /dist/m5/system/binaries/openboot.bin /dist/m5/system/binaries/openboot_new.bin
Hope this solves your issues.

Sunday, December 15, 2013

Tumblr's X-tumblr-puppies header

Recently Tumblr has implemented a new form security mechanism consisting in a key that is requested from http://www.tumblr.com/svc/secure_form_key.

This secure_form_key application is requested via an empty POST request and the server will reply with a 404 error if an unexpected request is detected (unidentified user, POST parameters, etc).

This form will reply with an empty document and a response header called X-tumblr-secure-form-key, which holds the key value required for X-tumblr-puppies, a header that needs to be passed to the http://www.tumblr.com/svc/post/update application, the one in charge of posting.

The value returned in X-tumblr-secure-form-key is binary, and must be precessed before being able to use it as a key. This regular expression should do it, as it only uses numbers, letters and the exclamation mark and pipe simbols: [^a-zA-Z0-9\|\!].

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.