|
|
Subscribe / Log in / New account

GCC front-ends

GCC front-ends

Posted Jan 1, 2025 18:30 UTC (Wed) by jklowden (guest, #107637)
In reply to: GCC front-ends by ibukanov
Parent article: An Algol 68 front end for GCC

LLVM is the target, right, the low-level virtual machine? Clang is the compiler toolkit. My experience with clang over a decade ago is why we opted for GCC over clang for COBOL. If the GCC API is criticized as hard to use, it has one singular advantage over clang: it exists.

Those years ago, I wanted to use clang to parse C++, and write the metadata to a database. I left with the sense that it might be possible, but I'd have to write the manual first.

(I still *do* want to write that tool. It would underpin a source-code navigation tool for C++, something that doesn't exist for large code bases. We have C-based tools like GNU Global and cscope, and I remember using a web-based text-search engine, but nothing that could distinguish open(2) from std::stream::open(), or report the call stack that modifies a variable.)

The GCC Internals manual runs some 800 pages. Even at that, the 10% of that document devoted to front-end development woefully inadequate; after all, the ISO COBOL specification is 1280 pages, and it describes only one language. But that document, plus a tutorial example, gave us a toehold. Within a week we had the "hello world" version of a COBOL compiler. Then it was just a quick 8 or so man-years of work.


to post comments

GCC front-ends

Posted Jan 1, 2025 19:07 UTC (Wed) by linuxrocks123 (subscriber, #34648) [Link]

The tool you want to write sounds like it could be most easily written as a client of the clangd language server.

https://clangd.llvm.org/

GCC front-ends

Posted Jan 1, 2025 22:32 UTC (Wed) by ejr (subscriber, #51652) [Link]

Having had to port front- and back-ends from LLVM 12 to 18, I concur on the lack of an API.

Both systems have their benefits and drawbacks. Neither "wins." What we had to do would have been much more painful in GCC for various reasons. But so was the forward porting. meh. That's why we're "engineers," right?

GCC front-ends

Posted Jan 2, 2025 14:58 UTC (Thu) by iabervon (subscriber, #722) [Link]

LLVM is the cross-language backend part; clang is the C family frontend part. Unlike with GCC, the same frontend is used for C, C++, and ObjC, but I assume Algol or COBOL would be a separate frontend (like Rust, for example).

GCC front-ends

Posted Jan 4, 2025 23:31 UTC (Sat) by geofft (subscriber, #59789) [Link]

I found the LLVM tutorial excellent when I was going through it recently - I got a working AOT compiler for a tiny subset of Python going in a couple of hours.

This is the opposite of what you're looking for, to be fair; I wanted to use LLVM's compilation backend with a non-C language, and you wanted to use Clang's C parser. But there is a libclang tutorial that looks brief and readable that might be what you wanted. (Perhaps it did not exist at the time.)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds