diff --git a/gpkg/gcc-libs-dev-glibc32/build.sh b/gpkg/gcc-libs-dev-glibc32/build.sh new file mode 100644 index 000000000..ddc08ea76 --- /dev/null +++ b/gpkg/gcc-libs-dev-glibc32/build.sh @@ -0,0 +1,14 @@ +TERMUX_PKG_HOMEPAGE=https://gcc.gnu.org/ +TERMUX_PKG_DESCRIPTION="Runtime libraries shipped by GCC on a 32-bit basis (temporary package)" +TERMUX_PKG_LICENSE="GPL-3.0" +TERMUX_PKG_MAINTAINER="@termux-pacman" +TERMUX_PKG_VERSION=14.2.1 +TERMUX_PKG_SKIP_SRC_EXTRACT=true +TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686" + +termux_step_make_install() { + ( + termux_set_crosses_arch + cp -r ${CGCT_DIR}/${TERMUX_ARCH}/lib/lib* ${TERMUX_LIB32_PATH} + ) +} diff --git a/gpkg/glibc/build.sh b/gpkg/glibc/build.sh index 397f1a32f..15b88837b 100644 --- a/gpkg/glibc/build.sh +++ b/gpkg/glibc/build.sh @@ -11,27 +11,7 @@ TERMUX_PKG_RECOMMENDS="glibc-runner" TERMUX_PKG_NO_STATICSPLIT=true TERMUX_PKG_CONFFILES="glibc/etc/gai.conf, glibc/etc/locale.gen" TERMUX_PKG_SEPARATE_SUB_DEPENDS=true - -# Variables for glibc32 compilation -TERMUX_PKG_BUILD32=$(test "$TERMUX_ARCH" = "aarch64" || test "$TERMUX_ARCH" = "arm" && \ - test "$TERMUX_ON_DEVICE_BUILD" = "false" && echo "true" || echo "false") -TERMUX_PKG_BUILDDIR32="${TERMUX_TOPDIR}/${TERMUX_PKG_NAME}/build32" -#if [ "$TERMUX_PKG_BUILD32" = "true" ]; then -# TERMUX_PKG_BUILD_DEPENDS="glibc32" -#fi - -termux_setup_build32() { - case $TERMUX_ARCH in - "aarch64") - TERMUX_ARCH="arm" - TERMUX_HOST_PLATFORM="arm-linux-gnueabihf";; - "x86_64") - TERMUX_ARCH="i686" - TERMUX_HOST_PLATFORM="i686-linux-gnu";; - esac - termux_step_setup_toolchain - cd ${TERMUX_PKG_BUILDDIR32} -} +TERMUX_PKG_BUILD32=true termux_step_pre_configure() { if [ "$TERMUX_PACKAGE_LIBRARY" != "glibc" ]; then @@ -112,8 +92,8 @@ termux_step_pre_configure() { # replacing some hard paths that may not exist in some device for i in /dev/stderr:/proc/self/fd/2 \ - /dev/stdin:/proc/self/fd/0 \ - /dev/stdout:/proc/self/fd/1; do + /dev/stdin:/proc/self/fd/0 \ + /dev/stdout:/proc/self/fd/1; do for j in $(grep -s -r -l ${i%%:*} ${TERMUX_PKG_SRCDIR}); do sed -i "s|${i%%:*}|${i//*:}|g" ${j} done @@ -124,20 +104,16 @@ termux_step_pre_configure() { # specifying the current release (use only when developing glibc) sed -i "s/stable/dev.$(git -C ${TERMUX_PKG_BUILDER_DIR} rev-parse --short HEAD).$(date +%Y%m%d%H%M%S)/" ${TERMUX_PKG_SRCDIR}/version.h - - if [ "$TERMUX_PKG_BUILD32" = "true" ]; then - rm -fr ${TERMUX_PKG_BUILDDIR32} - mkdir -p ${TERMUX_PKG_BUILDDIR32} - fi } -termux_glibc_configure() { - local libdir="${1}" - - echo "slibdir=${TERMUX_PREFIX}/${libdir}" > configparms - echo "rtlddir=${TERMUX_PREFIX}/${libdir}" >> configparms +termux_step_configure() { + echo "slibdir=${TERMUX_LIB_PATH}" > configparms + echo "rtlddir=${TERMUX_LIB_PATH}" >> configparms echo "sbindir=${TERMUX_PREFIX}/bin" >> configparms echo "rootsbindir=${TERMUX_PREFIX}/bin" >> configparms + if [ "$TERMUX_ARCH" != "$TERMUX_REAL_ARCH" ]; then + echo 'build-programs=no' >> configparms + fi local _configure_flags=() case $TERMUX_ARCH in @@ -153,8 +129,8 @@ termux_glibc_configure() { ${TERMUX_PKG_SRCDIR}/configure \ --prefix=$TERMUX_PREFIX \ - --libdir=${TERMUX_PREFIX}/${libdir} \ - --libexecdir=${TERMUX_PREFIX}/${libdir} \ + --libdir=$TERMUX_LIB_PATH \ + --libexecdir=$TERMUX_LIB_PATH \ --host=$TERMUX_HOST_PLATFORM \ --build=$TERMUX_HOST_PLATFORM \ --target=$TERMUX_HOST_PLATFORM \ @@ -171,35 +147,17 @@ termux_glibc_configure() { "${_configure_flags[@]}" } -termux_step_configure() { - termux_glibc_configure "lib" - - if [ "$TERMUX_PKG_BUILD32" = "true" ]; then - ( - termux_setup_build32 - termux_glibc_configure "lib32" - echo 'build-programs=no' >> configparms - ) - fi -} - termux_step_make() { make -O - make info - - if [ "$TERMUX_PKG_BUILD32" = "true" ]; then - ( - termux_setup_build32 - make -O - ) + if [ "$TERMUX_ARCH" = "$TERMUX_REAL_ARCH" ]; then + make info fi } termux_glibc_make_syscall_without_fsc() { local libname="libsyscall_without_fsc.so" - local libdir="$1" echo "Compiling '${libname}'..." - $CC ${TERMUX_PKG_BUILDER_DIR}/syscall.c -o ${TERMUX_PREFIX}/${libdir}/${libname} \ + $CC ${TERMUX_PKG_BUILDER_DIR}/syscall.c -o ${TERMUX_LIB_PATH}/${libname} \ -shared -DWITHOUT_FAKESYSCALL echo "DONE" } @@ -210,11 +168,11 @@ termux_step_make_install() { make install_root="/" install rm -f ${TERMUX_PREFIX}/etc/ld.so.cache - rm -f ${TERMUX_PREFIX}/bin/{tzselect,zdump,zic} + #rm -f ${TERMUX_PREFIX}/bin/{tzselect,zdump,zic} - install -dm755 ${TERMUX_PREFIX}/lib/tmpfiles.d + install -dm755 ${TERMUX_LIB_PATH}/tmpfiles.d install -m644 ${TERMUX_PKG_SRCDIR}/nscd/nscd.conf ${TERMUX_PREFIX}/etc/nscd.conf - install -m644 ${TERMUX_PKG_SRCDIR}/nscd/nscd.tmpfiles ${TERMUX_PREFIX}/lib/tmpfiles.d/nscd.conf + install -m644 ${TERMUX_PKG_SRCDIR}/nscd/nscd.tmpfiles ${TERMUX_LIB_PATH}/tmpfiles.d/nscd.conf install -m644 ${TERMUX_PKG_SRCDIR}/posix/gai.conf ${TERMUX_PREFIX}/etc/gai.conf install -m755 ${TERMUX_PKG_BUILDER_DIR}/locale-gen ${TERMUX_PREFIX}/bin sed -i "s|@TERMUX_PREFIX@|$TERMUX_PREFIX|g; s|@TERMUX_PREFIX_CLASSICAL@|$TERMUX_PREFIX_CLASSICAL|g" \ @@ -227,7 +185,7 @@ termux_step_make_install() { sed -e '1,3d' -e 's|/| |g' -e 's| \\||g' \ ${TERMUX_PKG_SRCDIR}/localedata/SUPPORTED > ${TERMUX_PREFIX}/share/i18n/SUPPORTED - install -dm755 ${TERMUX_PREFIX}/lib/locale + install -dm755 ${TERMUX_LIB_PATH}/locale make -C ${TERMUX_PKG_SRCDIR}/localedata objdir=${TERMUX_PKG_BUILDDIR} \ SUPPORTED-LOCALES="C.UTF-8/UTF-8 en_US.UTF-8/UTF-8" install-locale-files sed -i '/#C\.UTF-8 /d' ${TERMUX_PREFIX}/etc/locale.gen @@ -236,24 +194,35 @@ termux_step_make_install() { install -Dm644 ${TERMUX_PKG_BUILDER_DIR}/sdt-config.h ${TERMUX_PREFIX}/include/sys/sdt-config.h ln -sfr $PATH_DYNAMIC_LINKER ${TERMUX_PREFIX}/bin/ld.so - ln -sfr $PATH_DYNAMIC_LINKER ${TERMUX_PREFIX}/lib/ld.so + ln -sfr $PATH_DYNAMIC_LINKER ${TERMUX_LIB_PATH}/ld.so - termux_glibc_make_syscall_without_fsc "lib" - - if [ "$TERMUX_PKG_BUILD32" = "true" ]; then - ( - termux_setup_build32 + termux_glibc_make_syscall_without_fsc +} - make DESTDIR=${TERMUX_PKG_BUILDDIR32} install +termux_step_make_install32() { + make DESTDIR=${TERMUX_PKG_BUILD32DIR} install + + echo "Sorting headers for include32..." + local hpath + for hpath in $(find ${TERMUX_PKG_BUILD32DIR}/${TERMUX_PREFIX}/include -type f); do + local h=$(sed "s|${TERMUX_PKG_BUILD32DIR}/${TERMUX_PREFIX}/include/||g" <<< "$hpath") + if [ -f "${TERMUX_PREFIX}/include/${h}" ] && \ + [ $(md5sum "${hpath}" | awk '{printf $1}') = $(md5sum "${TERMUX_PREFIX}/include/${h}" | awk '{printf $1}') ]; then + rm "${hpath}" + fi + done + find ${TERMUX_PKG_BUILD32DIR}/${TERMUX_PREFIX}/include -type d -empty -delete + echo "DONE" - cp -r ${TERMUX_PKG_BUILDDIR32}/${TERMUX_PREFIX}/lib32 $TERMUX_PREFIX + cp -r ${TERMUX_PKG_BUILD32DIR}/${TERMUX_LIB_PATH} $TERMUX_PREFIX + install -dm755 ${TERMUX_PREFIX}/include32 + cp -r ${TERMUX_PKG_BUILD32DIR}/${TERMUX_PREFIX}/include/* ${TERMUX_PREFIX}/include32 - ln -sfr ${TERMUX_PREFIX}/lib/locale ${TERMUX_PREFIX}/lib32/locale + ln -sfr ${TERMUX_LIB64_PATH}/locale ${TERMUX_LIB_PATH}/locale - ln -sfr ${TERMUX_PREFIX}/lib32/${DYNAMIC_LINKER} $PATH_DYNAMIC_LINKER - ln -sfr ${TERMUX_PREFIX}/lib32/${DYNAMIC_LINKER} ${TERMUX_PREFIX}/lib32/ld.so + ln -sfr ${TERMUX_LIB_PATH}/${DYNAMIC_LINKER} $PATH_DYNAMIC_LINKER + ln -sfr ${TERMUX_LIB_PATH}/${DYNAMIC_LINKER} ${TERMUX_PREFIX}/bin/ld32.so + ln -sfr ${TERMUX_LIB_PATH}/${DYNAMIC_LINKER} ${TERMUX_LIB_PATH}/ld.so - termux_glibc_make_syscall_without_fsc "lib32" - ) - fi + termux_glibc_make_syscall_without_fsc } diff --git a/gpkg/glibc/fakesyscall.json b/gpkg/glibc/fakesyscall.json index d6e0dc919..9b2e3dfa3 100644 --- a/gpkg/glibc/fakesyscall.json +++ b/gpkg/glibc/fakesyscall.json @@ -56,6 +56,10 @@ "get_mempolicy", "set_mempolicy", "mq_open", - "rt_sigreturn" + "rt_sigreturn", + "semget", + "semctl", + "semtimedop", + "semtimedop_time64" ] } diff --git a/gpkg/glibc/glibc32.subpackage.sh b/gpkg/glibc/glibc32.subpackage.sh index fbc333fa3..210a79cd5 100644 --- a/gpkg/glibc/glibc32.subpackage.sh +++ b/gpkg/glibc/glibc32.subpackage.sh @@ -1,7 +1,10 @@ TERMUX_SUBPKG_DESCRIPTION="GNU C Library (32-bit)" -TERMUX_SUBPKG_DEPENDS="linux-api-headers-glibc" +TERMUX_SUBPKG_DEPENDS="glibc" TERMUX_SUBPKG_EXCLUDED_ARCHES="arm, i686" TERMUX_SUBPKG_INCLUDE=" +glibc/bin/ld32.so glibc/lib32/ glibc/lib/ld-linux-armhf.so.3 -glibc/lib/ld-linux.so.2" +glibc/lib/ld-linux.so.2 +glibc/include32/ +" diff --git a/gpkg/glibc/set-fakesyscalls.patch b/gpkg/glibc/set-fakesyscalls.patch index 2eb3b37d1..4cd49768f 100644 --- a/gpkg/glibc/set-fakesyscalls.patch +++ b/gpkg/glibc/set-fakesyscalls.patch @@ -81,6 +81,89 @@ index 730059d7..23ec12ad 100644 - return SYSCALL_CANCEL (open_by_handle_at, mount_fd, handle, flags); + return syscall (__NR_open_by_handle_at, mount_fd, handle, flags); } +diff --git a/sysdeps/unix/sysv/linux/semctl.c b/sysdeps/unix/sysv/linux/semctl.c +index c57fceab..0da2d1d7 100644 +--- a/sysdeps/unix/sysv/linux/semctl.c ++++ b/sysdeps/unix/sysv/linux/semctl.c +@@ -21,6 +21,7 @@ + #include + #include + #include /* For __kernel_mode_t. */ ++#include + + /* The struct used to issue the syscall. For architectures that assume + 64-bit time as default (!__ASSUME_TIME64_SYSCALLS) the syscall will +@@ -121,7 +122,7 @@ static int + semctl_syscall (int semid, int semnum, int cmd, semctl_arg_t arg) + { + #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS +- return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64, ++ return syscall (__NR_semctl, semid, semnum, cmd | __IPC_64, + arg.array); + #else + return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64, +@@ -388,7 +389,7 @@ __old_semctl (int semid, int semnum, int cmd, ...) + /* For architectures that have wire-up semctl but also have __IPC_64 to a + value different than default (0x0) it means the compat symbol used the + __NR_ipc syscall. */ +- return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd, arg.array); ++ return syscall (__NR_semctl, semid, semnum, cmd, arg.array); + # else + return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd, + SEMCTL_ARG_ADDRESS (arg)); +diff --git a/sysdeps/unix/sysv/linux/semget.c b/sysdeps/unix/sysv/linux/semget.c +index 26d00467..9675de7a 100644 +--- a/sysdeps/unix/sysv/linux/semget.c ++++ b/sysdeps/unix/sysv/linux/semget.c +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + + /* Return identifier for array of NSEMS semaphores associated with + KEY. */ +@@ -27,7 +28,7 @@ int + semget (key_t key, int nsems, int semflg) + { + #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS +- return INLINE_SYSCALL_CALL (semget, key, nsems, semflg); ++ return syscall (__NR_semget, key, nsems, semflg); + #else + return INLINE_SYSCALL_CALL (ipc, IPCOP_semget, key, nsems, semflg, NULL); + #endif +diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c +index 181289fa..e503f813 100644 +--- a/sysdeps/unix/sysv/linux/semtimedop.c ++++ b/sysdeps/unix/sysv/linux/semtimedop.c +@@ -19,15 +19,16 @@ + #include + #include + #include ++#include + + static int + semtimedop_syscall (int semid, struct sembuf *sops, size_t nsops, + const struct __timespec64 *timeout) + { + #ifdef __NR_semtimedop_time64 +- return INLINE_SYSCALL_CALL (semtimedop_time64, semid, sops, nsops, timeout); ++ return syscall (__NR_semtimedop_time64, semid, sops, nsops, timeout); + #elif defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS && defined __NR_semtimedop +- return INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, timeout); ++ return syscall (__NR_semtimedop, semid, sops, nsops, timeout); + #else + return INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, + SEMTIMEDOP_IPC_ARGS (nsops, sops, timeout)); +@@ -59,7 +60,7 @@ __semtimedop64 (int semid, struct sembuf *sops, size_t nsops, + pts32 = &ts32; + } + # ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS +- return INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, pts32); ++ return syscall (__NR_semtimedop, semid, sops, nsops, pts32); + # else + return INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid, + SEMTIMEDOP_IPC_ARGS (nsops, sops, pts32)); diff --git a/sysdeps/unix/sysv/linux/setegid.c b/sysdeps/unix/sysv/linux/setegid.c index 4a608532..e4ff2bc3 100644 --- a/sysdeps/unix/sysv/linux/setegid.c diff --git a/gpkg/glibc/set-sigrestore.patch b/gpkg/glibc/set-sigrestore.patch new file mode 100644 index 000000000..5c51ae1a6 --- /dev/null +++ b/gpkg/glibc/set-sigrestore.patch @@ -0,0 +1,36 @@ +diff --git a/sysdeps/unix/sysv/linux/arm/sigrestorer.S b/sysdeps/unix/sysv/linux/arm/sigrestorer.S +index 6eacc3f4..7d33283d 100644 +--- a/sysdeps/unix/sysv/linux/arm/sigrestorer.S ++++ b/sysdeps/unix/sysv/linux/arm/sigrestorer.S +@@ -16,6 +16,7 @@ + . */ + + #include ++#include + + /* If no SA_RESTORER function was specified by the application we use + one of these. This avoids the need for the kernel to synthesise a return +diff --git a/sysdeps/unix/sysv/linux/i386/libc_sigaction.c b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c +index 9d225d5e..70dcf24c 100644 +--- a/sysdeps/unix/sysv/linux/i386/libc_sigaction.c ++++ b/sysdeps/unix/sysv/linux/i386/libc_sigaction.c +@@ -18,6 +18,7 @@ + + #include + #include ++#include + + #define SA_RESTORER 0x04000000 + +diff --git a/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c b/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c +index b39812f8..59c6b490 100644 +--- a/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c ++++ b/sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c +@@ -17,6 +17,7 @@ + . */ + + #include ++#include + #define SA_RESTORER 0x04000000 + + extern void restore_rt (void) asm ("__restore_rt") attribute_hidden; diff --git a/gpkg/glibc/sigrestorer.S.patch b/gpkg/glibc/sigrestorer.S.patch deleted file mode 100644 index 7f0982fca..000000000 --- a/gpkg/glibc/sigrestorer.S.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- glibc-2.39/sysdeps/unix/sysv/linux/arm/sigrestorer.S 2024-01-31 03:34:58.000000000 +0300 -+++ glibc-2.39/sysdeps/unix/sysv/linux/arm/sigrestorer.S.patch 2024-09-01 15:21:37.555593719 +0300 -@@ -16,6 +16,7 @@ - . */ - - #include -+#include - - /* If no SA_RESTORER function was specified by the application we use - one of these. This avoids the need for the kernel to synthesise a return