From 785d52504e6ed1f3b35ee559891134d0e804d46f Mon Sep 17 00:00:00 2001 From: Robert Kirkman Date: Thu, 6 Mar 2025 18:12:21 -0600 Subject: [PATCH 1/3] fix(toolchain/{23c,27c}): add -isystem${TERMUX_PREFIX}/include/c++/v1 to $CPPFLAGS before -isystem${TERMUX_PREFIX}/include - Fixes termux#23578 -isystem${TERMUX_PREFIX}/include/c++/v1 is necessary because, while ${TERMUX_PREFIX}/include/c++/v1 is never present in $TERMUX_ON_DEVICE_BUILD=false mode (because of this line: https://github.com/termux/termux-packages/blob/fe7adf6ea2c7e5305c1213cbda919c17f251685d/scripts/build/termux_step_get_dependencies.sh#L28-L29 ), it is present in $TERMUX_ON_DEVICE_BUILD=true mode, and must be in the include path before ${TERMUX_PREFIX}/include, otherwise C++ programs will fail to compile on-device (but not in the cross-compiler), and also python, ruby, octave and ecl store the compiler arguments they were built with into their packages and reuse them when invoking clang and clang++ on-device, so this ensures that on-device pip builds will have the correct include order. --- scripts/build/toolchain/termux_setup_toolchain_23c.sh | 4 +++- scripts/build/toolchain/termux_setup_toolchain_27c.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/build/toolchain/termux_setup_toolchain_23c.sh b/scripts/build/toolchain/termux_setup_toolchain_23c.sh index 6ee3b5c99685adf..9a35d524de474bc 100644 --- a/scripts/build/toolchain/termux_setup_toolchain_23c.sh +++ b/scripts/build/toolchain/termux_setup_toolchain_23c.sh @@ -82,7 +82,9 @@ termux_setup_toolchain_23c() { fi export CXXFLAGS="$CFLAGS" - export CPPFLAGS+=" -isystem${TERMUX_PREFIX}/include" + # set the proper header include order - first package includes, then prefix includes + # -isystem${TERMUX_PREFIX}/include/c++/v1 is needed here for on-device building to work correctly + export CPPFLAGS+=" -isystem${TERMUX_PREFIX}/include/c++/v1 -isystem${TERMUX_PREFIX}/include" # If libandroid-support is declared as a dependency, link to it explicitly: if [ "$TERMUX_PKG_DEPENDS" != "${TERMUX_PKG_DEPENDS/libandroid-support/}" ]; then diff --git a/scripts/build/toolchain/termux_setup_toolchain_27c.sh b/scripts/build/toolchain/termux_setup_toolchain_27c.sh index c4c276e0db0c1a8..02c3df1fc3afe1e 100644 --- a/scripts/build/toolchain/termux_setup_toolchain_27c.sh +++ b/scripts/build/toolchain/termux_setup_toolchain_27c.sh @@ -82,7 +82,9 @@ termux_setup_toolchain_27c() { fi export CXXFLAGS="$CFLAGS" - export CPPFLAGS+=" -isystem${TERMUX_PREFIX}/include" + # set the proper header include order - first package includes, then prefix includes + # -isystem${TERMUX_PREFIX}/include/c++/v1 is needed here for on-device building to work correctly + export CPPFLAGS+=" -isystem${TERMUX_PREFIX}/include/c++/v1 -isystem${TERMUX_PREFIX}/include" # If libandroid-support is declared as a dependency, link to it explicitly: if [ "$TERMUX_PKG_DEPENDS" != "${TERMUX_PKG_DEPENDS/libandroid-support/}" ]; then From 12406302ee135304f92a2055db87cfa902260a39 Mon Sep 17 00:00:00 2001 From: Robert Kirkman Date: Thu, 6 Mar 2025 18:15:49 -0600 Subject: [PATCH 2/3] fix(main/ghostscript): clean up `$CPPFLAGS` and add tested `$TERMUX_ON_DEVICE_BUILD=true` support this package's configure script checks only for $PKGCONFIG, but that variable is currently only set globally in $TERMUX_ON_DEVICE_BUILD=false mode. In $TERMUX_ON_DEVICE_BUILD=true mode, only $PKG_CONFIG is set globally. ld.lld: error: undefined symbol: libiconv many packages manually set this universally without comment, but a pattern can be observed that reverse dependencies of libiconv seem to always require this in $TERMUX_ON_DEVICE_BUILD=true mode, and it gets set whenever someone creates $TERMUX_ON_DEVICE_BUILD=true support for one of them. see the commit message here: https://github.com/termux/termux-packages/commit/bab423c2bdef216da366afac7cdcea095698694b --- packages/ghostscript/build.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/ghostscript/build.sh b/packages/ghostscript/build.sh index 19f5fc2d13b393a..22660ae121e82ed 100644 --- a/packages/ghostscript/build.sh +++ b/packages/ghostscript/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Interpreter for the PostScript language and for PDF" TERMUX_PKG_LICENSE="AGPL-V3" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="10.03.1" -TERMUX_PKG_REVISION=2 +TERMUX_PKG_REVISION=3 TERMUX_PKG_SRCURL=https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${TERMUX_PKG_VERSION//.}/ghostpdl-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=8ea9dd8768b64576bc4ee2d79611450c9e1edeb686f7824f3bf94b92457b882a TERMUX_PKG_AUTO_UPDATE=false @@ -29,7 +29,10 @@ termux_step_post_get_source() { } termux_step_pre_configure() { - CPPFLAGS+=" -I${TERMUX_STANDALONE_TOOLCHAIN}/sysroot/usr/include/c++/v1" + if [ "$TERMUX_ON_DEVICE_BUILD" = "true" ]; then + export PKGCONFIG="$PKG_CONFIG" + export LDFLAGS+=" -liconv" + fi if [[ "${TERMUX_ARCH}" == "aarch64" ]]; then # https://github.com/llvm/llvm-project/issues/74361 From 302f7f0f5b31bd428f801895101c85f59b7f9bfc Mon Sep 17 00:00:00 2001 From: Robert Kirkman Date: Thu, 6 Mar 2025 18:19:37 -0600 Subject: [PATCH 3/3] fix({main/octave,x11/octave-x}): revbump and fix propagated $CPPFLAGS revbump after https://github.com/termux/termux-packages/commit/db889e1 to fix propagated $CPPFLAGS using $TERMUX_PKG_TMPDIR/_deps to only have needed libraries in the search path prevents ld.lld: error: duplicate symbol: tzalloc in $flang_libs_dir/libc.a putting -l:$_libgcc_name only in $LIBS instead of $LDFLAGS prevents ld.lld: error: unable to find library -l:libclang_rt.builtins-aarch64-android.a on-device during the pkg function https://octave.sourceforge.io/octave/function/pkg.html prevents this error: clang++: error: no such file or directory: '/home/builder/.termux-build/_cache/android-r27c-api-24-v1/lib/clang/18/lib/linux/libclang_rt.builtins-aarch64-android.a' --- packages/octave/build.sh | 15 +++++-- .../octave-x/0001-fix-hardcoded-paths.patch | 45 +------------------ ...ppend-rpath-flag-to-pkg-config-files.patch | 21 +-------- .../0003-undefine-the-macro-in-pwd.h.patch | 18 +------- x11-packages/octave-x/build.sh | 13 +++--- 5 files changed, 22 insertions(+), 90 deletions(-) mode change 100644 => 120000 x11-packages/octave-x/0001-fix-hardcoded-paths.patch mode change 100644 => 120000 x11-packages/octave-x/0002-append-rpath-flag-to-pkg-config-files.patch mode change 100644 => 120000 x11-packages/octave-x/0003-undefine-the-macro-in-pwd.h.patch diff --git a/packages/octave/build.sh b/packages/octave/build.sh index 33f67c50daec1f6..a956a67179cd36f 100644 --- a/packages/octave/build.sh +++ b/packages/octave/build.sh @@ -3,9 +3,10 @@ TERMUX_PKG_DESCRIPTION="GNU Octave is a high-level language, primarily intended TERMUX_PKG_LICENSE="GPL-3.0" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="9.4.0" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://ftpmirror.gnu.org/octave/octave-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=fff911909ef79f95ba244dab5b8c1cb8c693a6c447d31deabb53994f17cb7b3d -TERMUX_PKG_DEPENDS="libandroid-complex-math, arpack-ng, bzip2, fftw, fontconfig, freetype, glpk, graphicsmagick, libcurl, libhdf5, libiconv, libopenblas, libsndfile, openssl, pcre2, portaudio, qhull, qrupdate-ng, rapidjson, readline, suitesparse, sundials, zlib" +TERMUX_PKG_DEPENDS="libandroid-complex-math, arpack-ng, clang, bzip2, fftw, fontconfig, freetype, glpk, graphicsmagick, libcurl, libhdf5, libiconv, libopenblas, libsndfile, make, openssl, pcre2, portaudio, qhull, qrupdate-ng, rapidjson, readline, suitesparse, sundials, zlib" TERMUX_PKG_BUILD_DEPENDS="gnuplot, less" TERMUX_PKG_RECOMMENDS="gnuplot, less" TERMUX_PKG_CONFLICTS="octave-x" @@ -52,9 +53,15 @@ termux_step_pre_configure() { local flang_libs_dir="$flang_toolchain_dir/sysroot/usr/lib/$TERMUX_HOST_PLATFORM" export F77="$FC" - export ac_cv_f77_libs=" $flang_libs_dir/libFortranRuntime.a $flang_libs_dir/libFortranDecimal.a" + mkdir -p $TERMUX_PKG_TMPDIR/_deps + ln -sf $flang_libs_dir/libFortranRuntime.a $TERMUX_PKG_TMPDIR/_deps/ + ln -sf $flang_libs_dir/libFortranDecimal.a $TERMUX_PKG_TMPDIR/_deps/ + export ac_cv_f77_libs="-L$TERMUX_PKG_TMPDIR/_deps -l:libFortranRuntime.a -l:libFortranDecimal.a" LDFLAGS+=" -Wl,-rpath,$TERMUX_PREFIX/lib/octave/$TERMUX_PKG_VERSION" - LDFLAGS+=" $($CC -print-libgcc-file-name)" - export LIBS="-landroid-complex-math" + local _libgcc_file="$($CC -print-libgcc-file-name)" + local _libgcc_path="$(dirname $_libgcc_file)" + local _libgcc_name="$(basename $_libgcc_file)" + # put -l:$_libgcc_name only in $LIBS instead of $LDFLAGS + export LIBS="-landroid-complex-math -L$_libgcc_path -l:$_libgcc_name" } diff --git a/x11-packages/octave-x/0001-fix-hardcoded-paths.patch b/x11-packages/octave-x/0001-fix-hardcoded-paths.patch deleted file mode 100644 index 7de33c4df377719..000000000000000 --- a/x11-packages/octave-x/0001-fix-hardcoded-paths.patch +++ /dev/null @@ -1,44 +0,0 @@ ---- a/libinterp/corefcn/sysdep.cc -+++ b/libinterp/corefcn/sysdep.cc -@@ -796,7 +796,7 @@ - - #else - -- return "/tmp"; -+ return "@TERMUX_PREFIX@/tmp"; - - #endif - } ---- a/liboctave/system/oct-env.cc -+++ b/liboctave/system/oct-env.cc -@@ -237,7 +237,7 @@ - tempd = P_tmpdir; - #else - if (tempd.empty ()) -- tempd = "/tmp"; -+ tempd = "@TERMUX_PREFIX@/tmp"; - #endif - - #endif ---- a/src/mkoctfile.in.cc -+++ b/src/mkoctfile.in.cc -@@ -639,7 +639,7 @@ - tempd = P_tmpdir; - #else - if (tempd.empty ()) -- tempd = "/tmp"; -+ tempd = "@TERMUX_PREFIX@/tmp"; - #endif - - #endif ---- a/run-octave.in -+++ b/run-octave.in -@@ -127,7 +127,7 @@ - ## Is there a better way to do this so that we don't fill /tmp - ## with junk files? Using /dev/null won't work because asan - ## appends the process ID to the file name. -- ASAN_OPTIONS="leak_check_at_exit=0:log_path=/tmp/oct-asan-log:verbosity=0" -+ ASAN_OPTIONS="leak_check_at_exit=0:log_path=@TERMUX_PREFIX@/tmp/oct-asan-log:verbosity=0" - else - ASAN_OPTIONS="$ADDRESS_SANITIZER_OPTIONS" - fi diff --git a/x11-packages/octave-x/0001-fix-hardcoded-paths.patch b/x11-packages/octave-x/0001-fix-hardcoded-paths.patch new file mode 120000 index 000000000000000..938eaaea854ec5a --- /dev/null +++ b/x11-packages/octave-x/0001-fix-hardcoded-paths.patch @@ -0,0 +1 @@ +../../packages/octave/0001-fix-hardcoded-paths.patch \ No newline at end of file diff --git a/x11-packages/octave-x/0002-append-rpath-flag-to-pkg-config-files.patch b/x11-packages/octave-x/0002-append-rpath-flag-to-pkg-config-files.patch deleted file mode 100644 index 3102186c1428e6c..000000000000000 --- a/x11-packages/octave-x/0002-append-rpath-flag-to-pkg-config-files.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/libinterp/octinterp.in.pc -+++ b/libinterp/octinterp.in.pc -@@ -4,6 +4,6 @@ - Version: @PACKAGE_VERSION@ - Requires: octave = @PACKAGE_VERSION@ - Requires.private: --Libs: -L@octlibdir@ @LIBOCTINTERP@ -+Libs: -L@octlibdir@ -Wl,-rpath,@octlibdir@ @LIBOCTINTERP@ - Libs.private: - Cflags: -I@octincludedir@/.. ---- a/liboctave/octave.in.pc -+++ b/liboctave/octave.in.pc -@@ -4,6 +4,6 @@ - Version: @PACKAGE_VERSION@ - Requires: - Requires.private: --Libs: -L@octlibdir@ @LIBOCTAVE@ -+Libs: -L@octlibdir@ -Wl,-rpath,@octlibdir@ @LIBOCTAVE@ - Libs.private: @LIBOCTAVE_LINK_DEPS@ - Cflags: -I@octincludedir@/.. diff --git a/x11-packages/octave-x/0002-append-rpath-flag-to-pkg-config-files.patch b/x11-packages/octave-x/0002-append-rpath-flag-to-pkg-config-files.patch new file mode 120000 index 000000000000000..0c688132b6d45d3 --- /dev/null +++ b/x11-packages/octave-x/0002-append-rpath-flag-to-pkg-config-files.patch @@ -0,0 +1 @@ +../../packages/octave/0002-append-rpath-flag-to-pkg-config-files.patch \ No newline at end of file diff --git a/x11-packages/octave-x/0003-undefine-the-macro-in-pwd.h.patch b/x11-packages/octave-x/0003-undefine-the-macro-in-pwd.h.patch deleted file mode 100644 index 1db6c7ccd9fbc0d..000000000000000 --- a/x11-packages/octave-x/0003-undefine-the-macro-in-pwd.h.patch +++ /dev/null @@ -1,17 +0,0 @@ -+++ ./liboctave/wrappers/pwd-wrappers.c -@@ -32,6 +32,15 @@ - - #if defined (HAVE_PWD_H) - # include -+# ifdef getpwnam -+# undef getpwnam -+# endif -+# ifdef getpwuid -+# undef getpwuid -+# endif -+# ifdef getpwuid_r -+# undef getpwuid_r -+# endif - #endif - - #include "pwd-wrappers.h" diff --git a/x11-packages/octave-x/0003-undefine-the-macro-in-pwd.h.patch b/x11-packages/octave-x/0003-undefine-the-macro-in-pwd.h.patch new file mode 120000 index 000000000000000..3aa65606f3772b8 --- /dev/null +++ b/x11-packages/octave-x/0003-undefine-the-macro-in-pwd.h.patch @@ -0,0 +1 @@ +../../packages/octave/0003-undefine-the-macro-in-pwd.h.patch \ No newline at end of file diff --git a/x11-packages/octave-x/build.sh b/x11-packages/octave-x/build.sh index d91a83cd9375f72..04f1817c55c2a18 100644 --- a/x11-packages/octave-x/build.sh +++ b/x11-packages/octave-x/build.sh @@ -3,9 +3,10 @@ TERMUX_PKG_DESCRIPTION="GNU Octave is a high-level language, primarily intended TERMUX_PKG_LICENSE="GPL-3.0" TERMUX_PKG_MAINTAINER="@termux" TERMUX_PKG_VERSION="9.4.0" +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://ftpmirror.gnu.org/octave/octave-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=fff911909ef79f95ba244dab5b8c1cb8c693a6c447d31deabb53994f17cb7b3d -TERMUX_PKG_DEPENDS="arpack-ng, fftw, fltk, fontconfig, freetype, glpk, glu, graphicsmagick, libandroid-complex-math, libbz2, libc++, libcurl, libhdf5, libiconv, libopenblas, libsndfile, libx11, libxcursor, libxext, libxfixes, libxft, libxinerama, libxrender, opengl, openssl, pcre2, portaudio, qhull, qrupdate-ng, qt6-qt5compat, qt6-qtbase, qt6-qttools, readline, suitesparse, sundials, zlib" +TERMUX_PKG_DEPENDS="arpack-ng, clang, fftw, fltk, fontconfig, freetype, glpk, glu, graphicsmagick, libandroid-complex-math, libbz2, libc++, libcurl, libhdf5, libiconv, libopenblas, libsndfile, libx11, libxcursor, libxext, libxfixes, libxft, libxinerama, libxrender, make, opengl, openssl, pcre2, portaudio, qhull, qrupdate-ng, qt6-qt5compat, qt6-qtbase, qt6-qttools, readline, suitesparse, sundials, zlib" TERMUX_PKG_BUILD_DEPENDS="gnuplot, less, rapidjson, qt6-qtbase-cross-tools, qt6-qttools-cross-tools" TERMUX_PKG_RECOMMENDS="gnuplot, less" TERMUX_PKG_CONFLICTS="octave-x" @@ -53,15 +54,17 @@ termux_step_pre_configure() { local flang_libs_dir="$flang_toolchain_dir/sysroot/usr/lib/$TERMUX_HOST_PLATFORM" export F77="$FC" - export ac_cv_f77_libs=" $flang_libs_dir/libFortranRuntime.a $flang_libs_dir/libFortranDecimal.a" + mkdir -p $TERMUX_PKG_TMPDIR/_deps + ln -sf $flang_libs_dir/libFortranRuntime.a $TERMUX_PKG_TMPDIR/_deps/ + ln -sf $flang_libs_dir/libFortranDecimal.a $TERMUX_PKG_TMPDIR/_deps/ + export ac_cv_f77_libs="-L$TERMUX_PKG_TMPDIR/_deps -l:libFortranRuntime.a -l:libFortranDecimal.a" LDFLAGS+=" -Wl,-rpath,$TERMUX_PREFIX/lib/octave/$TERMUX_PKG_VERSION" - local _libgcc_file="$($CC -print-libgcc-file-name)" local _libgcc_path="$(dirname $_libgcc_file)" local _libgcc_name="$(basename $_libgcc_file)" - LDFLAGS+=" -L$_libgcc_path -l:$_libgcc_name" - export LIBS="-landroid-complex-math" + # put -l:$_libgcc_name only in $LIBS instead of $LDFLAGS + export LIBS="-landroid-complex-math -L$_libgcc_path -l:$_libgcc_name" export PATH="$TERMUX_PREFIX/opt/qt6/cross/bin:$PATH" }