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

Trouble building and testing on Mac OS 14 #127

Open
dctucker opened this issue Oct 22, 2024 · 1 comment
Open

Trouble building and testing on Mac OS 14 #127

dctucker opened this issue Oct 22, 2024 · 1 comment

Comments

@dctucker
Copy link

dctucker commented Oct 22, 2024

Nim v1.6.20

I'm unable to use futhark with Nim v1.6.x:

/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(245, 28) Error: expression 'kind["value"].str' is of type 'string' and has to be used (or discarded)

I have a workaround for this using Nim v2.x to run futhark for generating wrapper code, but I have a preference for 1.6.x since another library I'm using (uing) behaves more predictably at runtime when compiled with older Nim. It'd be nice if I could avoid running choosenim for this step.

Nim v2.x

Using Nim v2.2.0 yields better results, but unless I explicitly specify sysPath, it fails to find stdio.h:

$ nimble futhark
  Verifying dependencies for [email protected]
  Executing task futhark in /Users/dctucker/Development/nimvlc/nimvlc.nimble
Hint: used config file '/Users/dctucker/.choosenim/toolchains/nim-2.2.0/config/nim.cfg' [Conf]
Hint: used config file '/Users/dctucker/.choosenim/toolchains/nim-2.2.0/config/config.nims' [Conf]
...............................................................................................................................................
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(829, 7) Hint: Running: opir -I/usr/include -I/Applications/VLC.app/Contents/MacOS/include /Users/dctucker/.cache/nim/gen_d/futhark-includes.h [User]
stack trace: (most recent call last)
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(838, 9) importcImpl
/Users/dctucker/Development/nimvlc/src/gen.nim(15, 5) template/generic instantiation of `importc` from here
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(708, 14) template/generic instantiation of `importcImpl` from here
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(838, 9) Error: Opir exited with non-zero exit code 255.
Opir output:
Fatal: 'stdio.h' file not found /Applications/VLC.app/Contents/MacOS/include/vlc/libvlc.h:56:10 2077
Tried to parse: /Users/dctucker/.cache/nim/gen_d/futhark-includes.h
With arguments: -I/usr/include -I/Applications/VLC.app/Contents/MacOS/include
Unable to parse translation unit succesfully. Quitting
stack trace: (most recent call last)
/private/var/folders/1j/7j51cr512hj69tzdsj6153340000gn/T/nimblecache-3013547234098513788/nimscriptapi_2432715556752558808.nim(212, 16)
/Users/dctucker/Development/nimvlc/nimvlc.nimble(26, 5) futharkTask
/Users/dctucker/.choosenim/toolchains/nim-2.2.0/lib/system/nimscript.nim(264, 7) exec
/Users/dctucker/.choosenim/toolchains/nim-2.2.0/lib/system/nimscript.nim(264, 7) Error: unhandled exception: FAILED: nim c -c -d:useFuthark -d:futharkRebuild -d:nodeclguards src/gen.nim [OSError]
       Tip: 1 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(161) execScript

    Error:  Exception raised during nimble script execution

Again, there's a workaround for this, but this does seem like unexpected behavior to me, and maybe it's possible for futhark to auto-detect a proper sysPath within a when(macosx) block.

Test

When I build on Linux things more-or-less work without additional effort. On Mac, I'm unable to run a test binary despite adding the following to the top of my library:

{.passL: "-L/Applications/VLC.app/Contents/MacOS/lib".}
{.passL: "-rpath /Applications/VLC.app/Contents/MacOS/lib".}

SIGSEGV

(redacted)
This one gets resolved at runtime by adding VLC_PLUGIN_PATH to the environment. No more SIGSEGV, just a known libvlc on Mac quirk.

Sorry for opening such a long-bodied issue, I just figured having this all in one place would be more useful than opening several related issues.

@dctucker
Copy link
Author

Another related issue with building on Mac that I neglected to mention in the initial description is relative paths are ineffective when supplied to the path directive. If I supply a full system path it works normally, but when supplying a path relative to my source tree (as I am able to do on Linux) it indicates file not found:

$ nimble futhark
  Verifying dependencies for [email protected]
  Executing task futhark in /Users/dctucker/Development/nimvlc/nimvlc.nimble
Hint: used config file '/Users/dctucker/.choosenim/toolchains/nim-2.2.0/config/nim.cfg' [Conf]
Hint: used config file '/Users/dctucker/.choosenim/toolchains/nim-2.2.0/config/config.nims' [Conf]
...............................................................................................................................................
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(829, 7) Hint: Running: opir -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include /Users/dctucker/.cache/nim/gen_d/futhark-includes.h [User]
stack trace: (most recent call last)
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(838, 9) importcImpl
/Users/dctucker/Development/nimvlc/src/gen.nim(19, 5) template/generic instantiation of `importc` from here
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(708, 14) template/generic instantiation of `importcImpl` from here
/Users/dctucker/.nimble/pkgs/futhark-0.13.6/futhark.nim(838, 9) Error: Opir exited with non-zero exit code 255.
Opir output:
Fatal: 'vlc/libvlc.h' file not found /Users/dctucker/.cache/nim/gen_d/futhark-includes.h:1:10 9
Tried to parse: /Users/dctucker/.cache/nim/gen_d/futhark-includes.h
With arguments: -I/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include
Unable to parse translation unit succesfully. Quitting
stack trace: (most recent call last)
/private/var/folders/1j/7j51cr512hj69tzdsj6153340000gn/T/nimblecache-3013547234098513788/nimscriptapi_2432715556752558808.nim(212, 16)
/Users/dctucker/Development/nimvlc/nimvlc.nimble(26, 5) futharkTask
/Users/dctucker/.choosenim/toolchains/nim-2.2.0/lib/system/nimscript.nim(264, 7) exec
/Users/dctucker/.choosenim/toolchains/nim-2.2.0/lib/system/nimscript.nim(264, 7) Error: unhandled exception: FAILED: nim c -c -d:useFuthark -d:futharkRebuild -d:nodeclguards src/gen.nim [OSError]
       Tip: 1 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(161) execScript

    Error:  Exception raised during nimble script execution

Looking in the folder it mentions (~/.cache/nim/gen_d) I can see the futhark.includes.h attempts to include all of the header files from the importc directive as expected, but since either the include path is ignored AND the header files are absent from the gen_d directory, the above error is shown.

I think this is fixable but I'm low on implementation details at the moment and can't yet propose a fix. My current workaround is specifying the absolute path to my source tree.

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

1 participant