Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: cross-compilation implementation (compilation of 32-bit programs for 64-bit arch) #20864

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Maxython
Copy link
Member

@Maxython Maxython commented Jul 15, 2024

Main: this PR implements a scheme for building 32-bit programs for 64-bit archs (i.e. arm programs for aarch64 and i686 programs for x86_64). Such cross-compilation will definitely be relevant for building some glibc packages. Possibly for bionic packages too (although I have not seen such requests), but more tests are needed for this.

First words (relevant but not the most important): a package with the glibc32 prefix in its name is a package that is compiled on a 32-bit architecture standard but will run on a 64-bit device

@Maxython Maxython force-pushed the adding-glibc32-prefix branch from c51636f to cf462ce Compare August 16, 2024 17:43
@twaik
Copy link
Member

twaik commented Oct 19, 2024

The branch has conflicts.

@Maxython Maxython force-pushed the adding-glibc32-prefix branch 3 times, most recently from b51e5b9 to 0d6395c Compare October 21, 2024 12:17
@Maxython Maxython force-pushed the adding-glibc32-prefix branch 3 times, most recently from b5a9764 to 017ab21 Compare December 30, 2024 22:49
@Maxython Maxython changed the title scripts: changing glibc-based package name checking scripts: cross-compilation implementation (compilation of 32-bit programs for 64-bit arch) Dec 31, 2024
@Maxython
Copy link
Member Author

Test build - termux-pacman/glibc-packages#317

@Maxython Maxython force-pushed the adding-glibc32-prefix branch from 017ab21 to 808b56f Compare January 3, 2025 17:32
@Maxython Maxython marked this pull request as ready for review January 3, 2025 18:27
@Maxython Maxython requested a review from Grimler91 as a code owner January 3, 2025 18:27
@Maxython Maxython force-pushed the adding-glibc32-prefix branch 2 times, most recently from 3646db5 to bc819a8 Compare January 3, 2025 22:50
TERMUX_PKG_BUILD32=false
fi
if [ "$TERMUX_PKG_BUILD_IN_SRC" = "true" ] && [ "$TERMUX_PKG_BUILD32" = "true" ]; then
termux_error_exit "It is not possible to build 32-bit and 64-bit versions of a package in one place, the build location must be separate."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it have to be a separate directory? Why can't the same folder be used for both 64bit and 32bit builds?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If all built components (64-bit and 32-bit) of the package are stored in one directory, this can lead to component confusion. Which in turn can break the build of the package.

if [ "$TERMUX_PKG_BUILD32" = "true" ]; then
(
termux_step_setup_build32_environment
termux_step_make_install32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like termux_step_configure, termux_step_make and termux_step_make_install are run twice if the 32 variants are not overridden. Is that intended?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's how it's intended. This is implemented to optimize (i.e. not increase) build.sh scripts, since most of the cross-build stages are not very different from the regular build (except for the variables), and also so that with cross-functions it would be possible to reconfigure the cross-build stages if necessary. That is, to put it simply: if there is a possibility to optimize, then optimize. And if not, then configure this cross-assembly in detail (here everything depends on the package). Here is an example of the build.sh script of the glibc package, for better understanding.

Note: Please note that all cross functions are run in a slightly modified environment so that they can work correctly (i.e. perform cross compilation).

@Maxython Maxython force-pushed the adding-glibc32-prefix branch 4 times, most recently from 06d0b55 to fcb3e09 Compare January 24, 2025 11:47
@Maxython Maxython requested a review from TomJo2000 as a code owner January 24, 2025 11:59
@Maxython Maxython force-pushed the adding-glibc32-prefix branch 4 times, most recently from c14f524 to 214ccd0 Compare January 24, 2025 13:20
@Maxython
Copy link
Member Author

improved cross compilation based on bionic library

@Maxython Maxython requested a review from Grimler91 January 24, 2025 13:21
…rams for 64-bit arch)

- New variables have been implemented:
 - TERMUX_PKG_BUILD32 - enables or disables cross-compilation of the package
 - TERMUX_PKG_BUILD32DIR - path to compiled cross-package components
 - TERMUX_LIB64_PATH - 64-bit library path
 - TERMUX_LIB32_PATH - 32-bit library path
 - TERMUX_LIB_PATH - path to the library which changes depending on the compilation type (non-cross - TERMUX_LIB64_PATH, cross - TERMUX_LIB32_PATH)
- Implemented cross functions (termux_step_configure32, termux_step_make32 and termux_step_make_install32).
- The application environment setup scheme has been updated to ensure that cgct works properly. It now sets up temporary glibc, glibc32 packages, and libgcc symbolic links from cgct when needed. The updated scheme also allows forks to easily build glibc packages for their applications.
- The glibc package naming standard has been updated, now glibc packages can be named with the "glibc32" prefix.
@Maxython Maxython force-pushed the adding-glibc32-prefix branch from 214ccd0 to d13b79d Compare January 25, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants