Shop OBEX P1 Docs P2 Docs Learn Events
other GCC front-ends? — Parallax Forums

other GCC front-ends?

m00tykinsm00tykins Posts: 73
edited 2014-11-01 14:59 in Propeller 1
Hello all,

Since the Propeller supports GCC, I was wondering if it is capable of supporting the other programming languages supported by the GCC compiler. I'm trying to make a program for the propeller in Ada. AFAIK it should just be as simple as using the Ada GCC front end. Has anyone tried using a different front end for GCC before? How difficult would it be to get an Ada program running on the Propeller? Thank you very much!

-m00ty

Comments

  • ersmithersmith Posts: 6,053
    edited 2014-10-27 10:42
    Getting the compiler to work is the easy part -- getting the language run-time support and libraries to fit is the hard one :-(. I got the fortran front end itself to work with very little effort, but it would only run in XMM mode because the fortran run time library was so big. The default gcc language support routines are generally designed for desktop computers, not embedded systems.
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-10-27 10:56
    If any new languages become usable, let me know and I can add support for them in PropWare. CMake supports all of the languages in GCC already, so it won't (shouldn't) take long to add them to PropWare's build system.
  • m00tykinsm00tykins Posts: 73
    edited 2014-10-30 05:38
    Ok, thanks guys.

    The specific language I'm wanting to use with the propeller is Ada/Spark. Unfortunately though, Spark doesn't have GCC support so I'm thinking I'll just program in Ada using similar constraints as those found in Spark. AFAIK Ada is used mainly in embedded systems (Airplane control, ATMs, etc...) so I'm hoping RAM usage for the runtime won't be exorbitant. Do you foresee any issues with using Ada on the propeller? Also, does anyone have any helpful links to tutorials on exactly how to use a non-default frontend? (The system I'll be using to program the propeller in will be unix-like).

    Thanks again!

    Edit: One last thing... If Ada is not an option for running within the memory constraints of the propeller, I'm also considering using Cyclone, which if anything may take up less space than C as a runtime since it is basically C with a lot of constraints. See http://cyclone.thelanguage.org/ . :)
  • DavidZemonDavidZemon Posts: 2,973
    edited 2014-11-01 13:09
    What exactly do you mean by "front end?" Are you simply looking for an editor? A full IDE? The build system?
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-11-01 13:33
    GCC stands for Gnu Compiler Collection, and it supports more than just C and C++. The front end of the GCC compiler will convert a high level language to an intermediate language called Gimple. Gimple is then converted into the assembly language for the target processor.

    According to Wikipedia GCC has standard front ends for C, C++, Objective-C, Objective-C++, Fortran, Java, Ada and Go. There are also non-standard front ends for Pascal, Mercury, Modula-2, Modula-3, PL/I, D, VHDL and OpenMP.
  • Heater.Heater. Posts: 21,230
    edited 2014-11-01 13:34
    @SwimDude0614,

    The thing is that GCC has many "front ends". And many "back ends". We are not talking about editors, IDEs, or hardware programmers here.

    A compiler like GCC has many stages through which your input program passes on it's way from the source code you wrote to the executable you run.

    The text has to be parsed and all the "tokens" in it identified. Numbers, variable names, keywords etc. That is the "lexer"

    Then a tree like data structure is built up from those tokens that represents the structure of your program. That is the "parser"

    Then that intermediate representation can be transformed a few times. The "optimizers".

    Then whatever comes out can be turned into assembly language. "code generation"

    Then that can be assembled into your final executable code modules.

    Then you will need a linker to join all those modules into an executable.

    And so on and so on. I have no idea about the actual details.

    BUT if you are busy creating the infrastructure for all that work, like GCC, why not allow for compiling different input source languages? Just have to change the lexer/parser stages for each language. The "front ends".

    And of course why not allow the same compiler infrastructure generate code for different processor instructions sets? Just have to change the code generator/assembler stuff for each target machine. The "back ends".

    Specifically GCC has "front ends" for C, C++, Objective C, Ada, FORTRAN, Go, and a bunch of other languages.

    I did once get a "hello world" program written in FORTRAN running on the Propeller compiled with GCC for the ZPU machine run under the Zog ZPU emulator on the Prop. Crazy but true:)


    @m00tykins

    I have no idea about the work required to get GCC to compile Ada for the Propeller. In theory when you build GCC from source there is a configue option that tells it what languages to deal with. I forget what that option is now but that is how I got Fortran support on the Prop. Have a google around for "building gcc" and such.

    GCC compiles Ada source for the 8 bit AVR processors with less memory than the Propeller so that should not be an issue. http://sourceforge.net/projects/avr-ada/
  • TorTor Posts: 2,010
    edited 2014-11-01 14:39
    Getting the front-ends working is not the most difficult part. The problem is the run-time support, as ersmith said. Just as you need libc to run your C program (with support for all your calls to printf, strcpy, malloc, atoi, qsort, even open,read,write, and hundreds of others), Fortran requires libf (at least that's the traditional name), and most other languages need their own variant. And these need to be written or ported for each architecture, unlike the front-end itself (in principle at least).

    -Tor
  • Heater.Heater. Posts: 21,230
    edited 2014-11-01 14:59
    Yep, the run time can be the issue.

    Back in the day I had to support some guys porting their Ada compiler to the custom made "PC compatible" hardware the company I consulted to had designed.

    Problem was Ada has tasks, threads, or whatever Ada calls them built into the language. That requires run time support that in turn requires funky use of interrupts. And of course this custom hardware had a very strange, non-PC compatible interrupt arrangement.

    To bring this on topic: The Propeller does not have interrupts so I have no idea how Ada's concurrency model would be supported on the Prop.

    What do they do in avr-ada? Does it support concurrency? No idea.

    Anyway, Ada is horrible. Nobody wants to go there.
Sign In or Register to comment.