I hope you people don't mind but to shortcut some decisions I thought to pick some brains instead of slogging through documents and trial and error stuff. Apologies in advance.
First, I have a tool named flx
which was originally designed to invoke the Felix compiler flxg
which produces C++, then compile the generated C++, then find all the required libraries automatically, and link the final product (which could be an executable, shared library or archive), and run it. But it can also do native C and C++ (no Felix involved), and some Ocaml, and vague attempts have been made to integrate golang and other languages.
The tool has a few core features: first, you can write commands that are identical on Linux, Mac, and Windows and which do exactly the same thing on these platforms.
Secondly, the C++ compiler to be used is selected by selecting a plugin toolchain controller. Toolchains are not allowed to have semantic options. If you want different options, you have to use a different toolchain. As a result, toolchains have a fixed set of capabilities, no ifs/buts/configuration nightmares. A toolchain can compile to static object file, dynamic object file, build an archive library, link a shared library, link an executable, and check for compilation dependencies (header files) and that's all you're allowed to do.
Third, you do not specify search paths for either header files or for libraries to link with, nor are you allowed to specify the names of libraries. Instead, the language itself specifies abstract resources, and the tool uses another tool, flx_pkgconfig
to query the configuration database of meta-data to find out what is required (it's similar to pkconfig
but is a fully general database) So when you say to "run" a Felix program, it just runs. No arguments other than the file to run.
The tool does automatic dependency checking. No makefiles are required.
Also, the tool never writes anything into any place unless you tell it, except for a special cache directory. So when you run a program by specifying the source file all the binary crud is put in the cache. Unless you look there you will not find the executable.
So .. I want to add Chapel to the tools capabilities. For dependency specification I can program the Chapel toolchain to scan source code for special comments which specify requirements. This is built-in to Felix language. I use these special comments to allow autolinkage for C++.
Q1: what can/does the compiler generate? Is it only an executable?
Q2: Chapel has a way to lift C types and function. Does this work for C++ types and functions? Does it work, and if so how, if the LLVM backend is used?
Is there an in-languague way to specify abstract dependencies?
Just to explain here in Felix:
type intvector = "::std::vector<int>"
requires header "#include <vector>";
fun f(x:intvector)=> ...;
Now, if the function f is called, you must have an intvector value, so the intvector type is used, and so when Felix emits C++, it also emits the required #include directive. If it is not used, the #include is not emitted. You can also write:
.. requires package "metadata" ..
and now, this causes the toolchain to look for metadata.fpc
in the configuration database. That may contains specification to link some library. In C++ the requires clause is put in a comment
//@requires package "metadata"
Unless Chapel has a similar feature, I need to do as for C++ and put the specs in a comment. It's not optimal because in Felix, only resources actually required are included when building. The toolchain actually has to scan the C++ file to find these special comments to establish the abstract resource name so as to find the resource meta-data definition in the configuration database. This should work for Chapel too I hope.
Q3: The tool also gets rid of the need to specify environment variables to run the compilers and/or the executables under its control. It uses the meta-data database to find what is required, and sets it all up for you. Of course, if you run an executable standalone and it needs, say, a Chapel related resource such as a shared library with run time support, it can't help you. If the default is not to your liking you can specify a build control package on the command line. For example:
flx --chapel=chplsetup helloworld.chpl
will find the chplsetup.fpc file and set environment variables, command line switches, etc to run the chapel compiler, and then run the program. I have to program flx
to support this. So I need to know what is required.