Afaik, di gcc, Anda dapat mengatur -m32
flag untuk membiarkannya mengkompilasi sumber linux ke executable 32bit. Saya tidak memiliki pengetahuan luas tentang Makefiles, tetapi Anda dapat mengubah mereka.
sunting:
Saya ingin menambahkan pertanyaan dari stackoverflow di sini, di mana ia diberi tahu untuk mengatur cflags:
export CFLAGS=-m32
Dan dari repositori linux di akun github Torvalds , saya menemukan bagian berikut di makefile utama yang mungkin berguna bagi Anda, karena memberitahu Anda dapat mengatur arsitektur target dengan mengatur variabel lingkungan. Baca komentar, saat ini, baris ini dari file ini , antara baris 174-196 :
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
# When performing cross compilation for other architectures ARCH shall be set
# to the target architecture. (See arch/* for the possibilities).
# ARCH can be set during invocation of make:
# make ARCH=ia64
# Another way is to have ARCH set in the environment.
# The default ARCH is the host where make is executed.
# CROSS_COMPILE specify the prefix used for all executables used
# during compilation. Only gcc and related bin-utils executables
# are prefixed with $(CROSS_COMPILE).
# CROSS_COMPILE can be set on the command line
# make CROSS_COMPILE=ia64-linux-
# Alternatively CROSS_COMPILE can be set in the environment.
# A third alternative is to store a setting in .config so that plain
# "make" in the configured kernel build directory always uses that.
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
# ...
# There are more architecture related stuff beyond this line