Skip to content

Commit 3d2d815

Browse files
committed
rmpkg(main/binutils-is-llvm): make LLVM binutils default in Termux
- My idea of a different solution to: - #8191 - #9715 - #16588 - Reverts: - #10012 - #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`: #11218 - Source code and runtime behavior of Chimera Linux observed to design this PR https://chimera-linux.org/ | Binutil | Chimera Linux | Vanilla Android | Termux Current | Termux This PR | |:----------- |:------------- |:----------------- |:-------------- |:-------------- | | `addr2line` | LLVM | `llvm-` name only | Variable | LLVM | | `ar` | LLVM | `llvm-` name only | Variable | LLVM | | `as` | GNU | `llvm-` name only | GNU | GNU | | `c++filt` | LLVM | `llvm-` name only | Variable | LLVM | | `elfedit` | LLVM | `llvm-` name only | Variable | LLVM | | `ld` | LLVM | LLVM | Variable | LLVM | | `nm` | LLVM | `llvm-` name only | Variable | LLVM | | `objcopy` | LLVM | `llvm-` name only | Variable | LLVM | | `objdump` | LLVM | `llvm-` name only | Variable | LLVM | | `prof` | LLVM | `llvm-` name only | Variable | LLVM | | `ranlib` | LLVM | `llvm-` name only | Variable | LLVM | | `readelf` | LLVM | `llvm-` name only | Variable | LLVM | | `size` | LLVM | `llvm-` name only | Variable | LLVM | | `strings` | LLVM | `llvm-` name only | Variable | LLVM | | `strip` | LLVM | `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 #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 #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 %ci:no-build
1 parent 0ed8d82 commit 3d2d815

20 files changed

Lines changed: 142 additions & 78 deletions

File tree

File renamed without changes.
File renamed without changes.

packages/atool/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ TERMUX_PKG_SHA256="aaf60095884abb872e25f8e919a8a63d0dabaeca46faeba87d12812d6efc7
1010
TERMUX_PKG_DEPENDS="perl"
1111
TERMUX_PKG_BUILD_IN_SRC=true
1212
TERMUX_PKG_AUTO_UPDATE=true
13-
TERMUX_PKG_RECOMMENDS="arj, binutils-is-llvm | binutils, bzip2, cpio, file, gzip, lhasa, lzip, lzop, p7zip, tar, unrar, unzip, xz-utils, zip"
13+
TERMUX_PKG_RECOMMENDS="arj, llvm, bzip2, cpio, file, gzip, lhasa, lzip, lzop, p7zip, tar, unrar, unzip, xz-utils, zip"
1414
TERMUX_PKG_SUGGESTS="bash-completion"
1515
TERMUX_PKG_PLATFORM_INDEPENDENT=true
1616

packages/binutils/binutils-bin.subpackage.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/binutils/build.sh

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ TERMUX_PKG_MAINTAINER="@termux"
66
# remember to rebuild it when updating `binutils`.
77
TERMUX_PKG_VERSION="2.46.0"
88
TERMUX_PKG_REVISION=2
9-
TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/binutils/binutils-${TERMUX_PKG_VERSION}.tar.xz
9+
TERMUX_PKG_SRCURL="https://mirrors.kernel.org/gnu/binutils/binutils-${TERMUX_PKG_VERSION}.tar.xz"
1010
TERMUX_PKG_SHA256=d75a94f4d73e7a4086f7513e67e439e8fcdcbb726ffe63f4661744e6256b2cf2
11-
TERMUX_PKG_DEPENDS="binutils-bin, zlib, zstd"
12-
TERMUX_PKG_BREAKS="binutils (<< 2.46), binutils-libs, binutils-dev"
13-
TERMUX_PKG_REPLACES="binutils (<< 2.46), binutils-libs, binutils-dev"
11+
TERMUX_PKG_DEPENDS="libc++, zlib, zstd"
12+
TERMUX_PKG_BREAKS="binutils (<< 2.46), binutils-bin, binutils-libs, binutils-dev"
13+
TERMUX_PKG_REPLACES="binutils (<< 2.46), binutils-bin, binutils-libs, binutils-dev"
1414
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
15-
--bindir=$TERMUX_PREFIX/libexec/binutils
1615
--disable-gprofng
1716
--enable-plugins
1817
--disable-werror
@@ -22,6 +21,8 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
2221
TERMUX_PKG_EXTRA_MAKE_ARGS="tooldir=$TERMUX_PREFIX"
2322
TERMUX_PKG_RM_AFTER_INSTALL="share/man/man1/windmc.1 share/man/man1/windres.1"
2423
TERMUX_PKG_NO_STATICSPLIT=true
24+
# will overwrite llvm binutils and llvm ld
25+
TERMUX_PKG_ON_DEVICE_BUILD_NOT_SUPPORTED=true
2526
TERMUX_PKG_GROUPS="base-devel"
2627

