Seeing that you use Termux, I have a question to ask you.
When I use termux, keystrokes are not entered directly into the terminal. I have to choose one from the selected options before it gets typed into the terminal.
Have you experiended this problem?
keystrokes are not entered directly into the terminal
Provided you're using a hardware keyboard, install Null Keyboard and the issue will never bother you again anywhere.
I was able to get Nim working in Termux after some trial and error. Stisa's article helped with some of it, but I think I had to implant some additional code. I also had to patch getTempDir to get nimble/etc working on an unrooted device.
I wouldn't recommend doing Nim compiling directly on a mobile device though. Nim is a particularly smart compiler that does a lot of work to go from a superb syntax to a great fast executable, which is awesome on all fronts but one: it means noticeable compile times on low-power devices. Developers should use real computers with fast multicore CPUs, or at least a fast on-demand CaaS (compiler as a service) in the cloud. One can make a script to cross-compile on a fast device and deploy to the mobile device for testing.
Just removed termux and reinstalled from scratch ( I can only test on my phone, android 7 ), here are my steps:
apt install git
apt install clang
git clone https://github.com/nim-lang/Nim
cd Nim && git clone https://github.com/nim-lang/csources
apt install libandroid-glob && apt install libandroid-glob-dev
In csources/build.sh`` line 32: ``LINK_FLAGS="-landroid-glob ${LDFLAGS:-} "
In whatever c#_# ( mine was c2_2 ) folder it's building, stdlib_osproc.c "bin/sh" -> "sh" (line 400)
now in csources, sh ./build.sh should work.
We have nim!
In config/nim.cfg add passL=" -landroid-glob " and define:termux
In lib/posix/posix.nim : line 283: when defined(macosx) or defined(termux): and on line 1623: when not defined(macosx) and not defined(termux) ( you just need to add the termux part )
In lib/pure/osproc.nim "bin/sh" -> "sh" (line 744 in nim)
Now ./bin/nim c Koch should work
./koch boot
./koch tools
Hope this helps. ( I'll update my post if this works for you too )
Ok, so here's the automated version of the 32-bit termux Nim bootstrap part (also fixing the 64-bit kernel/32-bit userspace scenario), that reproduces the OP's error during the final link:
apt install clang
apt install git
apt install libandroid-glob && apt install libandroid-glob-dev
git clone --depth 1 https://github.com/nim-lang/Nim
cd Nim && git clone --depth 1 https://github.com/nim-lang/csources && cd csources
sed -i 's/LINK_FLAGS="${LDFLAGS:-} "/LINK_FLAGS="-landroid-glob ${LDFLAGS:-} "/;s/`uname -m`/armv7/' build.sh
sed -i 's/bin\/sh/sh/;s/sigtimedwait/__rt_sigtimedwait/' c_code/2_1/stdlib_osproc.c
sh build.sh
cd .. && ./bin/nim -v
edit: Fixed the script, nim can be bootstrapped fine.
In config/nim.cfg add passL=" -landroid-glob " and define:termux
In lib/posix/posix.nim : line 283: when defined(macosx) or defined(termux): and on line 1623: when not defined(macosx) and not defined(termux) ( you just need to add the termux part )
In lib/pure/osproc.nim "bin/sh" -> "sh" (line 744 in nim)
Can we get a PR out of this? :-)
@NastyRigger it compiles fine now but when trying to compile koch.nim you get the same error
/data/data/com.termux/files/home/Nim/nimcache/stdlib_osproc.o: In function `nospwaitForExit':
/data/data/com.termux/files/home/Nim/nimcache/stdlib_osproc.c:(.text+0x45f8): undefined reference to `sigtimedwait'
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
@NastyRigger: that's what -d:android does: https://github.com/nim-lang/Nim/blob/c480505797f9d82b9b19a72b5a5abde9c0cb0fd4/lib/posix/posix.nim#L2426
@cheatfate : thanks for the pointer, I'll have a look, I think it's a bit outside of what I can understand though
@cheatfate Well done! 32-bit works as expected:
https://s29.postimg.org/fdbzy8xav/Screenshot_2017-04-02-14-14-23.png
edit: For the lazy, I've uploaded a proof of concept termux arm build: https://mega.nz/#!oyIxVITJ!Z9BD8QQ3proNwLnOmnRmPjtdcB-N_5zxoGpB2_AckC8