Skip to content

How to compile a Whole Julia project by parts #161

@kylincaster

Description

@kylincaster

Dear all,

I am working on developing and compiling a large Julia project. To facilitate the development process, I hope to compile the project incrementally, similar to the procedure used in C and C++ projects.

For instance, in a C++ project with three files (a.cpp, b.cpp, c.cpp), we can compile each file into object files (a.o, b.o, c.o) using a Makefile. Then, we link them together to create an executable program. This allows us to easily modify individual files.

Using StaticCompiler in Julia, we can generate IR code from the required functions and compile them into object files. However, there is a challenge: to compile a function, all the functions it invokes must be provided. For example, consider the following function that calls a fib function:

function double(x::Int64)
    return 2 * fib(x)
end

If we want to compile the double function separately, we need a way to defer the compilation of the fib function. This means compiling double function into an object file without requiring fib to be defined at the same time. One possible solution is to use a function declaration for fib, similar to how header files work in C or C++.

If anyone has suggestions or improvements, they would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions