rmpkg(main/binutils-is-llvm): make LLVM binutils default in Termux#28586
rmpkg(main/binutils-is-llvm): make LLVM binutils default in Termux#28586robertkirkman merged 1 commit intotermux:masterfrom
Conversation
|
It will not be possible to recompile |
|
@licy183 @truboxl @twaik TL;DR this is my idea to fix a problem introduced by without reverting the can you think of any major problems that doing this would cause? I have shown above an example of a problem that this would cause with https://github.com/paullouisageneau/libjuice.git , but it seems minor. |
3d2d815 to
08f196e
Compare
|
Regarding GCC in TUR, if it doesn't work with LLVM binutils, I suggest we make a separate build of GNU binutils just for it (or |
|
I think this is a good move. Bump the libllvm/flang revision also. |
68cb4e7 to
d918fe1
Compare
I'll see if I can build all the packages except |
d918fe1 to
607a72a
Compare
|
It is somewhat necessary to move but this seems to be something appropriate because,
truboxl on September 27 2023: "I am proposing to move LDC to disabled" |
|
One reason that It's unclear exactly how to reproduce that, but I suspect it was probably that a command named exactly |
|
@strobecat @kinke @joakim-noah do you happen to know how |
607a72a to
79feda9
Compare
|
IIRC some assembly files cannot be compiled correctly under clang. I wonder if this situation has improved now. |
If you have an idea of what to check, you can check the behavior of |
TomJo2000
left a comment
There was a problem hiding this comment.
I think LLVM as default is definitely something we can look into.
I am however unsure if this is the best approach we can take in the short term.
My main concern is user flexibility here.
I agree that we should probably use LLVM binutils for building packages for improved consistency with our closest (loosely) related projects (e.g. AOSP, Chimera, FreeBSD).
My main concern is, what - if any, impact is switching to LLVM binutils for package builds/dependents gonna have on users?
This seems like a non-trivial question to answer and should be given plenty of testing.
As a low stakes interim option we could split out a binutils-libs subpackage from the newly unified GNU binutils package again.
That should allow us to resolve the incompatibility between lua-language-server, g-ir-scanner, ldd and binutils-is-llvm while we do a thorough evaluation of making the switch to LLVM binutils as default.
This does sacrifice some user flexibility for increased consistency of behavior between building software on-device with and without
LLVM binutils is already used for package builds. This PR will apply LLVM binutils globally to all on-device builds regardless of whether If you mean replacing |
b5507cf to
d036e9f
Compare
Upstream, we have official cross-compiled Android binaries on GitHub, using the ~latest LTS NDK (r27c currently IIRC). (So Android builds should in principle be fine.) There was a bigger change in LDC v1.38 - we now rely on native ELF TLS on Android. This requires API level 29 for armv7a, and level 30 for aarch64. This allowed us to drop the former custom TLS emulation scheme for Android in our custom LLVM, and enabled the usage of lld as linker (not requiring ld.bfd anymore). What this means for Termux is that if the level 29/30 requirement is okay, the LDC build should become much simpler by upgrading to the latest version, not needing the custom LLVM anymore and probably just fine using the regular LLVM package (edit: the latest beta supports LLVM 15-21). If the Termux build environment is similar to the NDK (and IIUC gets closer to the NDK with this PR) nowadays, this might become a straight-forward CMake build. |
I can still reproduce this problem with https://github.com/ldc-developers/ldc/releases/download/v1.41.0/ldc2-1.41.0-android-aarch64.tar.xz , on 64-bit ARM Android 13 which is API level 33, curl -O -L https://github.com/ldc-developers/ldc/releases/download/v1.41.0/ldc2-1.41.0-android-aarch64.tar.xz
tar xvf ldc2-1.41.0-android-aarch64.tar.xz
cd ldc2-1.41.0-android-aarch64/bin
./ldc2I understand that you might be aware of this problem already, but this is one of the things preventing us from upgrading to a newer version of LDC. Is this something you can reproduce, or does that build work properly on your device? |
I've never run it on my phone. ;) - Oh, good to know this issue is still a problem (as it's been reported once only, and way before the bigger TLS change). I hope it's 'just' a build problem, e.g., caused by the D parts compiled with latest LLVM from LDC cross-compiler, and the NDK's clang being older. No stack trace available, in case it'd be a genuine bug? |
Here's a little more information I collected:
|
Thx! Hmm, this Edit: Maybe worth a try: ldc-developers/ldc#5070. Unfortunately, the CI builds are currently blocked by apt.llvm.org problems. |
Yes, the current used version of ldc isn't compatible with llvm binutils iirc🤔 I remember trying using the linker from llvm binutils to compile tilix sometimes ago. It crashed with something alike "xxx not balanced" and instructed me to use the linker from gnu binutils |
7b78000 to
926b462
Compare
|
We tried for a while to get a newer version of LDC to work, but unfortunately we couldn't really get it to work in a stable way. However, at least I have eventually been able to recompile the current version of LDC available for Termux, and that version is still working, so I guess for now it will need to stay at that version. @strobecat I tested building |
926b462 to
9e728f2
Compare
|
On close inspection of the BSD-family systems, I have noticed that their binutils situations are more complicated than I originally thought. they do pick defaults and stick to them, but they pick them individually on a per-program basis, and currently have mixtures of programs from several different original sources, including LLVM binutils. This PR should, I think, continue with moving Termux to default to LLVM binutils for everything that conflicts with GNU binutils except for |
|
9e728f2 to
dcbf270
Compare
|
I will merge it in 24 hours from now if there are not any objections. Practically speaking, the behavior will be mostly similar to the current behavior of Termux when |
5df2a6d to
94b30ac
Compare
- My idea of a different solution to: - termux#8191 - termux#9715 - termux#16588 - Reverts: - termux#10012 - termux#13045 - Make Termux behave more similarly to the LLVM-based desktop Linux distro, Chimera Linux - Preserve `as` name for GNU `as`, since `llvm-as` is not compatible with software expecting GNU `as`, and Chimera Linux also gives that name to GNU `as`: termux#11218 - Source code and runtime behavior of Chimera Linux observed to design this PR https://chimera-linux.org/ | Binutil | GNU/Linux | Chimera Linux | FreeBSD | MacOS | Vanilla Android | Termux Current | Termux This PR | |:----------- |:------------- |:------------- |:------------ |:--------------- |:----------------- |:-------------- |:-------------- | | `as` | GNU | GNU | GNU | `clang -cc1as` | `llvm-` name only | GNU | GNU | | `elfedit` | GNU | GNU | GNU | Not Available | Not Available | GNU | GNU | | `gprof` | GNU | GNU | BSD | Not Available | Not Available | GNU | GNU | | `addr2line` | GNU | LLVM | elftoolchain | Not Available | `llvm-` name only | Variable | LLVM | | `ar` | GNU | LLVM | BSD | BSD | `llvm-` name only | Variable | LLVM | | `c++filt` | GNU | LLVM | LLVM | LLVM | `llvm-` name only | Variable | LLVM | | `ld` | GNU | LLVM | LLVM | Apple | LLVM | Variable | LLVM | | `nm` | GNU | LLVM | elftoolchain | LLVM | `llvm-` name only | Variable | LLVM | | `objcopy` | GNU | LLVM | elftoolchain | Not Available | `llvm-` name only | Variable | LLVM | | `objdump` | GNU | LLVM | LLVM | LLVM | `llvm-` name only | Variable | LLVM | | `ranlib` | GNU | LLVM | BSD | Apple | `llvm-` name only | Variable | LLVM | | `readelf` | GNU | LLVM | elftoolchain | Not Available | `llvm-` name only | Variable | LLVM | | `size` | GNU | LLVM | elftoolchain | Apple | `llvm-` name only | Variable | LLVM | | `strings` | GNU | LLVM | elftoolchain | Apple | `llvm-` name only | Variable | LLVM | | `strip` | GNU | LLVM | elftoolchain | Apple | `llvm-` name only | Variable | LLVM | - This is **not** a project to move Termux away from GNU in general. It is a project to make Termux have a consistent default implementation of a component that is among the group of components for which most distros pick a default and stick to it: | Component | GNU/Linux | Alpine Linux | Chimera Linux | FreeBSD | MacOS | Vanilla Android | Termux Current | Termux This PR | |:----------- |:--------- |:------------ |:------------- |:------- |:----- |:--------------- |:-------------- |:-------------- | | C stdlib | GNU | musl | musl | BSD | BSD | bionic | bionic | bionic | | C++ stdlib | GNU | GNU | LLVM | LLVM | LLVM | LLVM | LLVM | LLVM | | Compiler | GNU | GNU | LLVM | LLVM | LLVM | LLVM | LLVM | LLVM | | Binutils | GNU | GNU | LLVM | LLVM | LLVM | LLVM | **Variable** | LLVM | | Make | GNU | GNU | GNU | BSD | BSD | GNU | GNU | GNU | | Coreutils | GNU | busybox | BSD | BSD | BSD | toybox | GNU | GNU | most LLVM-based distros and operating systems choose the LLVM binutils, so choosing the LLVM binutils for Termux is reasonable and will contribute to the consistency of the wider LLVM-based distro ecosystem. - After termux#28438 , it is now impossible to have `binutils-is-llvm` and `ldd`, `binutils-bin` or `lua-language-server` installed simultaneously. - This disturbance to the prior status quo might inconvenience users of `ldd`, `lua-language-server`, `binutils-bin` or similar packages who are trying to build Termux packages on-device. - This is considered to have occurred due to the difficulty of maintaining multiple packages that provide binutils simultaneously, so the goal is now to reevaluate the default binutils executables provided in Termux, and make changes that solve the problem without reverting termux#28438 while aligning Termux more closely with the current choices used by an LLVM-based desktop Linux distro that also provides a GNU binutils package, Chimera Linux. After this, it will unfortunately be more difficult to compile certain software in Termux. Here is one example that I know of: ```bash git clone https://github.com/paullouisageneau/libjuice.git cd libjuice make ``` It would work before this PR if `binutils` was installed, but after this PR, it will show this error: ``` ar: error: unknown option f ``` (yes, this error also happens when building libjuice in Chimera Linux) Before this PR, it could be worked around by using `pkg install binutils`, but after this PR, it will only be possible to work around by either changing the invocation of `ar` to `gar` or removing the argument `f` from the instance of call to `ar` in `Makefile`. However: - it is already more difficult to compile software in Termux that has problems with Clang but not GCC, or problems with libc++ but not libstdc++, or problems with alternative libc but not glibc, and the additional limitation imposed by defaulting to LLVM binutils is expected to be relatively minimal - libjuice is not an official Termux package, and if it were, it would have already had to be patched to avoid this error anyway, because Termux currently has `ar` set to `llvm-ar` for building in multiple places: https://github.com/termux/termux-packages/blob/eaad7e0549ccf2fc3aa4919dc15b8306ce61dffc/scripts/build/toolchain/termux_setup_toolchain_29.sh#L11 https://github.com/termux/termux-packages/blob/eaad7e0549ccf2fc3aa4919dc15b8306ce61dffc/scripts/setup-termux.sh#L14 - This will make the default behavior of building software in Termux more consistently similar not only to the behavior of the vanilla Android NDK, and not only to behavior of the `termux_setup_toolchain_29()` and `setup-termux.sh` of termux-packages, but also to the behavior of the LLVM-based desktop Linux distro, Chimera Linux. - Any time `clang` is installed, all of the LLVM binutils in the `llvm` package are also already installed, just with `llvm-` prepended to their names, so for most situations, the `binutils` package is implementing duplicate functionality while taking up additional space
94b30ac to
923806a
Compare

