Welcome, Guest. Please login or register.

Author Topic: GCC 4.x or Clang for 68k  (Read 6333 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: GCC 4.x or Clang for 68k
« on: May 13, 2014, 06:01:55 AM »
Quote from: nyteschayde;764347
I was just wondering if there would be any major roadblocks from compiling GCC 4.x for 68k using the cross-compiler to build it? I suspect someone would have already tried that but...


Quote from: SamuraiCrow;764348
It works on AROS 68k but uses the ELF loader so it probably won't backport to AmigaOS easily.


Right. It's not 68k that is the problem but the Amiga. There were Amiga specific versions of GCC up to 3.4.0 which most importantly generated Amiga hunk format executables but they were never "official". Anyone adapting and compiling the source for use on a 68k Amiga is going to need very good Linux skills, good understanding of the Amiga and 68k and lots of patience. On the other hand, the vbcc, vasm and vlink sources compile on my 68060 Amiga with minimal effort. There should be a new version of vbcc coming at some point but it is C only (no C++).
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: GCC 4.x or Clang for 68k
« Reply #1 on: May 13, 2014, 05:35:39 PM »
Quote from: nicholas;764363
Will vbcc support c++ at some point in the future or is it something that holds no interest for Frank and Volker?


I have heard nothing of C++ support. Volker is working on supporting OpenCL. The c99 support is also improving (but will probably never be 100%).
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: GCC 4.x or Clang for 68k
« Reply #2 on: May 13, 2014, 07:56:39 PM »
Quote from: LiveForIt;764386
Well you can compile for C++ (G++) compiler but Amiga header files are “C” code only no classes or namespaces or references and so, and when you compile for C++ the exe file gets bigger, unless you need classes, name spaces and/or references, it does not make sense.

But anyway C++ is nice monogramming language, one thing that is not always clear whit C++ is if argument is changed or if its not, C# is more clear on that issue, as you most to type “ref” where the argument is a “ref” type, any how “ref” are not so special pointers and address of “&” symbol does more or less the same thing.

Anyway you can more or less do the same thing in C as you can in C++, whit some clever workarounds.

I do not have much experience with C++ but I do know it is popular and needed for porting other programs to the Amiga. I know it's less efficient as I have looked at the resulting disassembled executables (I see indirect branches and lots of unused code). Regular C is less complex (simpler syntax), offers most of what I need and can generate more efficient executables. Some programmers need C++ and more GCC compatibility though. A newer version of GCC or Clang would be great but it really needs a persistent effort by a knowledgeable team like the original GeekGadgets team.
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: GCC 4.x or Clang for 68k
« Reply #3 on: May 13, 2014, 10:42:58 PM »
Quote from: nyteschayde;764395

I have CubicIDE which has GCC 3.3 for the 68k Amiga, but I cannot find those "alpha" versions anywhere on the web anymore. The GCC-lite packages on Aminet are very good and easy to get started with but they're only 2.7.0.


Maybe you couldn't find it because Back2Roots.org has been down. It's supposed to be coming back:

http://eab.abime.net/showthread.php?t=73684
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: GCC 4.x or Clang for 68k
« Reply #4 on: May 14, 2014, 04:42:10 PM »
Quote from: Bif;764420
C++ is not inherently less efficient than C. With equivalent quality compilers you should be able to produce the same quality of executable. Of course if you use some C++ specific features (e.g. exceptions (usually on by default) + STL library, etc.), you can find your EXEs to be larger due to all the embedded error handling, etc. But you can avoid or disable that kind of stuff. Yes there are some C++ features that come with a bit of overhead (virtuals, etc.), but nobody is forcing you to use that stuff - but when you do, it's usually for a good reason, and you would have to introduce the same indirections in non-standard ways in C code to achieve the same thing. On the other hand C++ provides additional features that can help you code things more quickly and safely (e.g. templates, etc., when used intelligently).


I imagine some of the C++ inefficiencies can be avoided if a programmer knows what they are doing but that is even more to learn. Compilers have improved for C++ as have some high end processors which now have indirect branch prediction. Processors are now enough faster that a few percent slower code usually means waiting for the next processor to provide a speedup. I'm surprised the game industry doesn't use regular C with a library of functions, macros and assembler optimizations, at least for non-x86_64 games.

Quote from: Bif;764420

I point that out because at some point I want to start some projects that will run on many platforms, including the Amiga. I don't really want to go back to coding the straight C I used for the first 10 years of my life as I've spent the last 15+ years doing C++ in the game industry (where everyone else freaked out about C++ "inefficiency" when we first started using it, now everyone knows better). It does sound like the Amiga is left out in the cold in regards to modern C++ compilers, which is a bummer. GCC 2.95 was somewhat decent at handling C++ syntax but I do recall there were complaints about code quality for the platforms we used it for, and I would imagine things are similar in Amiga-land, the C++ capable compilers available probably don't generate as efficient code as some of the old well optimized C variants.


GCC 2.95.3 generates the most optimized integer C code of any Amiga compiler. I expect some of that would translate to C++. However, the C++ support in GCC was not very mature at that point which probably means lack of support and bugs in certain areas. The 68k code generation quality in GCC 3 deteriorated but it is more modern. C++ is quite usable. I am able to compile DOSBox with whatever changes NovaCoder made. I didn't spot any heavy C++ specific code but this program is huge and it works. The speed is lacking on even a 68060 (without 68k dynrec which is almost working) but it's slow on slower x86 hardware too. It runs fine on UAE. It was compiled using AmiDevCpp which is probably the only sane way of compiling it until we get faster 68k processors (faster 68k fpga processors than the 68060 are being developed):

http://amidevcpp.amiga-world.de/index.php?HR_LANG=english

Quote from: Bif;764420

Anyway, I'm also curious to see if a more modern GCC or Clang gets supported at some point (for cross compiling, I can't imagine compiling on a 68k Amiga nor do I really want to). If not I'd probably take a quick look at it myself to see what kind of job it is, though I suspect it is a pretty big headache or somebody would have done it by now.


GCC would probably be less work (it has better 68k support already) but a group including SamuraiCrow have done some of the work of porting Clang/LLVM to AROS. Maybe you could help them. I can help some with 68k backend stuff but I don't know C++ (even my C knowledge is limited). I have and am working on the vbcc 68k vclib and have submitted bug fixed and optimized code for vbcc including the backend. My time is rather limited right now though. Give AmiDevCpp a try until there is a better option.
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: GCC 4.x or Clang for 68k
« Reply #5 on: May 15, 2014, 07:40:44 AM »
Quote from: AJCopland;764436
Why would we? Look everyone likes to go on about C being the fastest but that comes with the caveat that you can write fast code. C++ comes with the caveat that it's fast if you can write fast code.


Writing fast code requires knowing what is going on under the hood, so to speak. There is more to know with C++ as it's more complex. It's kind of like a luxury car with it's conveniences but then they tend to be less reliable because of the complexity and not as fast because of the extra weight. Some of the luxuries are so nice that regular C has adopted them.

Quote from: AJCopland;764436

If you want a good argument against C it's the Heartbleed bug, a bug that exists almost solely because of someone writing something in C for which there is no good argument to use the language.


I tend to agree with psxphil that it's not the language but the way the security software is developed and distributed. I read an article on it. There was something like 1 paid academic type programmer with an education in security algorithms and a handful of volunteer programmers that develop the security software for most of the world. The software is used by almost everyone because it's free and popular. What could go wrong?