Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External dependencies in Jou programs #214

Closed
Akuli opened this issue Feb 11, 2023 · 0 comments · Fixed by #221
Closed

External dependencies in Jou programs #214

Akuli opened this issue Feb 11, 2023 · 0 comments · Fixed by #221

Comments

@Akuli
Copy link
Owner

Akuli commented Feb 11, 2023

This may be the last thing I need to do before I can start working on a self-hosted compiler (#116).

Let's say you want to write a C or Jou program that uses LLVM:

  • On Windows, you give a path to LLVM-C.lib as a command-line argument to the linker, and you make sure that a somewhat large collection of DLL files is available when the program runs. You need to download these files by either running LLVM's installer or by extracting them from LLVM's installer without running the installer.
  • On Linux, before you compile the program, you need to run sudo apt install llvm-11-dev on terminal to install LLVM. Then you can run a terminal command llvm-config-11 --ldflags --libs (where 11 is the LLVM version), which prints something like -L/usr/lib/llvm-11/lib -lLLVM-11. These are flags that you need to give to the linker.

In other words: it is a mess, and what exactly you need to do depends on your OS. Maybe some day there will be a Jou package manager that handles the mess for you.

But for now, I think it would be good enough if you could specify linker flags in Jou code. You still need to download/install the external library some os-specific way, but at least it would be possible to use it. Maybe a linker_flags keyword? Something like this:

if WINDOWS:  # Code inside this would be compiled only on windows.
    linker_flags "lib/LLVM-C.lib"
else:
    linker_flags "-L/usr/lib/llvm-11/lib -lLLVM-11"

declare LLVMSomeFunction(...)

def main() -> int:
    LLVMSomeFunction(...)
    return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant