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

Use optional environment variable to set clang path #2133

Closed
paulcadman opened this issue May 25, 2023 · 0 comments · Fixed by #2152
Closed

Use optional environment variable to set clang path #2133

paulcadman opened this issue May 25, 2023 · 0 comments · Fixed by #2152
Labels
CLI enhancement New feature or request
Milestone

Comments

@paulcadman
Copy link
Collaborator

For the native and WASM compile targets we run the clang executable from the PATH:

(exitCode, _, err) <- embed (P.readProcessWithExitCode "clang" args "")

So LLVM / clang is a dependency of the Juvix compiler for these targets. The user may not have LLVM installed or have a version that we do not support.

The proposal in this issue is to use an environment variable (e.g JUVIX_CLANG_PATH) to set the location of the clang binary that's used by Juvix. If this environment variable is not set then we'd fallback to the current behaviour of using PATH.

The reason for this is to facilitate easy installation of the Juvix and its dependencies as part of #1937 (Add one-liner installation command).

The installer command would give the user the option to install a version of LLVM / clang that's compatible with Juvix into $XDG_DATA_HOME/clang (specifically https://github.com/rsms/llvmbox for the target machine) and then set JUVIX_CLANG_PATH to this installation as part of the Juvix shell setup.

@lukaszcz lukaszcz added this to the 0.4 - Prague milestone May 26, 2023
lukaszcz pushed a commit that referenced this issue Jun 1, 2023
…clang executable (#2152)

If set, `JUVIX_LLVM_DIST_PATH` should point to the root of a LLVM
installation, i.e clang should be present
in`$JUVIX_LLVM_DIST_PATH`/bin/clang.

If `JUVIX_LLVM_DIST_PATH` is not set, or `clang` is not available there
then the system PATH is used instead, (this is the current behaviour).

The `juvix doctor` clang checks use the same logic as `juvix compile` to
find and check the `clang` executable.

To help with debugging the clang location, this PR also adds `juvix
doctor --verbose` which prints the location of the `clang` executable
and whether it was found using the system PATH or the
JUVIX_LLVM_DIST_PATH environment variable:

```
juvix doctor --verbose
> Checking for clang...
  | Found clang at "/Users/paul/.local/share/juvix/llvmbox/bin/clang" using JUVIX_LLVM_DIST_PATH environment variable
```

or

```
juvix doctor --verbose
> Checking for clang...
  | Found clang at "/Users/paul/.local/bin/clang" using system PATH
```

* Closes #2133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants