termux-pacman / glibc-packages

Glibc packages for termux
MIT License
134 stars 19 forks source link

Compile Glibc #216

Closed BloodANGELdb closed 8 months ago

BloodANGELdb commented 8 months ago

Can I compile glibc_arch64 so that the prefix is ​​for example /data/data/com.termux/files/usr/glibb? all my attempts are unsuccessful, glibc compiles well, I get a bad system call

Maxython commented 8 months ago

Why would you want to compile glibc with a different prefix?

So I understand that you tried to compile glibc without patches, because you are getting bad system calls. This is incorrect because glibc by default is not configured to work in the android Termux application.

BloodANGELdb commented 8 months ago

Why would you want to compile glibc with a different prefix?

So I understand that you tried to compile glibc without patches, because you are getting bad system calls. This is incorrect because glibc by default is not configured to work in the android Termux application.

I want to build glibc for testing so that it does not interfere with the operation of glibc_termux_pacman. If this is not a problem, could you suggest which patches I should use for this?

Maxython commented 8 months ago

You can compile glibc with a different prefix using build-package.sh, but with one change:

--- a/scripts/build/termux_step_setup_variables.sh
+++ b/scripts/build/termux_step_setup_variables.sh
@@ -36,7 +36,7 @@ termux_step_setup_variables() {
        fi

        if [ "$TERMUX_PACKAGE_LIBRARY" = "glibc" ]; then
-               export TERMUX_PREFIX="$TERMUX_PREFIX/glibc"
+               export TERMUX_PREFIX="$TERMUX_PREFIX/test-glibc"
                if ! package__is_package_name_have_glibc_prefix "$TERMUX_PKG_NAME"; then
                        TERMUX_PKG_NAME="$(package__add_prefix_glibc_to_package_name ${TERMUX_PKG_NAME})"
                fi

To start glibc compilation you must run the following command:

./build-package.sh -s -f --library glibc gpkg/glibc
BloodANGELdb commented 8 months ago

To start glibc compilation you must run the following command:

./build-package.sh -s -f --library glibc gpkg/glibc

Thanks a lot. I'm sorry, but I don't fully understand how to do this? What procedure should be followed to use build-package?

Maxython commented 8 months ago

To start using build-package.sh to compile glibc packages, you must issue the following commands:

# installing required packages
# - if you are using apt
apt install glibc-repo
apt install glibc-runner gcc-glibc python-glibc git
# - if you are using pacman
pacman -Syu glibc-runner gcc-glibc python-glibc git

# cloning termux-pacman/glibc-packages repo
git clone https://github.com/termux-pacman/glibc-packages.git
cd glibc-packages

# preparation for compilation
./get-build-package.sh
# - change prefix 
nano scripts/build/termux_step_setup_variables.sh

# starting the compiler
./build-package.sh -s -f --library glibc gpkg/glibc

# the final package will be stored in the output folder
ls ./output
BloodANGELdb commented 8 months ago
--- a/scripts/build/termux_step_setup_variables.sh
+++ b/scripts/build/termux_step_setup_variables.sh
@@ -36,7 +36,7 @@ termux_step_setup_variables() {
        fi

        if [ "$TERMUX_PACKAGE_LIBRARY" = "glibc" ]; then
-               export TERMUX_PREFIX="$TERMUX_PREFIX/glibc"
+               export TERMUX_PREFIX="$TERMUX_PREFIX/test-glibc"
                if ! package__is_package_name_have_glibc_prefix "$TERMUX_PKG_NAME"; then
                        TERMUX_PKG_NAME="$(package__add_prefix_glibc_to_package_name ${TERMUX_PKG_NAME})"
                fi

compilation succeeds if export TERMUX_PREFIX="$TERMUX_PREFIX/glibc" . but as soon as I change this line to export TERMUX_PREFIX="$TERMUX_PREFIX/glibc-test" I get the following error

Screenshot_2024-03-21-16-42-02-286_com.termux-edit.jpg

Maxython commented 8 months ago

I double-checked what needed to be configured in the compiler and created a patch. To use it you need to put it in your repo and perform the following steps:

./get-build-package.sh
git apply < change_prefix.txt

The patch itself: change_prefix.txt

BloodANGELdb commented 8 months ago

I double-checked what needed to be configured in the compiler and created a patch. To use it you need to put it in your repo and perform the following steps:

Thanks, now the compilation ends with this error

Screenshot_2024-03-22-13-50-02-441_com.termux-edit.jpg

Maxython commented 8 months ago

Thanks, now the compilation ends with this error

--- a/gpkg/glibc/build.sh
+++ b/gpkg/glibc/build.sh
@@ -76,7 +76,7 @@ termux_step_make() {
        make -O
        make info

-       elf/ld.so --library-path "$PWD" locale/localedef -c -f ${TERMUX_PKG_SRCDIR}/localedata/charmaps/UTF-8 -i ${TERMUX_PKG_SRCDIR}/localedata/locales/C ./C.UTF-8/
+       localedef -c -f ${TERMUX_PKG_SRCDIR}/localedata/charmaps/UTF-8 -i ${TERMUX_PKG_SRCDIR}/localedata/locales/C ./C.UTF-8/
 }

 termux_step_make_install() {
BloodANGELdb commented 8 months ago

Thank you very much, everything worked out)