2728
# For binutils-cross:
@@ -73,28 +74,27 @@ termux_step_pre_configure() {
7374
}
7475

7576
termux_step_post_make_install() {
76-
local dir="$TERMUX_PREFIX/share/binutils"
77-
mkdir -p "$dir"
78-
touch "$dir/.placeholder"
79-
80-
mkdir -p "$TERMUX_PREFIX/bin"
81-
cd "$TERMUX_PREFIX/libexec/binutils" || termux_error_exit "failed to change into 'libexec/binutils' directory"
82-
83-
mv ld.bfd ld
84-
ln -sf ld ld.bfd
85-
ln -sfr "$TERMUX_PREFIX/libexec/binutils/ld" "$TERMUX_PREFIX/bin/ld.bfd"
86-
87-
local bin
88-
for bin in ./*; do
89-
ln -sfr "$TERMUX_PREFIX/libexec/binutils/$bin" \
90-
"$TERMUX_PREFIX/bin/$bin"
91-
done
92-
93-
# Setup symlinks as these are used when building, so used by
94-
# system setup in e.g. python, perl and libtool:
95-
local -a _TOOLS_WITH_HOST_PREFIX=("ar" "ld" "nm" "objdump" "ranlib" "readelf" "strip")
96-
for bin in "${_TOOLS_WITH_HOST_PREFIX[@]}"; do
97-
ln -sfr "$TERMUX_PREFIX/libexec/binutils/$bin" \
98-
"$TERMUX_PREFIX/bin/$TERMUX_HOST_PLATFORM-$bin"
77+
rm "${TERMUX_PREFIX}/bin/ld"
78+
mv "${TERMUX_PREFIX}/share/man/man1/ld.1" \
79+
"${TERMUX_PREFIX}/share/man/man1/ld.bfd.1"
80+
local -a _BINUTILS_CONFLICTING_WITH_LLVM=(
81+
"ar"
82+
"addr2line"
83+
"c++filt"
84+
"nm"
85+
"objcopy"
86+
"objdump"
87+
"ranlib"
88+
"readelf"
89+
"size"
90+
"strings"
91+
"strip"
92+
)
93+
local binutil
94+
for binutil in "${_BINUTILS_CONFLICTING_WITH_LLVM[@]}"; do
95+
mv "${TERMUX_PREFIX}/bin/${binutil}" \
96+
"${TERMUX_PREFIX}/bin/g${binutil}"
97+
mv "${TERMUX_PREFIX}/share/man/man1/${binutil}.1" \
98+
"${TERMUX_PREFIX}/share/man/man1/g${binutil}.1"
9999
done
100100
}

packages/debootstrap/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ TERMUX_PKG_LICENSE="MIT"
44
TERMUX_PKG_LICENSE_FILE="debian/copyright"
55
TERMUX_PKG_MAINTAINER="@termux"
66
TERMUX_PKG_VERSION="1.0.142"
7-
TERMUX_PKG_SRCURL=https://deb.debian.org/debian/pool/main/d/debootstrap/debootstrap_${TERMUX_PKG_VERSION}.tar.gz
7+
TERMUX_PKG_SRCURL="https://deb.debian.org/debian/pool/main/d/debootstrap/debootstrap_${TERMUX_PKG_VERSION}.tar.gz"
88
TERMUX_PKG_SHA256=334b188c2bab5c1aa6f858a044274631d342f07f5ddec1bad870d728f02fd652
99
TERMUX_PKG_AUTO_UPDATE=true
10-
TERMUX_PKG_DEPENDS="binutils | binutils-is-llvm, perl, proot, sed, wget"
10+
TERMUX_PKG_DEPENDS="llvm, perl, proot, sed, wget"
1111
TERMUX_PKG_BUILD_IN_SRC=true
1212
TERMUX_PKG_PLATFORM_INDEPENDENT=true
1313

packages/flang/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="LLVM's Fortran frontend"
33
TERMUX_PKG_LICENSE="Apache-2.0"
44
TERMUX_PKG_LICENSE_FILE="flang/LICENSE.TXT"
55
TERMUX_PKG_MAINTAINER="@termux"
6-
TERMUX_PKG_VERSION=21.1.8
6+
TERMUX_PKG_VERSION="21.1.8"
77
TERMUX_PKG_SRCURL=(
88
"https://github.com/llvm/llvm-project/releases/download/llvmorg-${TERMUX_PKG_VERSION}/llvm-project-${TERMUX_PKG_VERSION}.src.tar.xz"
99
"https://github.com/llvm/llvm-project/releases/download/llvmorg-${TERMUX_PKG_VERSION}/LLVM-${TERMUX_PKG_VERSION}-Linux-X64.tar.xz"

packages/gauche/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ TERMUX_PKG_LICENSE="BSD 3-Clause"
44
TERMUX_PKG_MAINTAINER="@termux"
55
TERMUX_PKG_VERSION="0.9.15"
66
TERMUX_PKG_REVISION=2
7-
TERMUX_PKG_SRCURL=https://github.com/shirok/Gauche/releases/download/release${TERMUX_PKG_VERSION//./_}/Gauche-${TERMUX_PKG_VERSION}.tgz
7+
TERMUX_PKG_SRCURL="https://github.com/shirok/Gauche/releases/download/release${TERMUX_PKG_VERSION//./_}/Gauche-${TERMUX_PKG_VERSION}.tgz"
88
TERMUX_PKG_SHA256=3643e27bc7c8822cfd6fb2892db185f658e8e364938bc2ccfcedb239e35af783
99
TERMUX_PKG_AUTO_UPDATE=false
1010
TERMUX_PKG_DEPENDS="gdbm, libcrypt, libiconv, mbedtls, zlib"
1111
TERMUX_PKG_BUILD_DEPENDS="libatomic-ops"
12-
TERMUX_PKG_RECOMMENDS="binutils-is-llvm | binutils, ca-certificates"
12+
TERMUX_PKG_RECOMMENDS="llvm, ca-certificates"
1313
TERMUX_PKG_HOSTBUILD=true
1414
TERMUX_PKG_BUILD_IN_SRC=true
1515

packages/ldc/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ TERMUX_PKG_SHA256=(fdbb376f08242d917922a6a22a773980217fafa310046fc5d6459490af23d
2121
5784d4cc47d0845af0897d3b7473a08dd0281a4cdabac0a486740840d014fde1)
2222
TERMUX_PKG_AUTO_UPDATE=false
2323
# dub dlopen()s libcurl.so:
24-
TERMUX_PKG_DEPENDS="binutils-bin, binutils-is-llvm | binutils, clang, libc++, libcurl, zlib"
24+
TERMUX_PKG_DEPENDS="binutils, clang, libc++, libcurl, zlib"
2525
TERMUX_PKG_BUILD_DEPENDS="binutils-cross"
2626
TERMUX_PKG_NO_STATICSPLIT=true
2727
TERMUX_PKG_HOSTBUILD=true
@@ -39,7 +39,7 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
3939
-DLLVM_INCLUDE_TESTS=OFF
4040
-DLLVM_TABLEGEN=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-tblgen
4141
-DLLVM_CONFIG_PATH=$TERMUX_PKG_HOSTBUILD_DIR/bin/llvm-config
42-
-DPYTHON_EXECUTABLE=$(command -v python3)
42+
-DPYTHON_EXECUTABLE=$(command -v python3)ap
4343
-DLLVM_TARGETS_TO_BUILD='AArch64;ARM;WebAssembly;X86'
4444
"
4545

packages/ldd/build.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ TERMUX_PKG_HOMEPAGE=https://github.com/termux/termux-packages
22
TERMUX_PKG_DESCRIPTION="Fake ldd command"
33
TERMUX_PKG_LICENSE="Apache-2.0"
44
TERMUX_PKG_MAINTAINER="@termux"
5-
TERMUX_PKG_VERSION=0.3
5+
TERMUX_PKG_VERSION="0.3"
6+
TERMUX_PKG_REVISION=1
67
TERMUX_PKG_AUTO_UPDATE=false
78
TERMUX_PKG_SKIP_SRC_EXTRACT=true
8-
TERMUX_PKG_DEPENDS="bash, binutils-bin"
9+
TERMUX_PKG_DEPENDS="bash, llvm"
910
TERMUX_PKG_CONFLICTS="binutils (<< 2.39-1)"
1011

1112
termux_step_make_install() {
12-
local _READELF=$TERMUX_PREFIX/libexec/binutils/readelf
13+
local _READELF="$TERMUX_PREFIX/bin/readelf"
1314

1415
local ldd="$TERMUX_PREFIX/bin/ldd"
1516
mkdir -p "$(dirname "${ldd}")"

0 commit comments

Comments
 (0)