www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Can LLVM generate a compiler once implemented?

reply Justice <J.Justice gmail.com> writes:
Essentially, is LLVM a compiler generator or does it simply a 
generic compiler that one builds languages for?

e.g., could I design my own language using LLVM and get something 
like "myLang++.exe" and use independently of anything LLVM? 
(e.g., sell it, include it in an app to compile user programs, 
etc?)
May 02 2016
next sibling parent Joakim <dlang joakim.fea.st> writes:
On Monday, 2 May 2016 at 23:29:53 UTC, Justice wrote:
 Essentially, is LLVM a compiler generator or does it simply a 
 generic compiler that one builds languages for?
It was originally a set of libraries that facilitated working with a kind of generic assembly language, the LLVM Intermediate Representation (IR), that most languages could be compiled to. Eventually, Apple wrote their own compiler for C and C++, clang, that built on llvm, and other languages like Haskell have followed suit. Maybe there are more LLVM tools now to help you transform your language to the IR in the first place, ie parsers and the like, but ldc uses the dmd frontend for that.
 e.g., could I design my own language using LLVM and get 
 something like "myLang++.exe" and use independently of anything 
 LLVM? (e.g., sell it, include it in an app to compile user 
 programs, etc?)
Yes, LLVM is made available under the very liberal UIUC license, which allows you to do almost anything you want with it: http://llvm.org/docs/DeveloperPolicy.html#copyright-license-and-patents However, the license does not deal with patents. They are considering re-licensing as Apache, despite the statement in that link about the difficulty of re-licensing, and the Apache license is still very liberal while having some language covering patents too.
May 02 2016
prev sibling parent David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
Hi there,

On 3 May 2016, at 0:29, Justice via digitalmars-d-ldc wrote:
 […] is LLVM a compiler generator or does it simply a generic 
 compiler that one builds languages for?

 […] could I design my own language using LLVM and […] sell it, 
 include it in an app to compile user programs, etc?
Although the topic is slightly off-topic for this list (which deals with LDC, a compiler using LLVM, rather than the latter itself), the answer is easier than you may realise: Among your two statements, LLVM is much better described using the second one – it is a set of libraries for generating code, dealing with object file formats, and so on (and some associated tools). However, this does not preclude the sort of commercial applications you are hinting at. LLVM is licensed under a very liberal, BSD-style license, so you can use it as part of closed-source software just fine. In fact, a good part of the corporate contributors/users do so. There are some minimal requirements regarding attribution, but it's hard to imagine a use case where they would not be acceptable. Hope this helps, David
May 02 2016