PTLSIM Setup On OpenSuse With G++4.1

Lately , i have found my self using ptlsim.

Obviously , the first step to use ptlsim is to install it. Here , i will tell you how to install ptlsim on opensuse with g++4.1and some troubleshooting about the installation and later phases of the usage. I will also keep this document up to date as much as possible.

Installation Steps:

1) Go to, download the latest package, what i have downloaded was ptlsim-20090314-r229.

2) After that extract this package.

3) Open a console and change your directory to this ptlsim directory.

4) In the ptlsim directory, open Makefile and edit the line:

– CC = g++-4.3  change this line to CC = g++-4.1

5) then turn back to konsole, and type make

6) you may have several errors like

stubs-32.h not found


– Download and install glibc , // zypper install glibc

7) if this error has occured , type “make clean” and when cleaning process is finished , type “make ” again.

8) possibly the ptlsim will be successfully compiled and ready use.

Trouble Shooting:

In the working phase, you may get an error like this:

-/sysdeps/x86_64/cacheinfo.c:197: handle_intel: Assertion `maxidx >= 2′ failed.


This is an assertion from glibc running on an Intel CPU. It assumes that the cpuid instruction has minimum level of support, but ptlsim doesn’t provide it.You can either remove the assertion from glibc, or more easily, hack the cpuid instruction in ptlsim such that it claims it has a higher level of support than it provides.

– This can be done by editing the  ptlsim/decode-complex.cpp file

– Search for the  void assist_cpuid(Context& ctx) function

– and edit the case:

   case 0: {
     // Max avail function spec and vendor ID:
    const W32* vendor = (const W32*)&cpuid_vendor;
    // rax = 1; // only one extended function  // Comment this

    // add this
    rax = 2; // only one extended function (but fake more otherwise glibc
             // fails an assertion)
     rbx = vendor[0];
     rdx = vendor[1];
     rcx = vendor[2];

– Finally recompile and use ptlsim. That’s all folks.


4 Responses to “PTLSIM Setup On OpenSuse With G++4.1”

  1. Barry Rountree Says:

    Thanks for that. I don’t know how much effort you had to put into finding the problem, but it was effort that I didn’t have to duplicate, and I appreciate that.

  2. veb61 Says:

    anytime, it is quite nice for me to hear from you and thinking that my writing s are actually helping someone out there.

  3. Shivani Says:

    Thanks a lot for posting this information. You have saved me hours and I really appreciate your help.

  4. Anon Says:

    PTLsim is picky about which toolchain it is built with. For PTLsim stable (2009-03-14 svn rev 229) I have found that I need:
    glibc 2.9
    gcc 4.2.x

    otherwise I would see errors like
    /usr/include/stdlib.h:281: undefined reference to `strtod’

    (failing to use the correct version of glibc results in errors like:
    klibc.cpp: In function ‘char* strchr(const char*, int)’:
    klibc.cpp:842: error: new declaration ‘char* strchr(const char*, int)’)

    PTLsim is not friendly towards cross compilation (which you will have to do if your default toolchain doesn’t match PTLsim’s expectations). I used crosstool to build my toolchain but I also needed to copy stubs-32.h into my cross compiled toolchain’s include directory (which is write protected by default).

    I wound up changing every line with g++ to $(CC), every line with ld to $(LD) and every line with objcopy to $(OBJCOPY). I needed to manually set the I also need to edit the *.lds files so that they would search for libraries in the correct place (they are rather SUSE centric in the shipped build).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: