这是indexloc提供的服务,不要输入任何密码
Skip to content

[Bug]: building C++ packages on-device broken #23578

@robertkirkman

Description

@robertkirkman

Problem description

Unfortunately,

has broken the $TERMUX_ON_DEVICE_BUILD=true mode of building packages for packages that contain C++ code.

/data/data/com.termux/files/usr/include/c++/v1/cstdint:149:5: error: <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header. This usually means that your header search paths are not configured properly. The header search paths should contain the C++ Standard Library headers before any C Standard Library, and you are probably using compiler flags that make that not be the case.
  149 | #   error <cstdint> tried including <stdint.h> but didn't find libc++'s <stdint.h> header. \
      |     ^

I am very sorry about it, I tested that heavily for $TERMUX_ON_DEVICE_BUILD=false mode, but I did not test it heavily enough for $TERMUX_ON_DEVICE_BUILD=true mode.

I believe that the cause of this is that the include search path using -isystem, at least with the on-device clang++, might be causing $TERMUX_PREFIX/include to be searched for stdint.h before $TERMUX_PREFIX/include/c++/v1 because of an interaction it could be having with the -isysroot argument that is present in all compiler invocations on-device, but is never present in the cross-compiler arguments.

$TERMUX_ON_DEVICE_BUILD=true internal compiler arguments
"/data/data/com.termux/files/usr/bin/clang-19"
"-cc1"
"-triple"
"aarch64-unknown-linux-android"
"-emit-obj"
"-dumpdir"
"a-"
"-disable-free"
"-clear-ast-before-backend"
"-disable-llvm-verifier"
"-discard-value-names"
"-main-file-name"
"hello.cpp"
"-mrelocation-model"
"pic"
"-pic-level"
"2"
"-pic-is-pie"
"-mframe-pointer=non-leaf"
"-ffp-contract=on"
"-fno-rounding-math"
"-mconstructor-aliases"
"-funwind-tables=2"
"-target-cpu"
"generic"
"-target-feature"
"+v8a"
"-target-feature"
"+fp-armv8"
"-target-feature"
"+neon"
"-target-feature"
"+fix-cortex-a53-835769"
"-target-abi"
"aapcs"
"-debugger-tuning=gdb"
"-fdebug-compilation-dir=/data/data/com.termux/files/home/.termux-build/libcln/src"
"-fcoverage-compilation-dir=/data/data/com.termux/files/home/.termux-build/libcln/src"
"-resource-dir"
"/data/data/com.termux/files/usr/lib/clang/19"
"-isystem"
"/data/data/com.termux/files/usr/include"
"-isysroot"
"/data/data/com.termux/files"
"-internal-isystem"
"/data/data/com.termux/files/usr/include/c++/v1"
"-internal-isystem"
"/data/data/com.termux/files/usr/lib/clang/19/include"
"-internal-isystem"
"/data/data/com.termux/files/usr/local/include"
"-internal-externc-isystem"
"/data/data/com.termux/files/usr/include/aarch64-linux-android"
"-internal-externc-isystem"
"/data/data/com.termux/files/include"
"-internal-externc-isystem"
"/data/data/com.termux/files/usr/include"
"-source-date-epoch"
"1740992219"
"-Oz"
"-fdeprecated-macro"
"-ferror-limit"
"19"
"-femulated-tls"
"-stack-protector"
"2"
"-fno-signed-char"
"-fgnuc-version=4.2.1"
"-fskip-odr-check-in-gmf"
"-fcxx-exceptions"
"-fexceptions"
"-fcolor-diagnostics"
"-vectorize-slp"
"-target-feature"
"+outline-atomics"
"-target-feature"
"-fmv"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1"
"-o"
"/data/data/com.termux/files/usr/tmp/hello-a238da.o"
"-x"
"c++"
"hello.cpp"
$TERMUX_ON_DEVICE_BUILD=false internal compiler arguments
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/clang-18"
"-cc1"
"-triple"
"aarch64-unknown-linux-android24"
"-emit-obj"
"-dumpdir"
"a-"
"-disable-free"
"-clear-ast-before-backend"
"-disable-llvm-verifier"
"-discard-value-names"
"-main-file-name"
"hello.cpp"
"-mrelocation-model"
"pic"
"-pic-level"
"2"
"-pic-is-pie"
"-mframe-pointer=non-leaf"
"-ffp-contract=on"
"-fno-rounding-math"
"-mconstructor-aliases"
"-funwind-tables=2"
"-target-cpu"
"generic"
"-target-feature"
"+neon"
"-target-feature"
"+v8a"
"-target-feature"
"+fix-cortex-a53-835769"
"-target-abi"
"aapcs"
"-debugger-tuning=gdb"
"-fdebug-compilation-dir=/home/builder/.termux-build/dar/src"
"-fcoverage-compilation-dir=/home/builder/.termux-build/dar/src"
"-resource-dir"
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/lib/clang/18"
"-isystem"
"/data/data/com.termux/files/usr/include"
"-internal-isystem"
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/../sysroot/usr/include/c++/v1"
"-internal-isystem"
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/lib/clang/18/include"
"-internal-isystem"
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/../sysroot/usr/local/include"
"-internal-externc-isystem"
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/../sysroot/usr/include/aarch64-linux-android"
"-internal-externc-isystem"
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/../sysroot/include"
"-internal-externc-isystem"
"/home/builder/.termux-build/_cache/android-r27c-api-24-v1/bin/../sysroot/usr/include"
"-source-date-epoch"
"1740981624"
"-Oz"
"-fdeprecated-macro"
"-ferror-limit"
"19"
"-femulated-tls"
"-stack-protector"
"2"
"-fno-signed-char"
"-fgnuc-version=4.2.1"
"-fcxx-exceptions"
"-fexceptions"
"-fcolor-diagnostics"
"-vectorize-slp"
"-target-feature"
"+outline-atomics"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1"
"-o"
"/tmp/hello-6dbb52.o"
"-x"
"c++"
"hello.cpp"

What steps will reproduce the bug?

git clone https://github.com/termux/termux-packages.git
cd termux-packages/
scripts/setup-termux.sh
./build-package.sh -I -f libcln

Hello world test

cat > hello.cpp << EOF
#include <iostream>

int main(void) {
	std::cout << "hello world" << std::endl;
}
EOF
clang++ hello.cpp # ok
clang++ -I$PREFIX/include hello.cpp # ok
clang++ -isystem$PREFIX/include hello.cpp # error
clang++ -isystem$PREFIX/include/c++/v1 -isystem$PREFIX/include hello.cpp # ok

Insert these lines into termux_step_pre_configure() of any build.sh to obtain the internal include search path argument list for the C++ compiler being used for the build:

	cat > hello.cpp << EOF
#include <iostream>

int main(void) {
	std::cout << "hello world" << std::endl;
}
EOF
	$CXX -### $CXXFLAGS $CPPFLAGS $LDFLAGS hello.cpp

What is the expected behavior?

Successful on-device building of C++ packages like that were previously possible to build on-device, like libcln

System information

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__APK_FILE=/data/app/~~gVwKanLEt3onhDQBKcUZQA==/com.termux-Jepd-I809CuxEnnuONZ6_Q==/base.apk
TERMUX_APP__APK_RELEASE=F_DROID
TERMUX_APP__APP_VERSION_CODE=1020
TERMUX_APP__APP_VERSION_NAME=0.119.0-beta.1
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__IS_DEBUGGABLE_BUILD=false
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PID=20460
TERMUX_APP__TARGET_SDK=28
TERMUX_VERSION=0.119.0-beta.1
TERMUX__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c237,c256,c512,c768
TERMUX__SE_INFO=default:targetSdkVersion=28:complete
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c237,c256,c512,c768
TERMUX__UID=10237
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages.termux.dev/apt/termux-main stable main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous
# glibc-repo (sources.list.d/glibc.list)
deb https://packages-cf.termux.dev/apt/termux-glibc/ glibc stable
# sources.list.d/termux-adb.list
deb https://nohajc.github.io termux extras
# x11-repo (sources.list.d/x11.list)
deb https://packages.termux.dev/apt/termux-x11 x11 main
Updatable packages:
All packages up to date
termux-tools version:
1.44.6
Android version:
13
Kernel build information:
Linux localhost 4.14.190-lineage-gef0cb31b13 #4 SMP PREEMPT Fri Jun 23 13:11:47 CEST 2023 aarch64 Android
Device manufacturer:
samsung
Device model:
SM-A705FN
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.api versionCode:51
com.termux.x11 versionCode:15

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug reportSomething is not working properlypackagingIssue related to building packages, not affecting end users directly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions