Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2016-12

LLVM

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Schnell

I remember that some time ago an LLVM version of fpc was under discussion.

I'd like to know the state.

Background: I might be interested in doing a project that runs in the browser. It seems that the upcoming technology for this is WebAssembly. I found that an LLVM backend for WebAssembly somewhere is under construction.

Of course another (better) option would be a fpc directly creating WebAssembly, but I understand that this will take a lot of time.

Thanks,
-Michael

Reply by email

Jonas Maebe
to Michael Schnell
Michael Schnell wrote
I remember that some time ago an LLVM version of fpc was under discussion. I'd like to know the state.

If you don't perform control-flow-based LLVM optimizations, almost everything works on Darwin/x86-64 (and Linux/x86-64, except for safecall -- the reason for this extra is that safecall is simply ignored on Darwin). There are currently about 40 testsuite failures left on Darwin/x86-64 with LLVM, compared to 26 without LLVM.

With such optimizations enabled, everything apart from try/except and try/finally should work:
* "should" because I did not actually test this, given that exceptions are pretty common and hence it's not possible to get a baseline
* it's a pretty big "apart from", obviously. I have some ideas on how to fix this without breaking compatibility with code produced by the regular code generators, but I'm still working on it.

Note that even once I fix this, exceptions still won't work equally well as with our regular code generators, due to the points mentioned under point 3 of "Progress" at http://wiki.freepascal.org/LLVM

Background: I might be interested in doing a project that runs in the browser. It seems that the upcoming technology for this is WebAssembly. I found that an LLVM backend for WebAssembly somewhere is under construction.

You would also have to write a WebAssembly RTL for FPC, and you would have to add some FPC code generator support for a WebAssembly target (see the first FAQ on the wiki page mentioned above). LLVM IR is by construction architecture- and platform-specific. It's not like Java bytecode or CIL (or, for that matter, WebAssembly).

Jonas

Reply by email

Karoly Balogh (Charlie/SGR
to Michael Schnell: I remember that some time ago an LLVM version of fpc was under discussion. I'd like to…

Hi,

Michael Schnell wrote
Of course another (better) option would be a fpc directly creating WebAssembly, but I understand that this will take a lot of time.

There is some interest in a WebAssembly backend, but yes it will take a lot of time. No spoilers for now, and nothing to see, move along.

There is also some work underway, to compile Pascal code to JS, but that's a separate project, not implemented as an FPC backend.

Charlie

Reply by email