0

I have a host compiler(X86_64) GCC 4.6.3 & Target compiler(MIPS) GCC 4.5.3,

Is there a way to use the host compiler's front-end along with target compiler's back-end?

My question may be a bit weird, but reason for asking this is to use the latest C++11 standards while coding for embedded platforms where the target compiler still lags to support these features.

(I'm assuming all these C++11 features are implemented in compiler front-end & nothing related to CPU specific back-end)

Also is it possible to use LLVM + GCC combination for this requirement?

(Any suggestions/tips appreciated!!)

EDIT: (Added possible options known to me!)

  1. Getting the latest toolchain from chip vendtor (Time consuming)
  2. Building my own toolchain from GCC source (3rd party library compatibility issues)
Arunprasad Rajkumar
  • 1,374
  • 1
  • 15
  • 31
  • Get GCC 4.6.3 for MIPS? – R. Martinho Fernandes Oct 18 '13 at 13:31
  • @R.MartinhoFernandes, it is somewhat difficult and time consuming to get it from the chip vendor. – Arunprasad Rajkumar Oct 18 '13 at 13:34
  • 1
    You're assuming wrong, an awful lot of C++11 features are part of the standard library (in your case, `libstdc++` 4.5.3, you see the problem...). As a side note, GCC 4.6.3 is far from offering "the latest C++11 standards", GCC 4.8.1 is feature complete as far as the core language is concerned but far from complete on the standard library side. – syam Oct 18 '13 at 13:39
  • Your best bet is probably to build your toolchain yourself, provided your target platform is not too exotic (read: doesn't require patches to the compiler). I for one had to resort to that because I couldn't get my hands on a pre-built GCC 4.8 cross-compiler for ARM. – syam Oct 18 '13 at 13:42
  • @syam I initially thought of compiling my own, but I'm afraid of vendor specific patches :( – Arunprasad Rajkumar Oct 18 '13 at 13:45

1 Answers1

3

No. There are two reasons:

  • The assumption does not hold. C++11 features are spread across the frontend, the backend and the standard C++ library. A few features might be possible in front-end only without the other parts, but most of them not.

  • GCC policy is to keep the front-end and back-end linked together. It has no technical reason, it's purely political. But it prevents exchanging the front-end.

Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
  • @"Jan Hudec", You mean both F-E & B-E are not compatible across different versions of GCC? – Arunprasad Rajkumar Oct 18 '13 at 13:43
  • 1
    He means that there is no "frontend" and "backend". GCC is one monolithical piece, not modular. – R. Martinho Fernandes Oct 18 '13 at 13:58
  • 1
    It can be impressive what you can do. I was able to use C++11 variadic templates (I "compile-runned" my compile-time turing machine simulator) with my GCC backend without doing anything specific about C++ support (my goal was to support C, which I succeeded in). All the things that pop up my mind, like decltype, variadic templates, auto, initializer lists don't look as if they would require backend support. – Johannes Schaub - litb Oct 18 '13 at 20:39