polyglot-compiler / JLang

JLang: Ahead-of-time compilation of Java programs to LLVM
http://polyglot-compiler.github.io/JLang/
Other
284 stars 29 forks source link

Format cpp runtime code and update editor project config files #48

Closed guoyiteng closed 4 years ago

dz333 commented 4 years ago

This breaks the build on my Mac (haven't tested on Linux). I get the following error when compiling native code:

Compiling native/reflect.cpp In file included from native/reflect.cpp:3: In file included from native/reflect.h:5: In file included from native/class.h:13: In file included from /Library/Java/JavaVirtualMachines/jdk1.7.0_80.jdk/Contents/Home/include/jni.h:39: /Users/drew/tools/clang+llvm-5.0.1-final-x86_64-apple-darwin/include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found

include_next

^~~~~ 1 error generated. make[1]: *** [out/native/reflect.o] Error 1

guoyiteng commented 4 years ago

Yeah, this is a macOS-only problem. I've encountered this before. See this article for a solution: https://silvae86.github.io/sysadmin/mac/osx/mojave/beta/libxml2/2018/07/05/fixing-missing-headers-for-homebrew-in-mac-osx-mojave/ You have to run this pkg every time after you upgrade your macOS.

dz333 commented 4 years ago

What did you change that caused my build to break though? I can build the master branch no problem, even though I have upgraded my OS since my last build.

(But that fix did work)

guoyiteng commented 4 years ago

I have no idea... Is it possible that the master branch somehow caches the compiled files so the c compiler did not actually run? However, we need to fix this issue anyway if we want to continue supporting it on macOS. The latest macOS Catalina removes this workaround pkg file. I will look for a solution these days.

guoyiteng commented 4 years ago

It looks like this is the correct way to go: https://apple.stackexchange.com/questions/337940/why-is-usr-include-missing-i-have-xcode-and-command-line-tools-installed-moja

Add the -isysroot flag to your compile flags to automatically include the appropriate SDK header directory and avoid the need for the /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg package that will "in a future release, ... no longer be provided."

Examples:

-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

or

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk

You can use xcrun --show-sdk-path to find the default SDK path.

guoyiteng commented 4 years ago

I added some compilation flags in runtime/Makefile. Now, it compiles on macOS Catalina.

dz333 commented 4 years ago

Looks good to me!

But can you also actually update the README.md with how to get started using the IDE now that you have configs for it? (I just opened up the project in IntelliJ and still had a ton of warnings etc. A quick how-to on getting IntelliJ to build the compiler for you would be great)

guoyiteng commented 4 years ago

Ok, I updated the README and the config files. Now, it could compile and run the unit tests without any problem. I have already tested it on both macOS and Linux. Let me know if you encounter any problem when running it.