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

--genScript doesn't include nimbase.h file #803

Closed
dmac opened this issue Jan 8, 2014 · 2 comments
Closed

--genScript doesn't include nimbase.h file #803

dmac opened this issue Jan 8, 2014 · 2 comments
Labels

Comments

@dmac
Copy link

dmac commented Jan 8, 2014

Generating a compilation script with --genScript doesn't work out-of-the-box because the generated compilation commands don't include a path to the nimrod/lib directory.

$ cat compile_hello.sh
clang -c  -w  -o nimrod_hello.o nimrod_hello.c
clang -c  -w  -o nimrod-repo_system.o nimrod-repo_system.c
clang   -o hello  nimrod-repo_system.o nimrod_hello.o -ldl
$ sh compile_hello.sh
nimrod_hello.c:5:10: fatal error: 'nimbase.h' file not found
#include "nimbase.h"
         ^
1 error generated.
nimrod-repo_system.c:5:10: fatal error: 'nimbase.h' file not found
#include "nimbase.h"
         ^

If I'm correct in assuming that --genScript is intended to generate self-contained compileable C source, should it perhaps bundle the required header files into nimcache? Being new to nimrod, I'm not sure if nimbase.h is the only dependency or if there could potentially be others from nimrod/lib.

@reactormonk
Copy link
Contributor

IIRC the nimbase.h is hardcoded, so hardcoding the bundle of that file would be an idea.

@Araq Araq added pragmas and removed pragmas labels Jul 1, 2014
Araq pushed a commit that referenced this issue Apr 25, 2018
* Fixes #802, #803 and #3775 - genscript issues

* Test case for genscript

* Test script

* Verify on Linux

* Update categories.nim

* Fix merge

* Improve test framework

* Windows fixes
@johanobergman
Copy link

I wanted to compile some Nim code on my Raspberry Pi Zero today, and ran nim c --cpu:arm --os:linux --compileOnly --genScript src/app.nim, but the /Users/johanbergman/.cache/nim/app_d/ directory didn't contain nimbase.h, so I got an error when trying to run the compile script on my Pi.

The copying of nimbase.h was added here:

proc generateScript(projectFile: string, script: Rope) =

but is no longer present here:
https://github.com/nim-lang/Nim/blob/devel/compiler/extccomp.nim#L412

I copied the file manually and was then able to compile on the Pi using the script in the cache dir.

Two takeaways:

  • Is it possible to copy over nimbase.h automatically? It was quite a headache to figure out everything as a Nim newbie.
  • It was really difficult to find out where the source files and build script are located (the cache dir). The documentation on cross compilation https://nim-lang.org/docs/nimc.html#crossminuscompilation doesn't mention it, neither does the compile command output. The .deps-file was the only file created in my current directory, so I assumed something had gone wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants