[fpc-devel] LLVM code generator

Jonas Maebe jonas at freepascal.org
Tue Dec 25 19:14:53 CET 2018


On 2018-12-02 11:26, Jonas Maebe wrote:

The LLVM version of the code generator has been significantly improved 
in the mean time:
* several testsuite failures and other bugs have been fixed
* Lazarus (from the fixes_2_0 branch) can now be built (for 
Darwin/x86-64/Cocoa at least, have not tested other platforms) (*) and 
works correctly
* initial support for Linux/AArch64 has been added (which fortunately 
did not require many changes to the compiler)
* a few attributes have been added to slightly improve the quality of 
the generated code

(*) There is some code in Lazarus that implements interface methods 
using private methods declared in other units. Delphi rejects such code 
(methods that implement an interface method have to be visible in the 
current class), and such code also failed with the LLVM code generator 
while it succeeded with the other ones. I've fixed the trunk compiler so 
it now prints an error regardless of which code generator you use (will 
still be added to the User_Changes_Trunk wiki page).

Additionally:

> * investigate the RTE 217 when you compile a program with an error in 
> it

This turned out to be a bug in the clang version that's part of Xcode 8. 
It works fine with e.g. Clang 7.0.

> * add support for a volatile() built-in function similar to how we
> have unaligned(), to fix e.g. the endless loop in tests/test/tmt1 (or
> in general: global variables used for cross-thread synchronisation)

Added.

> To test:
> * make sure you have clang on your system (the ones from Xcode work
> fine too) and that it's in your path. If not, you can download one
> from http://releases.llvm.org/download.html#7.0.0

Check out the https://svn.freepascal.org/svn/fpc/branches/debug_eh/ 
branch

> * build FPC as follows

This is easier now:

** Darwin (can also use a higher version than 10.6, but the built-in
default --10.5--- won't work):
    make OPT="-WM10.6" LLVM=1 all -j 4 FPMAKEOPT="-T 4"
** Linux: you may also have to specify the library path to libgcc_s.
E.g. on Ubuntu 16.04:
   make OPT="-Fl/usr/lib/gcc/x86_64-linux-gnu/5" LLVM=1 all -j 4 
FPMAKEOPT="-T 4"

The previously mentioned LOCALOPT parameter is no longer necessary, and 
as a result building the WPO versions of the compiler also works again.


Jonas



More information about the fpc-devel mailing list