termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.22k stars 3.04k forks source link

Cross compiling termux package on Ubuntu: mv: cannot move '/home/harieamjari/.termux-build/_cache/android-r21d-api-24-v4-tmp' to '/home/harieamjari/.termux-build/_cache/android-r21d-api-24-v4': Permission denied #6831

Closed harieamjari closed 3 years ago

harieamjari commented 3 years ago

When I tried cross-compiling libllvm for arm, it seems that I get an error for permission:

harieamjari@LAPTOP-T5O9O8R1:~/termux-packages$ ./build-package.sh -a arm -I libllvm
Downloading https://grimler.se/termux-packages-24/dists/stable/Release
...

-- Generating done
-- Build files have been written to: /home/harieamjari/.termux-build/libllvm/host-build
[240/240] Linking CXX executable bin/lldb-tblgen
mv: cannot move '/home/harieamjari/.termux-build/_cache/android-r21d-api-24-v4-tmp' to '/home/harieamjari/.termux-build/_cache/android-r21d-api-24-v4': Permission denied

But if I to move it myself manually, I don't get an permission denied error

Even though, is there some fault in the script, where it must be run as sudo?

I'm sure that I followed this two links before cross-compiling:

P.S I'm running at a WSL

harieamjari commented 3 years ago

I have tried to run the command a second time and it seems that, it will be compiling 6000+ objects instead of 240 objects:

harieamjari@LAPTOP-T5O9O8R1:~/termux-packages$ ./build-package.sh -a arm -I libllvm
...
-- Build files have been written to: /home/harieamjari/.termux-build/libllvm/build
[141/6496] Building CXX object utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeEmitterGen.cpp.o      
Grimler91 commented 3 years ago

Should be no need to run as sudo to mv a folder in your home directory. Maybe some weird WSL behaviour.

What ubuntu version is it? Is the android-ndk installed to ~/lib/ (as per the setup-android-sdk.sh script)? What permissions does the folders have? (ls -l ~/.termux-build/_cache/)

Grimler91 commented 3 years ago

I have tried to run the command a second time and it seems that, it will compiling 6000+ objects instead of 240:

Seems it is working when you ran it again then. Note that WSL is not really supported, if you get more issues then it would probably be better to build in the docker image

harieamjari commented 3 years ago
harieamjari@LAPTOP-T5O9O8R1:~$ ls -l ~/.termux-build/_cache/
total 144
drwxr-xr-x 1 harieamjari harieamjari  4096 May 19 15:39 android-r21d-api-24-v4
drwxrwxrwx 1 harieamjari harieamjari  4096 May 19 15:25 cmake-3.20.2
-rw------- 1 harieamjari harieamjari 11969 May 19 15:46 grimler.se-game-packages-24-games-Release
-rw------- 1 harieamjari harieamjari   455 May 19 15:46 grimler.se-game-packages-24-games-Release.gpg
-rw------- 1 harieamjari harieamjari 12755 May 19 15:46 grimler.se-science-packages-24-science-Release
-rw------- 1 harieamjari harieamjari   455 May 19 15:46 grimler.se-science-packages-24-science-Release.gpg
-rw------- 1 harieamjari harieamjari 12548 May 19 15:46 grimler.se-termux-packages-24-stable-Release
-rw------- 1 harieamjari harieamjari   455 May 19 15:46 grimler.se-termux-packages-24-stable-Release.gpg
-rw------- 1 harieamjari harieamjari 12752 May 19 15:46 grimler.se-termux-root-packages-24-root-Release
-rw------- 1 harieamjari harieamjari   455 May 19 15:46 grimler.se-termux-root-packages-24-root-Release.gpg
-rw------- 1 harieamjari harieamjari 12559 May 19 15:46 grimler.se-unstable-packages-unstable-Release
-rw------- 1 harieamjari harieamjari   455 May 19 15:46 grimler.se-unstable-packages-unstable-Release.gpg
-rw------- 1 harieamjari harieamjari 12530 May 19 15:46 grimler.se-x11-packages-x11-Release
-rw------- 1 harieamjari harieamjari   455 May 19 15:46 grimler.se-x11-packages-x11-Release.gpg
drwxrwxrwx 1 harieamjari harieamjari  4096 May 19 15:25 ninja-1.10.2
-rwxrwxrwx 1 harieamjari harieamjari 17488 May 19 13:22 termux-elf-cleaner
-rw------- 1 harieamjari harieamjari  7093 May 19 13:22 termux-elf-cleaner.cpp

WSL version 1

harieamjari commented 3 years ago

And yes, the android-ndk is installed:

harieamjari@LAPTOP-T5O9O8R1:~$ ls ~/lib
android-ndk  android-sdk

