Objective Modula-2 wrote:
Kevan Hashemi wrote:
If what OM2 says about GCC is true, then I think it's clear that the GCC team will do their best to make it hard for us to keep up with their changes, and therefore you are right: it's not worth bothering with.
Please don't take this out of context. I also wrote that not all GCC developers think this way. There are two lines of thought. One group is so concerned about possible circumvention of the GPL that they are willing to let this influence design choices. The other line is more concerned with technical merit, they think protecting the license is a job for lawyers not for engineers to do.
I don't want to take it out of context, that's why I'd like to read the forum e-mails myself, to see who it pushing for self-inflicted mutilation of their own code.
So, I've been looking through the LLVM pages. I'm new to this compiler-creation business, but it looks to me like the following steps are required to produce a self-compiling GPC on LLVM.
We first have to write a partial-syntax Pascal lexer and parser to create the abstract syntax tree (AST) that is required by the LLVM libraries. We can't use Bison to create the lexer and parser because Bison's output is a C-program. We have to write the lexer and parser from scratch in Pascal.
We compile the partial-syntax lexer and parser with the existing GCC-based GPC. We link our AST structure to the LLVM libraries. The result is a program that takes text input and produces LLVM Intermediate Representation (IR) code. The LLVM system appears to handle optimization and platform-dependent assembly from there.
Having tested the minimal Pascal compiler, we enhance its lexer and parser until it supports all the syntax that is used in its own definition. We are still compiling our Pascal with the GCC version of GPC.
Now we compile the lexer and parser with itself. Our lexer-parser is entirely written in Pascal, but there are C-like parts where we link to the LLVM libraries.
From here, we continue to enhance the compiler in steps. Each step requires defining a new feature without the use of the new feature. Frank says he does not like that, but I'm fine with it.
I will continue looking into the matter, in particular I'd like to learn more about the state of LLVM's optimisers, and hear from some existing users about how well it all works on different platforms. Also, I'd like to know how settled the library interface is, because it's here that we had problems with GCC, if I understand correctly.
So, please correct my mistakes. I may have misunderstood the process entirely.
Yours, Kevan