Skip to content

Commit

Permalink
new packages: gpkg-dev/cgt and gpkg-dev/cbt (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxython authored Jul 20, 2023
1 parent 165ead3 commit 8cd7466
Show file tree
Hide file tree
Showing 12 changed files with 473 additions and 21 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ jobs:
il=(${i//// })
if [ "${il[0]}" = "gpkg-dev" ]; then
if [ -d "${il[0]}/${il[1]}" ]; then
echo "${il[1]}" >> "pkgs/gpkg-dev-need.txt"
curl -L "https://raw.githubusercontent.com/termux-pacman/glibc-packages/$(git log -n 2 --format=format:%H gpkg-dev/${il[1]} | tail -1)/gpkg-dev/${il[1]}/PKGBUILD" -o pkgs/PKGBUILDs/${il[1]}
if [ ! -f pkgs/gpkg-dev-need.txt ] || ! $(grep -q '^'${il[1]}'$' pkgs/gpkg-dev-need.txt); then
echo "${il[1]}" >> pkgs/gpkg-dev-need.txt
curl -L "https://raw.githubusercontent.com/termux-pacman/glibc-packages/$(git log -n 2 --format=format:%H gpkg-dev/${il[1]} | tail -1)/gpkg-dev/${il[1]}/PKGBUILD" -o pkgs/PKGBUILDs/${il[1]}
fi
else
echo "${il[1]}" >> "pkgs/deleted_gpkg-dev_packages.txt"
echo "${il[1]}" >> pkgs/deleted_gpkg-dev_packages.txt
fi
fi
done
Expand Down
58 changes: 58 additions & 0 deletions gpkg-dev/cbt/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
pkgname=cbt
pkgver=2.40
pkgrel=0
pkgdesc='Cross Binutils for Termux (only for Linux)'
arch=(x86_64)
url='https://www.gnu.org/software/binutils/'
license=('GPL3' 'GPL' 'FDL1.3' 'custom:FSFAP')
source=(https://ftp.gnu.org/gnu/binutils/binutils-$pkgver.tar.xz)
sha256sums=('0f8a4c272d7f17f369ded10a4aca28b8e304828e95526da482b0ccc4dfc9d8e1')
groups=('cgct')

build() {
unset CFLAGS CXXFLAGS AR LD CC CXX
CFLAGS="-O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fstack-clash-protection"
CXXFLAGS="${CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS"

for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do
arch_build=${target/-*}
CGCT_PREFIX="${DIR_TERMUX}/cgct/${arch_build}"
mkdir binutils-${arch_build}
cd binutils-${arch_build}

"$srcdir"/binutils-${pkgver}/configure \
--target=$target \
--prefix=$CGCT_PREFIX \
--disable-multilib \
--with-gnu-as \
--with-gnu-ld \
--disable-nls \
--enable-ld=default \
--enable-plugins \
--enable-deterministic-archives
make

cd ..
done
}

package() {
for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do
arch_build=${target/-*}
CGCT_PREFIX="${DIR_TERMUX}/cgct/${arch_build}"
cd binutils-${arch_build}

make DESTDIR="$pkgdir" install

mv $pkgdir/${CGCT_PREFIX}/$target/bin/* $pkgdir/${CGCT_PREFIX}/bin
mv $pkgdir/${CGCT_PREFIX}/$target/lib/* $pkgdir/${CGCT_PREFIX}/lib
rm -fr $pkgdir/${CGCT_PREFIX}/$target
rm -fr $pkgdir/${CGCT_PREFIX}/share
rm -fr $pkgdir/${CGCT_PREFIX}/include
rm -fr $pkgdir/${CGCT_PREFIX}/etc

cd ..
done

replace_hard_with_symbolic "$pkgdir"
}
134 changes: 134 additions & 0 deletions gpkg-dev/cgt/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
pkgname=cgt
pkgver=13.1.0
pkgrel=0
pkgdesc='Cross GCCs for Termux (only for Linux)'
arch=(x86_64)
url='https://gcc.gnu.org/'
license=(GPL LGPL FDL)
source=(https://ftp.gnu.org/gnu/gcc/gcc-$pkgver/gcc-$pkgver.tar.xz
collect2.cc.patch
gcc.cc.patch
gcc-Makefile.in.patch
gcc-configure.patch
set_glibc_dynamic_linker.patch)
sha256sums=('61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86'
'102f7791ace23391eef292efd0ba193cd05421ad02b7b6ca25bc5f9422ec3d96'
'205bbdd2dee34e9d83a892c1985c25cf2d20089cc0497b74dbff019436148873'
'ac3f2b2b225d3464c9c600f2042cf2f115cb5053c611a5f69ad4095f65fa9aaf'
'344cb82c63326bab5e7200a0a0f017a00b15c2c440497752fd8946c12c83beb6'
'7c4e3f5f31ed59beee30aa40675b339a6d6b05b3d46b98a2f468bb4db95075c4')
groups=('cgct')

prepare() {
for i in *.patch; do
patch -Np1 -i ${srcdir}/$i
done

cd gcc-${pkgver}
sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
sed -i '/m64=/s/lib64/lib/' gcc/config/i386/t-linux64
sed -i '/lp64=/s/lib64/lib/' gcc/config/aarch64/t-aarch64-linux
}

build() {
unset CFLAGS CXXFLAGS AR LD CC CXX
CFLAGS="-O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fstack-clash-protection"
CXXFLAGS="${CFLAGS} -Wp,-D_GLIBCXX_ASSERTIONS"

for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do
arch_build=${target/-*}
CGCT_PREFIX=${DIR_TERMUX}/cgct/${arch_build}
mkdir gcc-${arch_build}
cd gcc-${arch_build}

REPO_URL="${GPKG_DEV_SERVER_URL}/gpkg-dev/${arch_build}"
curl "${REPO_URL}/gpkg-dev.json" -o gpkg-dev.json
for i in glibc linux-api-headers libxcrypt-glibc; do
FILENAME=$(cat gpkg-dev.json | jq -r '."'$i'"."FILENAME"')
curl "${REPO_URL}/$FILENAME" -o $i.tar.xz
tar xJf $i.tar.xz -C / data
done

FLAGS_FOR_TARGET="-I$GLIBC_PREFIX/include -L$GLIBC_PREFIX/lib -Wl,-rpath=$GLIBC_PREFIX/lib"
CONFIGFLAG=""
case "$arch_build" in
"aarch64") CONFIGFLAG="--with-arch=armv8-a --enable-fix-cortex-a53-835769 --enable-fix-cortex-a53-843419";;
"arm") CONFIGFLAG="--with-arch=armv7-a --with-float=hard --with-fpu=neon";;
"x86_64") CONFIGFLAG="--with-arch=x86-64";;
"i686") CONFIGFLAG="--with-arch=i686 --with-as=/usr/bin/i686-elf-as --with-ld=/usr/bin/i686-elf-ld AR_FOR_TARGET=/usr/bin/i686-elf-ar RANLIB_FOR_TARGET=/usr/bin/i686-elf-ranlib NM_FOR_TARGET=/usr/bin/i686-elf-nm";;
esac

"$srcdir"/gcc-${pkgver}/configure \
--host=${CHOST} \
--build=${CHOST} \
--target=${target} \
--prefix=${CGCT_PREFIX} \
--with-local-prefix=${CGCT_PREFIX} \
--libdir=${CGCT_PREFIX}/lib \
--libexecdir=${CGCT_PREFIX}/lib \
--includedir=${GLIBC_PREFIX}/include \
--with-bugurl=https://github.com/termux-pacman/glibc-packages/issues \
$CONFIGFLAG \
--enable-languages=c,c++ \
--enable-checking=release \
--enable-threads=posix \
--enable-lto \
--disable-multilib \
--disable-bootstrap \
--disable-nls \
--enable-clocale=gnu \
--enable-default-pie \
--enable-default-ssp \
--with-system-zlib \
--enable-__cxa_atexit \
--enable-linker-build-id \
--enable-plugin \
--with-linker-hash-style=gnu \
--enable-gnu-indirect-function \
--enable-gnu-unique-object \
--enable-shared \
--disable-werror \
--disable-libssp \
--disable-libstdcxx-pch \
--disable-libunwind-exceptions \
CFLAGS_FOR_TARGET="$FLAGS_FOR_TARGET $CFLAGS" \
CXXFLAGS_FOR_TARGET="$FLAGS_FOR_TARGET $CXXFLAGS"
make

cd ..
rm -fr /data/data
done
}

package() {
for target in aarch64-linux-gnu arm-linux-gnueabihf x86_64-linux-gnu i686-linux-gnu; do
arch_build=${target/-*}
CGCT_PREFIX=${DIR_TERMUX}/cgct/${arch_build}
cd gcc-${arch_build}

for i in glibc linux-api-headers libxcrypt-glibc; do
tar xJf $i.tar.xz -C / data
done

make DESTDIR="$pkgdir" install-gcc install-target-{libgcc,libstdc++-v3,libgomp,libquadmath,libatomic}

if [ -d $pkgdir/${CGCT_PREFIX}/$target/lib ]; then
mv $pkgdir/${CGCT_PREFIX}/$target/lib/* $pkgdir/${CGCT_PREFIX}/lib
fi
if [ -d $pkgdir/${CGCT_PREFIX}/$target/include ]; then
mv $pkgdir/${CGCT_PREFIX}/$target/include/* $pkgdir/${CGCT_PREFIX}/include
fi
if [ -d $pkgdir/${CGCT_PREFIX}/include/$pkgver ]; then
mkdir $pkgdir/${CGCT_PREFIX}/include/c++
mv $pkgdir/${CGCT_PREFIX}/include/$pkgver $pkgdir/${CGCT_PREFIX}/include/c++
fi
rm -fr $pkgdir/${CGCT_PREFIX}/share
rm -fr $pkgdir/${CGCT_PREFIX}/$target
rm -fr $pkgdir/${DIR_TERMUX}/files

cd ..
rm -fr /data/data
done

replace_hard_with_symbolic "$pkgdir"
}
39 changes: 39 additions & 0 deletions gpkg-dev/cgt/collect2.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--- src/gcc-13.1.0/gcc/collect2.cc 2022-05-06 10:30:56.000000000 +0300
+++ src/gcc-13.1.0/gcc/collect2.cc.patch 2022-07-07 16:22:05.983834993 +0300
@@ -1188,8 +1188,7 @@
prefix_from_env ("LIBPATH", &libpath_lib_dirs);
/* Add to this list also two standard directories where
AIX loader always searches for libraries. */
- add_prefix (&libpath_lib_dirs, "/lib");
- add_prefix (&libpath_lib_dirs, "/usr/lib");
+ add_prefix (&libpath_lib_dirs, "/data/data/com.termux/files/usr/glibc/lib");
#endif

/* Get any options that the upper GCC wants to pass to the sub-GCC.
@@ -2678,20 +2677,12 @@
/* Array of standard AIX libraries which should not
be scanned for ctors/dtors. */
static const char *const aix_std_libs[] = {
- "/unix",
- "/lib/libc.a",
- "/lib/libm.a",
- "/lib/libc_r.a",
- "/lib/libm_r.a",
- "/usr/lib/libc.a",
- "/usr/lib/libm.a",
- "/usr/lib/libc_r.a",
- "/usr/lib/libm_r.a",
- "/usr/lib/threads/libc.a",
- "/usr/ccs/lib/libc.a",
- "/usr/ccs/lib/libm.a",
- "/usr/ccs/lib/libc_r.a",
- "/usr/ccs/lib/libm_r.a",
+ "/data/data/com.termux/files/usr/glibc/lib/unix",
+ "/data/data/com.termux/files/usr/glibc/lib/libc.a",
+ "/data/data/com.termux/files/usr/glibc/lib/libm.a",
+ "/data/data/com.termux/files/usr/glibc/lib/libc_r.a",
+ "/data/data/com.termux/files/usr/glibc/lib/libm_r.a",
+ "/data/data/com.termux/files/usr/glibc/lib/threads/libc.a",
NULL
};

20 changes: 20 additions & 0 deletions gpkg-dev/cgt/gcc-Makefile.in.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- src/gcc-13.1.0/gcc/Makefile.in 2023-07-14 18:39:16.751580302 +0300
+++ src/gcc-13.1.0/gcc/Makefile.in.patch 2023-07-15 22:33:23.067390433 +0300
@@ -689,7 +689,7 @@
# Used in install-cross.
gcc_tooldir = @gcc_tooldir@
# Since gcc_tooldir does not exist at build-time, use -B$(build_tooldir)/bin/
-build_tooldir = $(exec_prefix)/$(target_noncanonical)
+build_tooldir = /data/data/com.termux/files/usr/glibc
# Directory in which the compiler finds target-independent g++ includes.
gcc_gxx_include_dir = @gcc_gxx_include_dir@
gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@
@@ -3067,7 +3067,7 @@
-DGPLUSPLUS_LIBCXX_INCLUDE_DIR=\"$(gcc_gxx_libcxx_include_dir)\" \
-DGPLUSPLUS_LIBCXX_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_libcxx_include_dir_add_sysroot) \
-DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \
- -DCROSS_INCLUDE_DIR=\"$(CROSS_SYSTEM_HEADER_DIR)\" \
+ -DCROSS_INCLUDE_DIR=\"/data/data/com.termux/files/usr/glibc/include\" \
-DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
-DNATIVE_SYSTEM_HEADER_DIR=\"$(NATIVE_SYSTEM_HEADER_DIR)\" \
-DPREFIX=\"$(prefix)/\" \
22 changes: 22 additions & 0 deletions gpkg-dev/cgt/gcc-configure.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- src/gcc-13.1.0/gcc/configure 2023-04-26 10:11:18.000000000 +0300
+++ src/gcc-13.1.0/gcc/configure.patch 2023-07-16 13:12:24.569064972 +0300
@@ -3734,9 +3734,6 @@
gcc_gxx_include_dir='${libsubdir}/include/c++'
else
libstdcxx_incdir='include/c++/$(version)'
- if test x$host != x$target; then
- libstdcxx_incdir="$target_alias/$libstdcxx_incdir"
- fi
gcc_gxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libstdcxx_incdir"
fi
elif test "${with_sysroot+set}" = set; then
@@ -3780,9 +3777,6 @@
gcc_gxx_libcxx_include_dir='${libsubdir}/libc++_include/c++/v1'
else
libcxx_incdir='libc++_include/c++/$(version)/v1'
- if test x$host != x$target; then
- libcxx_incdir="$target_alias/$libcxx_incdir"
- fi
gcc_gxx_libcxx_include_dir="\$(libsubdir)/\$(libsubdir_to_prefix)$libcxx_incdir"
fi
elif test "${with_sysroot+set}" = set; then
55 changes: 55 additions & 0 deletions gpkg-dev/cgt/gcc.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
--- src/gcc-13.1.0/gcc/gcc.cc 2023-04-26 10:09:40.000000000 +0300
+++ src/gcc-13.1.0/gcc/gcc.cc.patch 2023-07-14 19:53:28.743169982 +0300
@@ -1585,10 +1585,7 @@
/* Default prefixes to attach to command names. */

#ifndef STANDARD_STARTFILE_PREFIX_1
-#define STANDARD_STARTFILE_PREFIX_1 "/lib/"
-#endif
-#ifndef STANDARD_STARTFILE_PREFIX_2
-#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
+#define STANDARD_STARTFILE_PREFIX_1 "/data/data/com.termux/files/usr/glibc/lib/"
#endif

#ifdef CROSS_DIRECTORY_STRUCTURE /* Don't use these prefixes for a cross compiler. */
@@ -1625,10 +1622,7 @@
static const char *md_exec_prefix = MD_EXEC_PREFIX;
static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
-static const char *const standard_startfile_prefix_1
- = STANDARD_STARTFILE_PREFIX_1;
-static const char *const standard_startfile_prefix_2
- = STANDARD_STARTFILE_PREFIX_2;
+static const char *const standard_startfile_prefix_1 = STANDARD_STARTFILE_PREFIX_1;

/* A relative path to be used in finding the location of tools
relative to the driver. */
@@ -8409,7 +8403,7 @@
}
/* We should eventually get rid of all these and stick to
startfile_prefix_spec exclusively. */
- else if (*cross_compile == '0' || target_system_root)
+ else
{
if (*md_startfile_prefix)
add_sysrooted_prefix (&startfile_prefixes, md_startfile_prefix,
@@ -8430,7 +8424,7 @@
add_sysrooted_prefix (&startfile_prefixes,
standard_startfile_prefix, "BINUTILS",
PREFIX_PRIORITY_LAST, 0, 1);
- else if (*cross_compile == '0')
+ else
{
add_prefix (&startfile_prefixes,
concat (gcc_exec_prefix
@@ -8446,10 +8440,6 @@
add_sysrooted_prefix (&startfile_prefixes,
standard_startfile_prefix_1, "BINUTILS",
PREFIX_PRIORITY_LAST, 0, 1);
- if (*standard_startfile_prefix_2)
- add_sysrooted_prefix (&startfile_prefixes,
- standard_startfile_prefix_2, "BINUTILS",
- PREFIX_PRIORITY_LAST, 0, 1);
}

/* Process any user specified specs in the order given on the command
Loading

0 comments on commit 8cd7466

Please sign in to comment.