I'll close this issue if the compilation is successful this next many hours and comment a solution (if the behaviour is defined, replicatable and I was able to find the cause), otherwise I'll ask again.

This next paragraph, is a report on issues I have many encountered when setting up the building environment on my system. Future installers are suggested to take note.

finagolfin commented 3 years ago

The first mv error is probably a WSL issue. As for compiling 6k+ objects, that's correct: the LLVM build first natively builds some utilities it needs on the host, the 240 objects, then cross-compiles all of LLVM for arm, the 6k+ objects.

ghost commented 3 years ago

WSL version 1

You could try using WSL version 2 (if your hardware supports virtualization) as it has full linux system calls compatibility and runs under Lightweight Hyper-V Engine,

i use it and works fine with no issues, though lack of systemd init shouldn't be an issue for that

It should atleast compile Termux packages without issues than WSL1

harieamjari commented 3 years ago

OK!! stuff is ready and cooked!:

Changes to the AArch64 Backend
--------------------------
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:146: WARNING: Unexpected indentation.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:147: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:153: WARNING: Unexpected indentation.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:154: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:158: WARNING: Unexpected indentation.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:159: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:167: WARNING: Unexpected indentation.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:168: WARNING: Block quote ends without a blank line; unexpected unindent.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:190: WARNING: Unexpected indentation.
/home/harieamjari/.termux-build/libllvm/src/llvm/docs/ReleaseNotes.rst:191: WARNING: Block quote ends without a blank line; unexpected unindent.

termux - build of 'libllvm' done

And I got the debs on debs dir.

harieamjari@LAPTOP-T5O9O8R1:~/termux-packages/debs$ ls -la && du -h
total 100800
drwxrwxrwx 1 harieamjari harieamjari     4096 May 20 08:27 .
drwxrwxrwx 1 harieamjari harieamjari     4096 May 19 15:59 ..
-rw-rw-rw- 1 harieamjari harieamjari 19931672 May 20 08:22 clang_12.0.0_arm.deb
-rw-rw-rw- 1 harieamjari harieamjari  1400102 May 20 08:22 libcompiler-rt_12.0.0_arm.deb
-rw-rw-rw- 1 harieamjari harieamjari 45751456 May 20 08:26 libllvm-static_12.0.0_arm.deb
-rw-rw-rw- 1 harieamjari harieamjari 20393268 May 20 08:27 libllvm_12.0.0_arm.deb
-rw-rw-rw- 1 harieamjari harieamjari  1181874 May 20 08:22 libpolly_12.0.0_arm.deb
-rw-rw-rw- 1 harieamjari harieamjari  2337742 May 20 08:23 lld_12.0.0_arm.deb
-rw-rw-rw- 1 harieamjari harieamjari  4011262 May 20 08:23 lldb_12.0.0_arm.deb
-rw-rw-rw- 1 harieamjari harieamjari  7863872 May 20 08:23 llvm_12.0.0_arm.deb
99M     .
harieamjari@LAPTOP-T5O9O8R1:~/termux-packages/debs$ file /data/data/com.termux/files/usr/bin/clang-12
/data/data/com.termux/files/usr/bin/clang-12: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /system/bin/linker, not stripped

Though I can just go and install these debs, I'm not sure if this will even work (my phone is also near running out of storage). I'll try first copying the /data/data/com.termux/files/usr/bin/clang-12 from this ubuntu to my android to see what (linker) errors would come up (and to make sure that this ELF is not corrupted), then, I would move next to backing up termux and installing the debs.

Wish me luck,

harieamjari commented 3 years ago

@Grimler91 Where can I override the value of TERMUX_PKG_API_LEVEL to 23? Should I just export it? like: export TERMUX_PKG_API_LEVEL=23?

Edit: I found it https://github.com/termux/termux-packages/wiki/Creating-new-package.

ghost commented 3 years ago

master branch of termux-packages doesn't support TERMUX_PKG_API_LEVEL below 24 - we have dropped compatibility patches with this API level once switched to Android 7.

harieamjari commented 3 years ago

@xeffyr Compiling it with TERMUX_PKG_API_LEVEL=24 yields success, but when running it on android yields a runtime linker error about __aeabi_mem*.

Compiling this again now with TERMUX_PKG_API_LEVEL=23 yields several linker errors getting spit about __aeabi__mem* being undefined. Well, I better just stick with clang-9 as this gets complicated at every turn. This mrm

Though, (if I got time), I might try looking up the source code for those __aeabi_mem* and compile it with libllvm to see what new errors I then would get.

Edit, it seemed that I found light Screenshot_20210520-212236