cda-group / arc

Programming Language for Continuous Deep Analytics
https://cda-group.github.io/arc/
44 stars 6 forks source link

Implement Compiler Driver #382

Closed frej closed 2 years ago

frej commented 2 years ago

We need a proper compiler driver.

Proposed requirements:

segeljakt commented 2 years ago

Some questions

One other thing that would be nice:

frej commented 2 years ago

A bash script is probably the most flexible.

The structure would be to first parse the command line and building up the steps of the pipeline and then execute it.

Do we need to generate the executable, e.g., make install, or can we have it just be in the root directory?

We should probably try to autodetect that, so it works both when run from the build directory and when installed.

What should the name of the driver be?

arc there is no need to distinguish it a shell-script.

When you re-run the driver for an Arc-Lang source file, it will reuse the same target directory as before (to exploit Rust's incremental compilation).

You should have the option of having a shared target directory, but it should not be the default. If you have two arc programs in the same directory and compile one of them, it should not change the state of the other unless you explicitly say so.

segeljakt commented 2 years ago

You should have the option of having a shared target directory, but it should not be the default. If you have two arc programs in the same directory and compile one of them, it should not change the state of the other unless you explicitly say so.

I meant something like this. Every script has its own target directory. In the first version, maybe it's ok to not support program compilation of multiple files 👀

$ ls -R
app.arc
$ arc build app.arc
$ ls -R
app.arc
app/
    src/
       main.rs
    Cargo.toml
$ arc run app.arc
$ ls -R
app.arc
app/
    src/
       main.rs
    Cargo.toml
    Cargo.lock
    target/
$ vim app.arc # make some changes
$ arc build app.arc # only main.rs and Cargo.toml are overwritten, other files are untouched
$ arc run app.arc # target/ and Cargo.lock are reused from the previous run

We could do like cargo where we have arc check arc build and arc run (In the above steps we could have just used arc run).

segeljakt commented 2 years ago

I think I got the driver working, but I don't know how to do the makefile. Some questions:

frej commented 2 years ago

I have comments in #387.

but I don't know how to do the makefile

What makefile, are you talking about CMake?

Is it OK if the makefile compiles with CMake to the default build directory? If not, I'm not sure how to get the build directory path.

This doesn't make sense, a makefile which runs CMake? I clearly doesn't understand what you mean. The compiler driver isn't responsible for building the tools.

Is it OK if the makefile symlinks the binaries to /usr/bin?

Leave installation to the standard CMake mechanisms, -DCMAKE_INSTALL_PREFIX=...

Is it OK if the makefile adds ARC_RUNTIME_DIR to ~/.bashrc (after asking the user)?

This should not be needed, the driver should be able to figure out its own location. That way everything will work if you run it from the build directory or the installation directory.

segeljakt commented 2 years ago

This doesn't make sense, a makefile which runs CMake? I clearly doesn't understand what you mean. The compiler driver isn't responsible for building the tools.

In my opinion, I don't think the user should have to cd into arc-mlir to build everything. It would be easier if we could build everything from the root directory. Therefore I thought maybe a solution could be to have a makefile at the root. Maybe we could instead add CMake to the root.

This should not be needed, the driver should be able to figure out its own location. That way everything will work if you run it from the build directory or the installation directory.

👍 I can add so the script figures out where it is.

I'll fix the comments in the PR

frej commented 2 years ago

In my opinion, I don't think the user should have to cd into arc-mlir to build everything. It would be easier if we could build everything from the root directory. Therefore I thought maybe a solution could be to have a makefile at the root. Maybe we could instead add CMake to the root.

Why would we need anything more complicated than the current arc-mlir-build? Just move it to the top if you don't want the user to have to say <srcdir>/arc-mlir/arc-mlir-build (and rename it). arc-mlir-build doesn't require cwd to be <srcdir>/arc-mlir/.