My idea of a different solution to:
Reverts:
Make Termux behave more similarly to the LLVM-based desktop Linux distro, Chimera Linux
Preserve
asname for GNUas, sincellvm-asis not compatible with software expecting GNUas, and Chimera Linux also gives that name to GNUas: binutils-is-llvm: remove symlink from llvm-as to as #11218Source code and runtime behavior of Chimera Linux observed to design this PR https://chimera-linux.org/
asclang -cc1asllvm-name onlyelfeditgprofaddr2linellvm-name onlyarllvm-name onlyc++filtllvm-name onlyldnmllvm-name onlyobjcopyllvm-name onlyobjdumpllvm-name onlyranlibllvm-name onlyreadelfllvm-name onlysizellvm-name onlystringsllvm-name onlystripllvm-name onlymost LLVM-based distros and operating systems choose the LLVM binutils, so choosing the LLVM binutils for Termux is reasonable and will contribute to the consistency of the wider LLVM-based distro ecosystem.
Why is this necessary?
binutils-is-llvmandldd,binutils-binorlua-language-serverinstalled simultaneously.ldd,lua-language-server,binutils-binor similar packages who are trying to build Termux packages on-device.binutils-is-llvmwas recommended for installation during on-device builds, which will reduce confusion and make developing packages easier in the event that an incompatibility with LLVM binutils does occur that needs to be fixed.clang, but installedbinutilsrather thanbinutils-is-llvmwithout realizing thatbinutils-is-llvmprobably would work for what they need.Breaking change example
After this, it will unfortunately be more difficult to compile certain software in Termux.
Here is one example that I know of:
git clone https://github.com/paullouisageneau/libjuice.git cd libjuice makeIt would work before this PR if
binutilswas installed, but after this PR, it will show this error:(yes, this error also happens when building libjuice in Chimera Linux)
Before this PR, it could be worked around by using
pkg install binutils,but after this PR, it will only be possible to work around by either changing the invocation of
artogaror removing the argumentffrom the instance of call toarinMakefile.However:
it is already more difficult to compile software in Termux that has problems with Clang but not GCC, or problems with libc++ but not libstdc++, or problems with alternative libc but not glibc, and the additional limitation imposed by defaulting to LLVM binutils is expected to be relatively minimal
libjuice is not an official Termux package, and if it were, it would have already had to be patched to avoid this error anyway, because Termux currently has
arset tollvm-arfor building in multiple places:termux-packages/scripts/build/toolchain/termux_setup_toolchain_29.sh
Line 11 in eaad7e0
termux-packages/scripts/setup-termux.sh
Line 14 in eaad7e0
This will make the default behavior of building software in Termux more consistently similar not only to the behavior of the vanilla Android NDK, and not only to behavior of the
termux_setup_toolchain_29()andsetup-termux.shof termux-packages, but also to the behavior of the LLVM-based desktop Linux distro, Chimera Linux.Any time
clangis installed, all of the LLVM binutils in thellvmpackage are also already installed, just withllvm-prepended to their names, so for most situations, thebinutilspackage is implementing duplicate functionality while taking up additional space