LLVM has libraries that allow easy reading and writing of bitcode. This enables e.g. writing code generators that output llvm bitcode (which one can compile to native code using llvm), or loading bitcode files and performing optimizations or analyses on them.
One can even do so from OCaml.
Is there a library to load LLVM bitcode into Mono (F#), and browse it as e.g. an object tree?
(Note: I do not want to execute LLVM bitcode in Mono, just load the code and browse the structures.)
llvm-fs is a set of F# bindings for the LLVM project.
Bonus reading:
Building a simple compiler with F# and LLVM on windows.
Related
I'm trying to use the Clang Compiler FrontEnd to compile C++ for OpenCL to SPIR-V.
I assume that this is done by creating a clang::driver::toolchains::SPIRVToolChain which is defined in header SPIRV.h. However, this header is located under LLVM_ROOT_DIR/clang/lib/ToolChains/, which only exists in the LLVM project folder. It is not installed with the rest of Clangs headers.
Am I supposed to only interface abstract class clang::driver::ToolChain in order to perform the compilation, or do I have to modify the LLVM/Clang-installation?
I'm developing a framework for iOS, it mixes Swift and Objective-C inside, distributed in binary form without source code.
Since Xcode 13, I observe a warning when importing this framework:
'MyFramework.framework/Modules/MyFramework.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo'
is either malformed or generated by a different Swift version. Note
that it uses an unstable format and may leak internal project details,
it should not be distributed alongside modules
It seems it doesn't like .swiftsourceinfo file. Maybe I should just manually remove this file from the package, but I cannot find any explanation of what it is made for.
Even when I set BUILD_LIBRARY_FOR_DISTRIBUTION=YES, Xcode builds the framework with that .swiftsourceinfo file. So why does the warning say "it should not be distributed alongside modules"?
What is the purpose of .swiftsourceinfo file? Can I safely remove it from the built framework?
How are you building your binary frameworks?
Generally, .swiftsourceinfo are not stable across different versions of Swift Compiler so shouldn't be included when distributing the framework (especially when BUILD_LIBRARY_FOR_DISTRIBUTION=YES). So they shouldn't be included in the .framework package. If you build your framework using xcodebuild archive it should not generate .swiftsourceinfo
I have a Qt project that was developed on MacOS. I've been given the job to make it compile on Windows.
My current problem is that compiler (Microsofts LLVM clang-cl) seems to be ignoring objective-c++ files, and the QtCreator is freaking out on #import statement (#import of type library is an unspported Microsoft feature). It also freaks out about a lot of stuff after that, but I'm guessing it's due to the import not being handled properly.
I was led to believe that win32-clang-mvsc was the only QtCreator compiler that supports compilation of objective-c++ files on windows, however, it doesn't seem to support the #import statement.
I've looked around and it seems that I would need GNUstep to be able to compile that on windows, and I'm not entirely sure it would work.
Is it possible to use the whichever compiler GNUstep provides with QtCreator? Or is there some way to use the compiler I'm already using to compile the files with #import statement?
The error I'm getting on the build is that ***.obj file doesn't exists, where *** is the name of the file with the #import statement. I'm guessing the compiler skips it and doesn't generate the .obj file, so something can't find it. I'd guess it was the linker, but I'd expect linker errors then, not a generic file not found error.
You can use the GNUstep Windows MSVC Toolchain to build Objective-C code using Clang on Windows. We’re also using this in a Qt project. You’ll just need to tell your build system to use the necessary flags for Objective-C files (e.g. using QMAKE_EXTRA_COMPILERS if you’re using QMake). This Qt example project for using Objective-C in a Qt project for Android should get you started.
The error you’re seeing about #import is likely because your project is using some clang-cl flags like /TC//TP that force the compiler to treat the file as C/C++ irrespective of its extension. Removing these flags should make this error disappear.
Please open issues in the GitHub project linked above if you need further help with the setup.
I am trying to make an iOS framework. My code includes c++11 features.
When I build the framework target I get errors such as:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctime:56:9: No member named 'clock_t' in the global namespace
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ctime:58:9: No member named 'time_t' in the global namespace; did you mean 'size_t'?
How can I resolve this? Thanks.
UPDATE:
Here is my Apple LLVM 6.0 - Language-c++ settings:
Regular iOS project with that c++11 code compiles without errors.
you need to explicitly add libc++ as a linked library under general tab.
I don't know how far it will work fine in your scenario. I got similar kind of error when I tried to compile and build so. I will share what I did :
1.Goto your project Build Settings.
2.Click Build Settings.
3.Search for Apple LLVM 6.0 - Language-c++ .
4.set c++ standard library as libstdc++ .
Then try compile the project.
This might not the exact solution.
I just shared what worked for me when I am facing the similar kind of errors as yours.
Thank you!
Have you tried setting the C++ Language Dialect to C++11? It's in the same place as the C++ standard library setting:
Go to Build Settings
Select your Target, and click Build Settings.
Search for Apple LLVM 6.0 - Language-C++
Set C++ Language Dialect to C++11.
You might also have to set the C++ Standard Library to libc++.
Xcode adds all headers to the "Headers" build phase by default. So, I solved my issue by removing all unnecessary C++ headers from the build phase.
My project has dependent libraries that don't compile under the LLVM compiler, so my project is not compatible with ARC.
How can I include other third party libraries and source files that are ARC compatible in to my non-ARC project.
Thanks in advance.
You could add a complier flag to each compile source in the Build Phases. The flag you should add is -fobjc-arc
If you're not using LLVM your main project won't be able to use ARC at as it's a LLVM 3.0 feature.
If I was you I'd make your main project/target/app compile under LLVM and include your older external dependencies as static library dependencies. Once the static libraries are compiled the fact that they're ARC or non-ARC doesn't make a difference.
You'll need to move to Xcode workspaces that contain multiple Xcode projects, one for each of your third party libraries and have static library targets for each project. This setup allows independent build settings and greater flexibility. You'll find a lot of people create static libraries for third party things these days.
Checkout a blog post or two on setting up static libraries within an Xcode workspace, it's quite common these days.