Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: ciVic on September 04, 2013, 09:28:33 AM

Title: gcc and precompiled header
Post by: ciVic on September 04, 2013, 09:28:33 AM
Hi all,

since the gcc is very slow on an A4000/040, especially when using the STL, I tried to use precompiled header with the m68k gcc 3.4. Unfortunately I can only see an error message "PCH not supported". I'm wondering why, since it works doing the same on a linux machine and 3.4 should support precompiled header. Maybe somebody knows a solution or a newer gcc version for classic Amigas?

FYI, here are the hello.cpp and hello.h:

Code: [Select]

#pragma once
#include <string>
using namespace std;

class Hello
{
public:
        Hello() : s(&quot;Hello World!&quot;) {};
        string s;
};



Code: [Select]

#include "hello.h"
#include

using namespace std;

int main()
{
        Hello h;
        cout << h.s;
        return 0;
}



and I can compile it this way:

Code: [Select]

g++ -x c++-header hello.h
g++ -H hello.cpp
Title: Re: gcc and precompiled header
Post by: matthey on September 04, 2013, 04:37:23 PM
Quote from: ciVic;747001

since the gcc is very slow on an A4000/040, especially when using the STL, I tried to use precompiled header with the m68k gcc 3.4. Unfortunately I can only see an error message "PCH not supported". I'm wondering why, since it works doing the same on a linux machine and 3.4 should support precompiled header.


The Amiga GCC 3.4 68k version is an unofficial version of GCC 3.4. It also seems to be a work in progress that is not as finished or polished as the last 2.x version. I don't know why the PCH support is not supported, specifically. You should make sure you installed and are using the 020 versions of GCC 3.4. Other ways that may speedup compilation:

o If you have enough memory, you could copy the most common header files to a recoverable ram disk.
o PFS (Aminet)
o TLSFMem (from Aminet)
o Move kickstart and SSP to fast memory (Mu libs and 68040.library from Aminet)
o CopyMem040 (CopyMem from Aminet)
o Don't use C++ :P.

I find the speed of GCC 3.4 68k on C only code to be reasonably fast on my CSMK3 68060@75MHz with UltraSCSI 15k RPM drive and 68060 versions of the above suggestions for the 68060.

Quote from: ciVic;747001

Maybe somebody knows a solution or a newer gcc version for classic Amigas?


Anything newer will be slower. There aren't any better alternatives than GCC for C++ on the 68k Amiga either. Cross compiling to 68k with a newer version of GCC can be fast but GCC 4.x generates ELF instead of HUNK format executables. ELF is not a problem if you are using AROS though.
Title: Re: gcc and precompiled header
Post by: ferrellsl on September 04, 2013, 07:09:02 PM
Maybe you should try using a cross compiler instead of developing on classic hardware.  AmiDevCpp is excellent for this purpose and it supports all Amigas, classic, NG, MorphOS, and AROS....best of all it's free.  http://http://amidevcpp.amiga-world.de/download.php?HR_LANG=english

If that's not acceptable maybe you should develop using WinUAE and transfer your compiled binaries to a classic system for compatibility testing.  Call me spoiled, but trying to develop software on 25 year old hardware is beyond painful.
Title: Re: gcc and precompiled header
Post by: nicholas on September 04, 2013, 07:46:57 PM
You might want to try v7 of SAS/C as it has C++ support and is a lot faster at compiling stuff than GCC.  It's STL support is nonexistent though, just the pre-STL Standard C++ library.

http://aminet.net/package/biz/patch/expsascxx

From the ReadMe:
Quote
SAS/C++ limitations
-------------------
These are features which we do not support as specified by the C++
draft.


Glossary
--------
   POD -- 'plain old data', basically a type using only C features
   pseudo-destructor -- a destructor call that names a non-class type,
      like 'p->~int()'.  These are used for generic programming.



No identifier form ANSI digraphs (i.e. "and", "and_eq", etc.)

No universal character names

no 'bool' type

no "extern inline"

global/static initialization/destruction order differences
   local statics are destroyed at module cleaup, not synced with "atexit()"

temporary lifetime differences
   The draft specifies destruction at the end of a full expression.
   We destroy early for operands of "? :", "&&" or "||".

no "operator new[]" or "operator delete[]"

no placement delete declarations

'wchar_t' is not distinct from other integral types

destructor name handling differences

restricted pseudo-destructors

conditional expression handling differences

scope of variable declared in 'for' initialization
   The draft behavior must be enabled by the -!Aoldforscope option.
   The draft behavior is the default on the mainline.

no 'mutable' keyword

no 'explicit' keyword

no namespaces

no 'using' keyword

no 'asm' declaration

linkage limited to "C" and "C++"

no "{}" empty initializer

static member data variables may not be initialized in the class definition

virtual base construction, destruction, and copying differences?

no overriding of virtual function return type

miscellaneous overloading differences
   The overloading code of the translator was written before the draft
   specified this very well.  There are bound to be differences.  In
   fact, probably every different compiler will interpret some things
   differently sometimes.

enum types always promote to int, never to unsigned or other integral types

no operator overloading on enum types

templates
   no 'export' keyword or separate compilation
   no template template parameters
   no member templates
   no function member pointer template arguments
   no partial specialization of classes or functions
   no out of line definition of member classes
   no default template arguments
   no function template default arguments
   no checking of name dependency rules
   no 'export'ed templates
   no template class member friend declarations
   no deduction from derived class pointer

no exceptions

C++ library
   We have the "classic" C++ library.
   The draft version has lots of nice stuff, like the Standard Template
   Library and templatized basic types, which we don't have.

Obsolete C++ features and bugs
------------------------------
These are "features" of the translator which are disallowed by the draft.

'overload' keyword, not allowed by default

default base class constructor initialization

constant expression overflows should be diagnosed

skipping initializations using non-POD types with 'goto' should be diagnosed
   The translator does not diagnose cases like references.
Title: Re: gcc and precompiled header
Post by: ciVic on September 05, 2013, 09:36:11 AM
Indeed I'm coding with WinUAE, but I like my real Amiga and want to use it. Unfortunately I must use C++ and a "modern" compiler since I need some C++ classes from other sources like rapidjson and twit curl.

I also found out the reason for the "PCH not supported". This error message was inserted with some patches for Amiga. So there is no hope that I could get this work.

@matthey Thx, seems like your hints speed up the compiler a bit.