nqcc
nqcc copied to clipboard
Need docs to get started
I installed the compiler and ran make to see this error.
ocaml setup.ml -configure
Cannot find file topfind.
Unknown directive `require'.
make: *** [Makefile:34: setup.data] Error 2
Could you please add some docs to get started?
Thanks for bringing this up! I've added installation and usage instructions to the readme - let me know if you still have any trouble running it.
Great! I went one step ahead and compiled the compiler, but it failed for the examples.
$ ./nqcc ./examples/if/ex1.c
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1/../../../libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/bin/ld: skipping incompatible /usr/lib/libgcc_s.so.1 when searching for libgcc_s.so.1
/usr/bin/ld: cannot find libgcc_s.so.1
collect2: error: ld returned 1 exit status
I'll take a look at this now.
@nlsandler Is there any specific reason for you to target 32b architecture?
I went down this same path recently and worked on the scheme version of this project and the source is available here https://github.com/jaseemabid/inc. One of the insights was that you normally don't need 32b libraries for anything else on your machine and its easier to get going with 64b without cross compilation and things like that.
If you have to use 32b, I've added a Dockerfile based off debian to make this easier with the gcc-multilib package. Removing the chez scheme bits and replacing that with ocaml should give you what you want. https://github.com/namin/inc/blob/master/Dockerfile
Basically, I targeted 32b because An Incremental Approach to Compiler Construction did. In retrospect, that wasn't a very good reason, but I probably won't have the chance to change it in the near future. Compiling for 32b didn't actually require any extra setup on OS X, and I wasn't aware that it did on Debian. Thanks for letting me know and for sharing your Dockerfile!
I can understand, I started with 32 and moved to 64. Once you get comfortable with asm, the difference isn't that much for a small compiler. You might have to fix a bunch of hard coded size values here and there and change register names. That's all.
Since you mentioned osx, that leads to the next question. Are you going to target just osx or will you consider linux as well?
The sticking point for updating to 64-bit is actually that this is kind-of sort-of a reference implementation for a series of blog posts I'm writing, and I think switching to 64-bit mid-series would be kind of disruptive and confusing, even though the code changes are small.
Anyway, I'd be interested in supporting Linux as well, though I've only tested it on OS X. Have you run into any issues on Linux, other than getting 32-bit gcc running?