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

nekotools boot result not standalone, requires ndll #226

Closed
Jan69 opened this issue Jul 11, 2021 · 2 comments · Fixed by #273
Closed

nekotools boot result not standalone, requires ndll #226

Jan69 opened this issue Jul 11, 2021 · 2 comments · Fixed by #273

Comments

@Jan69
Copy link

Jan69 commented Jul 11, 2021

what's the point of a not-standalone binary if you get the same effect with a 2-line shell script (including the shebang), or similarly short bat file, and a symlink?
IMO it pretty much destroys any point of using nekotools boot since you still require all of the used .ndll files anyway, so why not just use neko binary itself at that point (maybe with a wrapper script if you want a fancy-named program)
to make extra sure, I built neko from source with STATIC_DEPS=all disabling all the configurable features (JIT + WITH_* stuff) leaving it relocatable, thinking that maybe it helps even a tiny bit...

nekotools --help says that boot <file.n> : build an standalone executable, so lets see how true that is...

$ ./nekotools boot test.n
$ cp test /tmp
$ /tmp/test
/tmp/test: error while loading shared libraries: libneko.so.2: cannot open shared object file: No such file or directory

ok understandable, it must be keeping everything in that one library right...

$ cp libneko.so.2 /tmp/
$ /tmp/test
The virtual machine is working !
Calling a function inside std library...
Test successful

so it works? not really, it works only because I was in the directory with the .ndll files...

$ cd /tmp
$ ./test
Uncaught exception - load.c(237) : Failed to load library : std.ndll (std.ndll: cannot open shared object file: No such file or directory)

this is even on the same system, without needing to test it in a chroot or an actually different system, or anything...

of course that's not even touching on the fact that it's dynamically linked to system-specific libraries, which is an unrelated problem for standalone programs, although it's completely normal for stuff installed and used on one system... and there's no option to compile it statically, or even attempt to do that, without manually editing the makefiles or stuff like that...

I love neko, or at least I love what it could be, which is why I've been sad about this since I first found it... I am not skilled enough to fix it myself... unless the solution is removing it altogether...

@tobil4sk
Copy link
Member

The problem here was that nekotools boot is not a good/safe way of generating an executable, see #130. With nekotools boot -c, the c source file can be compiled manually using a c compiler, and an -rpath value can be added so that the executable is able to load the ndlls and libneko from the correct location.

@tobil4sk
Copy link
Member

I think I misunderstood the original issue, so just to clarify:

It turns out nekotools boot actually does create an executable with a correctly set RUNPATH value. Once neko/nekotools is installed on the system, the nekotools generated executable can load the libneko/ndll from the system library path [0] or from the same directory that the executable is in (i.e. $ORIGIN, assuming -DRELOCATABLE=ON). This is the reason for the libneko.so.2 and std.ndll loading errors, as std.ndll was in neither location.

This means that when distributing the app, libneko.so and the ndlls must be packaged alongside with the app (in the same directory). Dynamic linking and loading is how neko programs have always used ndlls, so static linking is not really an option.

For more control over the runpath, nekotools boot -c should be used instead which allows manually compiling a c file, as mentioned above.

[0] - Non-/usr install prefixes don't work by default until #271 is merged.

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

Successfully merging a pull request may close this issue.

2 participants