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

2 errors on installing and using futhark #107

Open
theSherwood opened this issue May 31, 2024 · 3 comments
Open

2 errors on installing and using futhark #107

theSherwood opened this issue May 31, 2024 · 3 comments

Comments

@theSherwood
Copy link

Here are a couple errors I'm getting. On my mac, I'm getting an error on installation of futhark. On replit, I'm getting an error trying to use it.

mac

I'm on macOS Monterey 12.6.3

Error message attempting to install futhark:

$ nimble install futhark
Downloading https://github.com/PMunch/futhark using git
   Warning: Package 'futhark' has an incorrect structure. The top level of the package source directory should contain at most one module, named 'futhark.nim', but a file named 'opir.nim' was found. This will be an error in the future.
      Hint: If this is the primary source file in the package, rename it to 'futhark.nim'. If it's a source file required by the main module, or if it is one of several modules exposed by 'futhark', then move it into a 'futhark/' subdirectory. If it's a test file or otherwise not required to build the the package 'futhark.nim', prevent its installation by adding `skipFiles = @["opir.nim"]` to the .nimble file. See https://github.com/nim-lang/nimble#libraries for more info.
  Verifying dependencies for [email protected]
     Info:  Dependency on termstyle@any version already satisfied
  Verifying dependencies for [email protected]
     Info:  Dependency on macroutils@any version already satisfied
  Verifying dependencies for [email protected]
     Info:  Dependency on https://github.com/PMunch/nimbleutils@>= 0.3.0 already satisfied
  Verifying dependencies for [email protected]
 Installing [email protected]
   Building futhark/opir using c backend
/private/var/folders/v9/wl83yxp164b9084hqvrncgv80000gn/T/nimble_13275/githubcom_PMunchfuthark/src/libclang.nim(2, 6) Warning: imported and not used: 'macros' [UnusedImport]
/Users/adam/.cache/nim/opir_r/@m..@s..@s..@s..@s..@s..@s..@s..@s..@sUsers@[email protected]@stoolchains@snim-@hdevel@slib@sstd@[email protected]:8:10: fatal error: 'string.h' file not found
    8 | #include <string.h>
      |          ^~~~~~~~~~
1 error generated.
/Users/adam/.cache/nim/opir_r/@m..@s..@s..@s..@s..@s..@s..@s..@s..@sUsers@[email protected]@stoolchains@snim-@hdevel@slib@[email protected]:8:10: fatal error: 'stdio.h' file not found
    8 | #include <stdio.h>
      |          ^~~~~~~~~
1 error generated.
Error: execution of an external compiler program 'clang -c  -w -ferror-limit=3 -pthread -O3   -I'/Users/adam/.choosenim/toolchains/nim-#devel/lib' -I/private/var/folders/v9/wl83yxp164b9084hqvrncgv80000gn/T/nimble_13275/githubcom_PMunchfuthark/src -o /Users/adam/.cache/nim/opir_r/@m..@s..@s..@s..@s..@s..@s..@s..@s..@sUsers@[email protected]@stoolchains@snim-@hdevel@slib@sstd@[email protected] /Users/adam/.cache/nim/opir_r/@m..@s..@s..@s..@s..@s..@s..@s..@s..@sUsers@[email protected]@stoolchains@snim-@hdevel@slib@sstd@[email protected]' failed with exit code: 1

Clang Version

$ clang --version
Homebrew clang version 17.0.6
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin

Nim Version

$ nim --version
Nim Compiler Version 2.1.1 [MacOSX: amd64]
Compiled at 2024-02-27
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 1e7ca2dc789eafccdb44304f7e42206c3702fc13
active boot switches: -d:release

Nimble Version

$ nimble --version
nimble v0.14.2 compiled at 2024-05-31 20:47:31
git hash: 3575fd54a890d910ace56678aa74b4237d604175

replit

Here's the url: https://replit.com/@theSherwood/EarlyBlueSpreadsheets
It's public, so you should be able to see it if you're so inclined.

Here's the nim file:

import futhark, os

importc:
  outputPath currentSourcePath.parentDir / "tree-sitter-bindings.nim"
  path "tree-sitter/lib/include/tree_sitter/"
  "api.h"

echo "Hello world" # Echo to the console

Here's the error when trying to run the nim file (nim c -r main.nim):

 Hint: used config file '/home/runner/.choosenim/toolchains/nim-2.0.4/config/nim.cfg' [Conf]
Hint: used config file '/home/runner/.choosenim/toolchains/nim-2.0.4/config/config.nims' [Conf]
...............................................................................................................................................
/home/runner/EarlyBlueSpreadsheets/nimble-env/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(810, 7) Hint: Running: opir -I/home/runner/EarlyBlueSpreadsheets/tree-sitter/lib/include/tree_sitter/ -I/nix/store/n37gxbg343hxin3wdryx092mz2dkafy8-clang-wrapper-16.0.6/resource-root/include /home/runner/EarlyBlueSpreadsheets/.cache/nim/main_d/futhark-includes.h [User]
stack trace: (most recent call last)
/home/runner/EarlyBlueSpreadsheets/nimble-env/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(819, 9) importcImpl
/home/runner/EarlyBlueSpreadsheets/main.nim(3, 1) template/generic instantiation of `importc` from here
/home/runner/EarlyBlueSpreadsheets/nimble-env/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(689, 14) template/generic instantiation of `importcImpl` from here
/home/runner/EarlyBlueSpreadsheets/nimble-env/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(819, 9) Error: Opir exited with non-zero exit code 255.
Opir output: 
Fatal: 'stdlib.h' file not found /home/runner/EarlyBlueSpreadsheets/tree-sitter/lib/include/tree_sitter/api.h:14:10 233
Tried to parse: /home/runner/EarlyBlueSpreadsheets/.cache/nim/main_d/futhark-includes.h
With arguments: -I/home/runner/EarlyBlueSpreadsheets/tree-sitter/lib/include/tree_sitter/ -I/nix/store/n37gxbg343hxin3wdryx092mz2dkafy8-clang-wrapper-16.0.6/resource-root/include
Unable to parse translation unit succesfully. Quitting

Nim version

$ nim --version
Nim Compiler Version 2.0.4 [Linux: amd64]
Compiled at 2024-03-28
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: b47747d31844c6bd9af4322efe55e24fefea544c
active boot switches: -d:release

Nimble version

$ nimble --version
      Info: Using the environment variable: NIMBLE_DIR='/home/runner/EarlyBlueSpreadsheets/nimble-env'
nimble v0.14.2 compiled at 2024-03-28 00:58:03
git hash: couldn't determine git hash

Clang version

$ clang --version
clang version 16.0.6
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /nix/store/5ql31bfsgynanf794wnl2wlbs23q7b8h-clang-16.0.6/bin
@PMunch
Copy link
Owner

PMunch commented Jun 6, 2024

The first issue seems to be a problem where building opir (the helper tool for Futhark) on your machine fails because it can't find the C standard library. Are you able to compile other Nim programs?

The second issue seems to be that stdlib.h can't be found, not quite sure why that would happen. Only guess is that you've set up your paths incorrectly somehow. This works for me:

[peter /tmp/treesitter ] $ tree
.
├── tree-sitter
│   └── lib
│       └── include
│           └── tree_sitter
│               └── api.h
└── treesitter.nim

5 directories, 2 files
[peter /tmp/treesitter ] $ cat treesitter.nim
import futhark

importc:
  path "tree-sitter/lib/include/tree_sitter"
  "api.h"
[peter /tmp/treesitter ] $ nim c treesitter.nim
Hint: used config file '/home/peter/.choosenim/toolchains/nim-2.0.4/config/nim.cfg' [Conf]
Hint: used config file '/home/peter/.choosenim/toolchains/nim-2.0.4/config/config.nims' [Conf]
...............................................................................................................................................
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(810, 7) Hint: Running: opir -I/usr/lib/clang/17/include -I/tmp/treesitter/tree-sitter/lib/include/tree_sitter /home/peter/.cache/nim/treesitter_d/futhark-includes.h [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(828, 3) Hint: Parsing Opir output [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(839, 5) Hint: Caching Opir output in /home/peter/.cache/nim/treesitter_d/opir_ED44B79224F7527D.json [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(842, 3) Hint: Generating Futhark output [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(854, 3) Hint: Gathering symbols [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(888, 3) Hint: Find all imported symbols [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(900, 3) Hint: Generate temporary names [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(916, 3) Hint: Add name changes [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(924, 3) Hint: Generate Nim code [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(207, 5) Hint: Renaming "type" to "typefield" in structtsquerypredicatestep [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(207, 5) Hint: Renaming "end" to "endarg" [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(207, 5) Hint: Renaming "end" to "endarg" [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(207, 5) Hint: Renaming "end" to "endarg" [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(207, 5) Hint: Renaming "end" to "endarg" [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(965, 3) Hint: Add setting up imports [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(1014, 3) Hint: Adding extra types [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(1018, 3) Hint: Adding opaque types [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(1030, 3) Hint: Adding decl guards [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(1043, 3) Hint: Adding types [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(1047, 3) Hint: Adding second level of decl guards [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(1060, 3) Hint: Adding generated procs [User]
/home/peter/.nimble/pkgs2/futhark-0.13.1-f8ed16e56f65c86bacdfc3f6b4ae27ae5f9a185d/futhark.nim(1066, 3) Hint: Caching Futhark output in /home/peter/.cache/nim/treesitter_d/futhark_8DB65A1214405120.nim [User]
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/system/exceptions.nim
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/std/private/digitsutils.nim
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/system/dollars.nim
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/system.nim
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/pure/times.nim
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/std/envvars.nim
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/std/cmdline.nim
CC: ../../home/peter/.choosenim/toolchains/nim-2.0.4/lib/system/nimscript.nim
CC: treesitter.nim
Hint:  [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
68242 lines; 1.275s; 167.855MiB peakmem; proj: /tmp/treesitter/treesitter.nim; out: /tmp/treesitter/treesitter [SuccessX]

Using nim 2.0.4, Futhark 0.13.1, and clang 17.0.6. But your setup should work as well.

@theSherwood
Copy link
Author

The first issue seems to be a problem where building opir (the helper tool for Futhark) on your machine fails because it can't find the C standard library. Are you able to compile other Nim programs?

Yes. On my mac I can install other nimble packages and compile and run Nim programs without issue.

The second issue seems to be that stdlib.h can't be found, not quite sure why that would happen. Only guess is that you've set up your paths incorrectly somehow.

I've got a very similar directory tree in my replit codebase:

.
├── tree-sitter
│   └── lib
│       └── include
│           └── tree_sitter
│               └── api.h
└── main.nim

And I can compile and run C source files that include stdlib.h and I can compile and run Nim files that don't use Futhark's importc.

@AmjadHD
Copy link
Contributor

AmjadHD commented Aug 23, 2024

For me it errors when building opir:
nimble install futhark -> ld.exe: cannot find -lclang
nimble install --passL:"-L\"C:\Program Files\LLVM\lib\"" futhark -> gcc.exe: error: Files/LLVM/lib: No such file or directory

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

No branches or pull requests

3 participants