apoch / epoch-language

Home of the Epoch Programming Language Project
Other
72 stars 3 forks source link

'llvm/Support/raw_ostream.h': No such file or directory #207

Closed stijnsanders closed 5 years ago

stijnsanders commented 6 years ago

This is a noob question. I've cloned the epoch-language repository. I've opened EpochSDK.sln. I've started build solution, but get this error:

fatal error C1083: Cannot open include file: 'llvm/Support/raw_ostream.h': No such file or directory

I've downloaded the LLVM source, but am not sure how to make #include <llvm/...> work for the EpochSDK solution...

apoch commented 6 years ago

Totally fair question! The EpochSDK build process is currently very... uh... questionable :-)

The way I build it locally is to configure Visual Studio's global directories setting to point to the LLVM headers and libs. You can reach this setting by right-clicking a project and choosing Properties, then selecting the VC++ Directories item from the list on the left. Just add the Include and Library directories that point to your (built) copy of LLVM.

There are probably other land mines in the setup process so please feel free to ping this ticket if you run into any other headaches.

This is obviously not a great approach and I will totally keep this ticket around to remind me to fix this properly. Thanks!

stijnsanders commented 6 years ago

teehee, let me guess, you have LLVM installed on D:\LLVM32 and 64-bits on F:\Epoch\LLVM!

stijnsanders commented 6 years ago

I got the current LLVM from its SVN, tried to build EpochSDK:

1>d:\data\2018\epoch\epochllvm\llvm wrappers\codegencontext.cpp(167): error C2039: 'MemoryBlock': is not a member of 'llvm::sys'
1>  d:\data\llvm\include\llvm\support\dynamiclibrary.h(23): note: see declaration of 'llvm::sys'
1>d:\data\2018\epoch\epochllvm\llvm wrappers\codegencontext.cpp(167): error C2065: 'MemoryBlock': undeclared identifier
1>d:\data\2018\epoch\epochllvm\llvm wrappers\codegencontext.cpp(167): error C2923: 'llvm::SmallVector': 'MemoryBlock' is not a valid template type argument for parameter 'T'
stijnsanders commented 6 years ago

tried adding

#include <llvm/ExecutionEngine/SectionMemoryManager.h>

but that one doesn't have sys::Memory::AllocateRWX

apoch commented 6 years ago

Are you running latest LLVM? I am not in front of my computer to confirm, but I think the current Epoch SDK builds against LLVM 3.8.0. Latest has a ton of breaking API changes that I have not had a chance to address on the Epoch side.

stijnsanders commented 6 years ago

Ah, that explains it. LLVM's trunk has 6.0.0 being readied. I'll try to get the 3.8.0 source to build...

stijnsanders commented 6 years ago

yippie:

1>------ Rebuild All started: Project: EpochLLVM, Configuration: Debug Win32 ------
2>------ Skipped Rebuild All: Project: EpochRT, Configuration: Debug Win32 ------
2>Project not selected to build for this solution configuration 
3>------ Rebuild All started: Project: EpochPDB, Configuration: Debug Win32 ------
1>  pch.cpp
3>  stdafx.cpp
3>  EpochPDB.cpp
3>  EpochPDB.vcxproj -> D:\Data\2018\epoch\Debug\EpochPDB.exe
3>  EpochPDB.vcxproj -> D:\Data\2018\epoch\Debug\EpochPDB.pdb (Full PDB)
1>  EntryPoint.cpp
1>  GCCompilation.cpp
1>  CodeGenContext.cpp
1>  Exports.cpp
1>  Generating Code...
1>     Creating library D:\Data\2018\epoch\\Bin\Debug\EpochLLVM.lib and object D:\Data\2018\epoch\\Bin\Debug\EpochLLVM.exp
1>  EpochLLVM.vcxproj -> D:\Data\2018\epoch\\Bin\Debug\EpochLLVM.dll
1>  EpochLLVM.vcxproj -> D:\Data\2018\epoch\\Bin\Debug\EpochLLVM.pdb (Full PDB)
========== Rebuild All: 2 succeeded, 0 failed, 1 skipped ==========

got any advice what's a good spot to start reading source? Is there a way to start it on a hello-world example so I can step through with a debugger?

apoch commented 6 years ago

Nice, congrats!

I think there are several different starting points depending on what your goals are:

If you want to play with the language itself, and write programs in it, the pre-packaged binary release is probably your best bet. (Sorry, I know, I'm telling you this after all the pain of setting up the sources!)

In fact that's still a good place to start because it gives you the compiler and a Visual Studio plugin to get syntax highlighting etc. Once you have the dev environment set up you can start poking the compiler sources ( https://github.com/apoch/epoch-language/tree/master/EpochDevTools/Compiler ) and/or the Visual Studio extension itself ( https://github.com/apoch/epoch-language/tree/master/EpochVisualStudio/EpochVSIX ).

Pipeline work is probably the hardest but also most needed, because if you want to build the whole self-hosting compiler from scratch, it's a giant process. To be totally honest I would have to try it myself just to remember the steps :-/

stijnsanders commented 6 years ago

My goals are, at least at first for now: Learning by doing, specifically:

So I thought I'd combine all three and started looking around for suitable projects to set my teeth in. Epoch looks like the best I've seen so far, primarily because it's a real Visual Studio project that I can just build and run without fighting around this pesky max/bsd/*nix default that's apparently in full swing with the young wave of newish developers.

That said, a good way to learn is by doing real work, so I hope I can slowly work my way into something somewhere and offer a little advancement of the project in return. Perhaps. Maybe. Don't get your expectation up too high, as I'm only a hobbyist programmer that puts only a few hours a week into projects like this. If I'm getting anywhere with anything, I'll let you know.

apoch commented 6 years ago

Awesome! So I have some good news and some maybe less good news...

For the C++ side of things, Epoch is actually moving away from having much implementation in C++ at all, aside from a very thin wrapper around LLVM (which you can find here for reference). There is also a tiny "runtime library" that is getting phased out in favor of using native platform APIs for almost everything except garbage collection, which I would like to statically link into Epoch binaries someday.

Basically I am pushing to get away from C++, but more importantly, the C++ that does remain is really quick and dirty stuff. It does not reflect best practices or even good habits... I would go so far as to say much of it is kind of shamefully bad. So if you're specifically interested in picking up C++ I would recommend supplementing with other projects :-)

Compilers on the other hand... compilers I can do :-) This is the Epoch source for the Epoch compiler. It is probably inscrutable and is definitely not documented enough, but feel free to poke around in there and ask questions on how things work. The organization is abysmal so a lot of things do not live in the right files. The file Exe.epoch is probably the most relevant place for looking into linking and generation of executable files. LLVM.epoch is a good resource for how the compiler does code generation and specifically how it converts from Epoch's internal representation to LLVM's internal representation.

For LLVM - my experience here yields two things you will probably find relevant. First, the C APIs for LLVM are drastically limited compared to the C++ APIs. Any non-trivial project should rely on C++ for speaking with LLVM. The EpochLLVM project is my specific wrapper for the C++ APIs, for example. Much of it is crufty and poorly documented but the general idea is that I wanted to create a C API for Epoch to use that is more stable and reliable over time than the LLVM one. In other words, I want to be able to drop LLVM 6.0.0 into the project and only impact that tiny wrapper instead of having to write a whole new codegen back-end.

Last but not least: please do not feel obligated to do anything in particular :-) I am honestly just glad that someone is interested in the project enough to reach out and ask questions. I totally understand the limited time thing (there's a reason I have no commits in the past 8 months) and I fully expect there to be a nasty learning curve to the Epoch project right now, because I have honestly neglected to make it approachable and intuitive at all.

apoch commented 5 years ago

I will be taking care to make the developer experience smoother and more convenient in the Renewal branch moving forward. I think this issue has served its purpose and can be closed.