Merge pull request #21552 from jefferyto/python-platform-triplet

python3: Restore platform triplet to paths
This commit is contained in:
Alexandru Ardelean 2023-08-31 07:59:57 +03:00 committed by GitHub
commit 11ae2c3061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 852 additions and 262 deletions

View File

@ -1,45 +1,140 @@
#!/bin/sh
set -e
process_filespec() {
local src_dir="$1"
local dst_dir="$2"
local filespec="$3"
echo "$filespec" | (
IFS='|'
while read fop fspec fperm; do
local fop=`echo "$fop" | tr -d ' \t\n'`
if [ "$fop" = "+" ]; then
if [ ! -e "${src_dir}${fspec}" ]; then
echo "File not found '${src_dir}${fspec}'"
exit 1
fi
dpath=`dirname "$fspec"`
if [ -z "$fperm" ]; then
dperm=`stat -c "%a" ${src_dir}${dpath}`
fi
mkdir -p -m$dperm ${dst_dir}${dpath}
echo "copying: '$fspec'"
cp -fpR ${src_dir}${fspec} ${dst_dir}${dpath}/
if [ -n "$fperm" ]; then
chmod -R $fperm ${dst_dir}${fspec}
fi
elif [ "$fop" = "-" ]; then
echo "removing: '$fspec'"
rm -fR ${dst_dir}${fspec}
elif [ "$fop" = "=" ]; then
echo "setting permissions: '$fperm' on '$fspec'"
chmod -R $fperm ${dst_dir}${fspec}
fi
done
)
log() {
printf '%s\n' "$*"
}
src_dir="$1"
dst_dir="$2"
error() {
printf 'Error: %s\n' "$*" >&2
}
path_exists() {
local dir="$1"
local path="$2"
[ -n "$(find "$dir"/$path -print -quit 2>/dev/null)" ]
}
file_dir_chmod() {
local dir="$1"
local path="$2"
local file_mode="$3"
local dir_mode="$4"
shift; shift; shift; shift;
if [ -n "$file_mode" ]; then
find "$dir"/$path -type f "$@" -exec chmod "$file_mode" -- '{}' +
fi
if [ -n "$dir_mode" ]; then
find "$dir"/$path -type d "$@" -exec chmod "$dir_mode" -- '{}' +
fi
}
src="$1"
dest="$2"
filespec="$3"
process_filespec "$src_dir" "$dst_dir" "$filespec" || {
echo "process filespec error-ed"
if [ -z "$src" ]; then
error "Missing source directory"
exit 1
}
fi
if [ -z "$dest" ]; then
error "Missing destination directory"
exit 1
fi
while IFS='|' read -r cmd path file_mode dir_mode; do
# trim whitespace
cmd="${cmd#"${cmd%%[![:space:]]*}"}"
cmd="${cmd%"${cmd##*[![:space:]]}"}"
path="${path#"${path%%[![:space:]]*}"}"
path="${path%"${path##*[![:space:]]}"}"
file_mode="${file_mode#"${file_mode%%[![:space:]]*}"}"
file_mode="${file_mode%"${file_mode##*[![:space:]]}"}"
dir_mode="${dir_mode#"${dir_mode%%[![:space:]]*}"}"
dir_mode="${dir_mode%"${dir_mode##*[![:space:]]}"}"
if [ -z "$cmd" ] || [ "$cmd" != "${cmd#\#}" ]; then
continue
fi
if [ -z "$path" ]; then
error "Missing path for \"$cmd\""
exit 1
fi
case "$cmd" in
+)
log "Copying: \"$path\""
if ! path_exists "$src" "$path"; then
error "\"$src/$path\" not found"
exit 1
fi
dir="${path%/*}"
mkdir -p "$dest/$dir"
cp -fpR "$src"/$path "$dest/$dir/"
file_dir_chmod "$dest" "$path" "$file_mode" "$dir_mode"
;;
-)
log "Removing: \"$path\""
if ! path_exists "$dest" "$path"; then
error "\"$dest/$path\" not found"
exit 1
fi
rm -fR -- "$dest"/$path
;;
=)
log "Setting recursive permissions \"${file_mode:-(none)}\"/\"${dir_mode:-(none)}\" on \"$path\""
if ! path_exists "$dest" "$path"; then
error "\"$dest/$path\" not found"
exit 1
fi
if [ -z "$file_mode$dir_mode" ]; then
error "Missing recursive permissions for \"$path\""
exit 1
fi
file_dir_chmod "$dest" "$path" "$file_mode" "$dir_mode"
;;
==)
log "Setting permissions \"${file_mode:-(none)}\"/\"${dir_mode:-(none)}\" on \"$path\""
if ! path_exists "$dest" "$path"; then
error "\"$dest/$path\" not found"
exit 1
fi
if [ -z "$file_mode$dir_mode" ]; then
error "Missing permissions for \"$path\""
exit 1
fi
file_dir_chmod "$dest" "$path" "$file_mode" "$dir_mode" -maxdepth 0
;;
*)
error "Unknown command \"$cmd\""
exit 1
;;
esac
done << EOF
$filespec
EOF

View File

@ -20,7 +20,7 @@ PYTHON3:=python$(PYTHON3_VERSION)
PYTHON3PATH:=$(PYTHON3_LIB_DIR):$(STAGING_DIR)/$(PYTHON3_PKG_DIR):$(PKG_INSTALL_DIR)/$(PYTHON3_PKG_DIR)
-include $(PYTHON3_LIB_DIR)/config-$(PYTHON3_VERSION)/Makefile-vars
-include $(PYTHON3_LIB_DIR)/openwrt/Makefile-vars
# These configure args are needed in detection of path to Python header files
# using autotools.
@ -39,6 +39,7 @@ PYTHON3_VARS = \
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PYTHON3_INC_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS) -lpython$(PYTHON3_VERSION)" \
_PYTHON_HOST_PLATFORM="$(_PYTHON_HOST_PLATFORM)" \
_PYTHON_SYSCONFIGDATA_NAME="_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH)" \
PYTHONPATH="$(PYTHON3PATH)" \
PYTHONDONTWRITEBYTECODE=1 \
_python_sysroot="$(STAGING_DIR)" \

View File

@ -11,7 +11,7 @@ include $(TOPDIR)/rules.mk
include ../python3-version.mk
PKG_NAME:=python3
PKG_RELEASE:=1
PKG_RELEASE:=3
PKG_VERSION:=$(PYTHON3_VERSION).$(PYTHON3_VERSION_MICRO)
PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
@ -31,7 +31,6 @@ PYTHON3_PKG_BUILD:=0
include ../python3-package.mk
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
HOST_BUILD_PARALLEL:=1
# LTO is handled here individually, see --with-lto below
@ -51,44 +50,52 @@ define Package/python3/Default
SUBMENU:=Python
SECTION:=lang
CATEGORY:=Languages
TITLE:=Python $(PYTHON3_VERSION) programming language
TITLE:=Python $(PYTHON3_VERSION)
URL:=https://www.python.org/
endef
define Package/python3/Default/description
Python is a dynamic object-oriented programming language that can be used
for many kinds of software development. It offers strong support for
integration with other languages and tools, comes with extensive standard
libraries, and can be learned in a few days. Many Python programmers
report substantial productivity gains and feel the language encourages
the development of higher quality, more maintainable code.
Python is an interpreted, interactive, object-oriented programming
language. It incorporates modules, exceptions, dynamic typing, very high
level dynamic data types, and classes. It supports multiple programming
paradigms beyond object-oriented programming, such as procedural and
functional programming. Python combines remarkable power with very clear
syntax. It has interfaces to many system calls and libraries, as well as
to various window systems, and is extensible in C or C++. It is also
usable as an extension language for applications that need a
programmable interface. Finally, Python is portable: it runs on many
Unix variants including Linux and macOS, and on Windows.
endef
define Package/libpython3
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) core library
TITLE+= core library
DEPENDS:=+libpthread
ABI_VERSION:=$(PYTHON3_VERSION)
endef
define Package/libpython3/description
This package contains only core Python library.
$(call Package/python3/Default/description)
This package contains only core Python library.
endef
define Package/python3-base
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) interpreter
TITLE+= base interpreter
DEPENDS:=+libpython3
endef
define Package/python3-base/description
This package contains only the interpreter and the bare minimum
for the interpreter to start.
$(call Package/python3/Default/description)
This package contains only the interpreter and the bare minimum for the
interpreter to start.
endef
define Package/python3-light
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) light installation
TITLE+= light installation
DEPENDS:=+python3-base +libbz2 +zlib
endef
@ -97,14 +104,15 @@ define Package/python3-light/config
endef
define Package/python3-light/description
This package is essentially the python3-base package plus
a few of the rarely used (and big) libraries stripped out
into separate packages.
$(call Package/python3/Default/description)
This package installs the base interpreter package and contains the most
commonly used parts of the standard library.
endef
PYTHON3_LIB_FILES_DEL:=
PYTHON3_PACKAGES:=
PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR).so
PYTHON3_SO_SUFFIX:=cpython-$(PYTHON3_VERSION_MAJOR)$(PYTHON3_VERSION_MINOR)-*.so
PYTHON3_PACKAGES_DEPENDS:=
define Py3BasePackage
PYTHON3_PACKAGES+=$(1)
@ -112,13 +120,15 @@ define Py3BasePackage
PYTHON3_PACKAGES_DEPENDS+=$(1)
endif
PYTHON3_LIB_FILES_DEL+=$(2)
define Py3Package/$(1)/filespec
ifneq ($(2),)
$(subst $(space),$(newline),$(foreach lib_file,$(2),+|$(lib_file)))
-|/usr/lib/python$(PYTHON3_VERSION)/*/test
-|/usr/lib/python$(PYTHON3_VERSION)/*/tests
endif
endef
ifeq ($(2),)
Py3Package/$(1)/filespec=
else
define Py3Package/$(1)/filespec
$(foreach lib_file,$(2),
+|$(lib_file)
)
endef
endif
Py3Package/$(1)/install?=:
endef
@ -126,16 +136,19 @@ include ./files/python3-package-*.mk
define Package/python3
$(call Package/python3/Default)
TITLE+= programming language
DEPENDS:=+python3-light $(foreach package,$(PYTHON3_PACKAGES_DEPENDS),+$(package))
endef
define Package/python3/description
This package contains the (almost) full Python install.
It's python3-light + all other packages.
$(call Package/python3/Default/description)
This package installs almost all parts of the standard Python
installation.
endef
# Set READELF here so that the exact same readelf program name can be
# replaced in _sysconfigdata.py (in Py3Package/python3-base/install)
# replaced in _sysconfigdata_*.py (in Build/Install)
TARGET_CONFIGURE_OPTS+= \
READELF="$(TARGET_CROSS)readelf"
@ -183,23 +196,38 @@ CONFIGURE_ARGS += \
$(if $(CONFIG_IPV6),--enable-ipv6) \
$(if $(findstring mips,$(CONFIG_ARCH)),,--with-lto)
define Build/Install
$(call Build/Install/Default,)
$(SED) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata_*.py \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)-*/Makefile
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
$(INSTALL_DIR) $(2)/bin
$(INSTALL_DIR) $(1)/usr/include
$(CP) \
$(PKG_INSTALL_DIR)/usr/include/python$(PYTHON3_VERSION) \
$(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION) \
$(PKG_INSTALL_DIR)/usr/lib/libpython$(PYTHON3_VERSION).so* \
$(1)/usr/lib/
grep \
'^_PYTHON_HOST_PLATFORM=' \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile > \
$(1)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile-vars
$(INSTALL_DIR) $(1)/usr/lib/python$(PYTHON3_VERSION)/openwrt
grep -E \
'^(_PYTHON_HOST_PLATFORM|ABIFLAGS|MACHDEP|MULTIARCH)=' \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)-*/Makefile > \
$(1)/usr/lib/python$(PYTHON3_VERSION)/openwrt/Makefile-vars
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) \
$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/python*.pc \
$(1)/usr/lib/pkgconfig
$(INSTALL_DIR) $(2)/bin
$(INSTALL_BIN) \
$(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config \
$(2)/bin/
@ -212,7 +240,7 @@ PYTHON3_BASE_LIB_FILES:= \
/usr/lib/python$(PYTHON3_VERSION)/encodings \
/usr/lib/python$(PYTHON3_VERSION)/_collections_abc.py \
/usr/lib/python$(PYTHON3_VERSION)/_sitebuiltins.py \
/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py \
/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata_*.py \
/usr/lib/python$(PYTHON3_VERSION)/_weakrefset.py \
/usr/lib/python$(PYTHON3_VERSION)/abc.py \
/usr/lib/python$(PYTHON3_VERSION)/codecs.py \
@ -228,24 +256,22 @@ PYTHON3_LIB_FILES_DEL+=$(PYTHON3_BASE_LIB_FILES)
define Py3Package/python3-base/filespec
+|/usr/bin/python$(PYTHON3_VERSION)
$(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),+|$(lib_file)))
$(foreach lib_file,$(PYTHON3_BASE_LIB_FILES),
+|$(lib_file)
)
endef
define Py3Package/python3-light/filespec
+|/usr/lib/python$(PYTHON3_VERSION)
-|/usr/lib/python$(PYTHON3_VERSION)/distutils/cygwinccompiler.py
-|/usr/lib/python$(PYTHON3_VERSION)/distutils/command/wininst*
-|/usr/lib/python$(PYTHON3_VERSION)/idlelib
-|/usr/lib/python$(PYTHON3_VERSION)/tkinter
-|/usr/lib/python$(PYTHON3_VERSION)/turtledemo
-|/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_test*.so
-|/usr/lib/python$(PYTHON3_VERSION)/pdb.doc
-|/usr/lib/python$(PYTHON3_VERSION)/test
-|/usr/lib/python$(PYTHON3_VERSION)/webbrowser.py
-|/usr/lib/python$(PYTHON3_VERSION)/*/test
-|/usr/lib/python$(PYTHON3_VERSION)/*/tests
-|/usr/lib/python$(PYTHON3_VERSION)/_osx_support.py
$(subst $(space),$(newline),$(foreach lib_file,$(PYTHON3_LIB_FILES_DEL),-|$(lib_file)))
$(foreach lib_file,$(filter /usr/lib/python$(PYTHON3_VERSION)/%,$(PYTHON3_LIB_FILES_DEL)),
-|$(lib_file)
)
endef
define Package/libpython3/install
@ -258,17 +284,10 @@ define Py3Package/python3-base/install
$(INSTALL_DIR) $(1)/usr/bin
$(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python3
$(LN) python$(PYTHON3_VERSION) $(1)/usr/bin/python
# This depends on being called before filespec is processed
$(SED) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/_sysconfigdata.py
endef
Py3Package/python3-light/install:=:
Py3Package/python3/install:=:
define Py3Package/python3/filespec
-|$(PYTHON3_PKG_DIR)
endef
Package/python3/install:=:
# libuuid is provided by e2fsprogs and uuid/uuid.h is moved into
# $(STAGING_DIR_HOST)/include/e2fsprogs
@ -351,14 +370,13 @@ $(foreach package, $(PYTHON3_PACKAGES), \
)
$(eval $(call BuildPackage,libpython3))
$(eval $(call BuildPackage,python3))
$(eval $(call Py3Package,python3-base))
$(eval $(call Py3Package,python3-light))
$(eval $(call Py3Package,python3))
$(eval $(call BuildPackage,python3-base))
$(eval $(call BuildPackage,python3-light))
$(eval $(call BuildPackage,python3))
$(eval $(call BuildPackage,python3-base-src))
$(eval $(call BuildPackage,python3-light-src))

View File

@ -7,10 +7,16 @@
define Package/python3-asyncio
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) asyncio module
TITLE+= asyncio module
DEPENDS:=+python3-light
endef
define Package/python3-asyncio/description
$(call Package/python3/Default/description)
This package contains the asyncio module.
endef
$(eval $(call Py3BasePackage,python3-asyncio, \
/usr/lib/python$(PYTHON3_VERSION)/asyncio \
))

View File

@ -7,16 +7,27 @@
define Package/python3-cgi
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) cgi module
TITLE+= cgi module
DEPENDS:=+python3-light +python3-email
endef
define Package/python3-cgitb
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) cgitb module
TITLE+= cgitb module
DEPENDS:=+python3-light +python3-cgi +python3-pydoc
endef
define Package/python3-cgi/description
$(call Package/python3/Default/description)
This package contains the cgi module.
endef
define Package/python3-cgitb/description
$(call Package/python3/Default/description)
This package contains the cgitb module.
endef
$(eval $(call Py3BasePackage,python3-cgi, \
/usr/lib/python$(PYTHON3_VERSION)/cgi.py \

View File

@ -7,10 +7,16 @@
define Package/python3-codecs
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) codecs + unicode support
TITLE+= codecs/Unicode support
DEPENDS:=+python3-light
endef
define Package/python3-codecs/description
$(call Package/python3/Default/description)
This package contains codecs and Unicode support.
endef
$(eval $(call Py3BasePackage,python3-codecs, \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_cn.$(PYTHON3_SO_SUFFIX) \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_codecs_hk.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-ctypes
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) ctypes module
TITLE+= ctypes module
DEPENDS:=+python3-light +libffi
endef
define Package/python3-ctypes/description
$(call Package/python3/Default/description)
This package contains the ctypes module.
endef
$(eval $(call Py3BasePackage,python3-ctypes, \
/usr/lib/python$(PYTHON3_VERSION)/ctypes \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_ctypes.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-dbm
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) dbm module
TITLE+= dbm module
DEPENDS:=+python3-light +libgdbm
endef
define Package/python3-dbm/description
$(call Package/python3/Default/description)
This package contains the dbm module.
endef
$(eval $(call Py3BasePackage,python3-dbm, \
/usr/lib/python$(PYTHON3_VERSION)/dbm \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_dbm.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-decimal
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) decimal module
TITLE+= decimal module
DEPENDS:=+python3-light
endef
define Package/python3-decimal/description
$(call Package/python3/Default/description)
This package contains the decimal module.
endef
$(eval $(call Py3BasePackage,python3-decimal, \
/usr/lib/python$(PYTHON3_VERSION)/decimal.py \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_decimal.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,23 +7,27 @@
define Package/python3-dev
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) development files
TITLE+= development files
DEPENDS:=+python3 +python3-lib2to3
endef
define Package/python3-dev/description
$(call Package/python3/Default/description)
This package contains files for building Python modules, extending the
Python interpreter, or embedded Python in applications.
endef
define Py3Package/python3-dev/install
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/bin/python$(PYTHON3_VERSION)-config $(1)/usr/bin
$(LN) python$(PYTHON3_VERSION)-config $(1)/usr/bin/python3-config
$(LN) python$(PYTHON3_VERSION)-config $(1)/usr/bin/python-config
$(LN) python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/libpython$(PYTHON3_VERSION).a $(1)/usr/lib/
# This depends on being called before filespec is processed
$(SED) 's|$(TARGET_AR)|ar|g;s|$(TARGET_CROSS)readelf|readelf|g;s|$(TARGET_CC)|gcc|g;s|$(TARGET_CXX)|g++|g' \
$(PKG_INSTALL_DIR)/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)/Makefile
endef
$(eval $(call Py3BasePackage,python3-dev, \
/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION) \
/usr/lib/python$(PYTHON3_VERSION)/config-$(PYTHON3_VERSION)-* \
/usr/include/python$(PYTHON3_VERSION) \
/usr/lib/pkgconfig \
, \

View File

@ -7,10 +7,16 @@
define Package/python3-distutils
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) distutils module
TITLE+= distutils module
DEPENDS:=+python3-light +python3-email
endef
define Package/python3-distutils/description
$(call Package/python3/Default/description)
This package contains the distutils module.
endef
$(eval $(call Py3BasePackage,python3-distutils, \
/usr/lib/python$(PYTHON3_VERSION)/distutils \
))

View File

@ -7,10 +7,16 @@
define Package/python3-email
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) email module
TITLE+= email module
DEPENDS:=+python3-light
endef
define Package/python3-email/description
$(call Package/python3/Default/description)
This package contains the email module.
endef
$(eval $(call Py3BasePackage,python3-email, \
/usr/lib/python$(PYTHON3_VERSION)/email \
))

View File

@ -7,10 +7,16 @@
define Package/python3-lib2to3
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) lib2to3 module
TITLE+= lib2to3 module
DEPENDS:=+python3
endef
define Package/python3-lib2to3/description
$(call Package/python3/Default/description)
This package contains the lib2to3 module.
endef
$(eval $(call Py3BasePackage,python3-lib2to3, \
/usr/lib/python$(PYTHON3_VERSION)/lib2to3 \
, \

View File

@ -7,10 +7,16 @@
define Package/python3-logging
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) logging module
TITLE+= logging module
DEPENDS:=+python3-light
endef
define Package/python3-logging/description
$(call Package/python3/Default/description)
This package contains the logging module.
endef
$(eval $(call Py3BasePackage,python3-logging, \
/usr/lib/python$(PYTHON3_VERSION)/logging \
))

View File

@ -7,10 +7,16 @@
define Package/python3-lzma
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) lzma module
TITLE+= lzma module
DEPENDS:=+python3-light +liblzma
endef
define Package/python3-lzma/description
$(call Package/python3/Default/description)
This package contains the lzma module.
endef
$(eval $(call Py3BasePackage,python3-lzma, \
/usr/lib/python$(PYTHON3_VERSION)/lzma.py \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_lzma.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-multiprocessing
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) multiprocessing
TITLE+= multiprocessing module
DEPENDS:=+python3-light
endef
define Package/python3-multiprocessing/description
$(call Package/python3/Default/description)
This package contains the multiprocessing module.
endef
$(eval $(call Py3BasePackage,python3-multiprocessing, \
/usr/lib/python$(PYTHON3_VERSION)/multiprocessing \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_multiprocessing.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-ncurses
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) ncurses module
TITLE+= ncurses module
DEPENDS:=+python3-light +libncursesw
endef
define Package/python3-ncurses/description
$(call Package/python3/Default/description)
This package contains the ncurses module.
endef
$(eval $(call Py3BasePackage,python3-ncurses, \
/usr/lib/python$(PYTHON3_VERSION)/curses \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_curses.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-openssl
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) SSL module
TITLE+= ssl module
DEPENDS:=+python3-light +libopenssl +ca-certs
endef
define Package/python3-openssl/description
$(call Package/python3/Default/description)
This package contains the ssl module.
endef
$(eval $(call Py3BasePackage,python3-openssl, \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_hashlib.$(PYTHON3_SO_SUFFIX) \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_ssl.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-pydoc
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) pydoc module
TITLE+= pydoc module
DEPENDS:=+python3-light
endef
define Package/python3-pydoc/description
$(call Package/python3/Default/description)
This package contains the pydoc module.
endef
$(eval $(call Py3BasePackage,python3-pydoc, \
/usr/lib/python$(PYTHON3_VERSION)/doctest.py \
/usr/lib/python$(PYTHON3_VERSION)/pydoc.py \

View File

@ -7,10 +7,16 @@
define Package/python3-readline
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) readline module
TITLE+= readline module
DEPENDS:=+python3-light +libreadline
endef
define Package/python3-readline/description
$(call Package/python3/Default/description)
This package contains the readline module.
endef
$(eval $(call Py3BasePackage,python3-readline, \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/readline.$(PYTHON3_SO_SUFFIX) \
))

View File

@ -7,10 +7,16 @@
define Package/python3-sqlite3
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) sqlite3 module
TITLE+= sqlite3 module
DEPENDS:=+python3-light +libsqlite3
endef
define Package/python3-sqlite3/description
$(call Package/python3/Default/description)
This package contains the sqlite3 module.
endef
$(eval $(call Py3BasePackage,python3-sqlite3, \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_sqlite3.$(PYTHON3_SO_SUFFIX) \
/usr/lib/python$(PYTHON3_VERSION)/sqlite3 \

View File

@ -7,10 +7,16 @@
define Package/python3-unittest
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) unittest module
TITLE+= unittest module
DEPENDS:=+python3-light
endef
define Package/python3-unittest/description
$(call Package/python3/Default/description)
This package contains the unittest module.
endef
$(eval $(call Py3BasePackage,python3-unittest, \
/usr/lib/python$(PYTHON3_VERSION)/unittest \
))

View File

@ -7,10 +7,16 @@
define Package/python3-urllib
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) URL library module
TITLE+= URL handling modules
DEPENDS:=+python3-light +python3-email
endef
define Package/python3-urllib/description
$(call Package/python3/Default/description)
This package contains the URL handling modules.
endef
$(eval $(call Py3BasePackage,python3-urllib, \
/usr/lib/python$(PYTHON3_VERSION)/urllib \
))

View File

@ -7,10 +7,16 @@
define Package/python3-uuid
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) UUID module
TITLE+= uuid module
DEPENDS:=+python3-light +libuuid
endef
define Package/python3-uuid/description
$(call Package/python3/Default/description)
This package contains the uuid module.
endef
$(eval $(call Py3BasePackage,python3-uuid, \
/usr/lib/python$(PYTHON3_VERSION)/uuid.py \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_uuid.$(PYTHON3_SO_SUFFIX) \

View File

@ -7,10 +7,16 @@
define Package/python3-venv
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) venv module
TITLE+= venv module
DEPENDS:=+python3
endef
define Package/python3-venv/description
$(call Package/python3/Default/description)
This package contains the venv module.
endef
$(eval $(call Py3BasePackage,python3-venv, \
/usr/lib/python$(PYTHON3_VERSION)/ensurepip \
/usr/lib/python$(PYTHON3_VERSION)/venv \

View File

@ -7,10 +7,16 @@
define Package/python3-xml
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) xml libs
TITLE+= XML modules
DEPENDS:=+python3-light +python3-urllib
endef
define Package/python3-xml/description
$(call Package/python3/Default/description)
This package contains the XML modules.
endef
$(eval $(call Py3BasePackage,python3-xml, \
/usr/lib/python$(PYTHON3_VERSION)/xml \
/usr/lib/python$(PYTHON3_VERSION)/xmlrpc \

View File

@ -1,22 +0,0 @@
--- a/configure
+++ b/configure
@@ -23352,7 +23352,7 @@ printf %s "checking ABIFLAGS... " >&6; }
printf "%s\n" "$ABIFLAGS" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking SOABI" >&5
printf %s "checking SOABI... " >&6; }
-SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
+SOABI='cpython-'`echo $VERSION | tr -d .`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $SOABI" >&5
printf "%s\n" "$SOABI" >&6; }
--- a/configure.ac
+++ b/configure.ac
@@ -5683,7 +5683,7 @@ AC_SUBST(SOABI)
AC_MSG_CHECKING(ABIFLAGS)
AC_MSG_RESULT($ABIFLAGS)
AC_MSG_CHECKING(SOABI)
-SOABI='cpython-'`echo $VERSION | tr -d .`${ABIFLAGS}${PLATFORM_TRIPLET:+-$PLATFORM_TRIPLET}
+SOABI='cpython-'`echo $VERSION | tr -d .`
AC_MSG_RESULT($SOABI)
# Release and debug (Py_DEBUG) ABI are compatible, but not Py_TRACE_REFS ABI

View File

@ -1,70 +0,0 @@
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -461,6 +461,7 @@ def get_makefile_filename():
def _get_sysconfigdata_name():
+ return '_sysconfigdata'
multiarch = getattr(sys.implementation, '_multiarch', '')
return os.environ.get(
'_PYTHON_SYSCONFIGDATA_NAME',
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2111,7 +2111,7 @@ libinstall: all $(srcdir)/Modules/xxmodu
esac; \
done; \
done
- $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
+ $(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata*.py \
$(DESTDIR)$(LIBDEST); \
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
@@ -2273,7 +2273,7 @@ sharedinstall: all
--install-scripts=$(BINDIR) \
--install-platlib=$(DESTSHARED) \
--root=$(DESTDIR)/
- -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py
+ -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata*.py
-rm -r $(DESTDIR)$(DESTSHARED)/__pycache__
# Here are a couple of targets for MacOSX again, to install a full
--- a/configure
+++ b/configure
@@ -3630,7 +3630,7 @@ fi
fi
ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
PYTHON_FOR_FREEZE="$with_build_python"
- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
+ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata '$with_build_python
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_build_python" >&5
printf "%s\n" "$with_build_python" >&6; }
@@ -23421,7 +23421,7 @@ fi
-if test x$PLATFORM_TRIPLET = x; then
+if true ; then
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
else
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"
--- a/configure.ac
+++ b/configure.ac
@@ -162,7 +162,7 @@ AC_ARG_WITH(
dnl Build Python interpreter is used for regeneration and freezing.
ac_cv_prog_PYTHON_FOR_REGEN=$with_build_python
PYTHON_FOR_FREEZE="$with_build_python"
- PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH) '$with_build_python
+ PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata '$with_build_python
AC_MSG_RESULT([$with_build_python])
], [
AS_VAR_IF([cross_compiling], [yes],
@@ -5741,7 +5741,7 @@ fi],
dnl define LIBPL after ABIFLAGS and LDVERSION is defined.
AC_SUBST(PY_ENABLE_SHARED)
-if test x$PLATFORM_TRIPLET = x; then
+if true ; then
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}"
else
LIBPL='$(prefix)'"/${PLATLIBDIR}/python${VERSION}/config-${LDVERSION}-${PLATFORM_TRIPLET}"

View File

@ -0,0 +1,476 @@
From c163d7f0b67a568e9b64eeb9c1cbbaa127818596 Mon Sep 17 00:00:00 2001
From: Jeffery To <jeffery.to@gmail.com>
Date: Thu, 24 Aug 2023 20:22:50 +0800
Subject: [PATCH] gh-95855: Refactor platform triplet detection code, add
detection for MIPS soft float and musl libc (#107221)
- Move platform triplet detection code into Misc/platform_triplet.c
- Refactor MIPS detection, use defined(__mips64) to detect MIPS64
- Compute libc values in separate section
- Add detection for MIPS soft float
- Add detection for musl
musl supports SPE with its soft-float ABI:
https://git.musl-libc.org/cgit/musl/commit/?id=7be59733d71ada3a32a98622507399253f1d5e48
Original patch by Christian Heimes.
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
[omit news, changes to configure; adapt for Python 3.11]
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
---
...3-07-25-02-30-00.gh-issue-95855.wA7rAf.rst | 2 +
Misc/platform_triplet.c | 255 ++++++++++++++++++
configure | 192 +------------
configure.ac | 192 +------------
4 files changed, 265 insertions(+), 376 deletions(-)
create mode 100644 Misc/NEWS.d/next/Build/2023-07-25-02-30-00.gh-issue-95855.wA7rAf.rst
create mode 100644 Misc/platform_triplet.c
--- /dev/null
+++ b/Misc/platform_triplet.c
@@ -0,0 +1,255 @@
+/* Detect platform triplet from builtin defines
+ * cc -E Misc/platform_triplet.c | grep '^PLATFORM_TRIPLET=' | tr -d ' '
+ */
+#undef bfin
+#undef cris
+#undef fr30
+#undef linux
+#undef hppa
+#undef hpux
+#undef i386
+#undef mips
+#undef powerpc
+#undef sparc
+#undef unix
+#if defined(__ANDROID__)
+ # Android is not a multiarch system.
+#elif defined(__linux__)
+/*
+ * BEGIN of Linux block
+ */
+// Detect libc (based on config.guess)
+# include <features.h>
+# if defined(__UCLIBC__)
+# error uclibc not supported
+# elif defined(__dietlibc__)
+# error dietlibc not supported
+# elif defined(__GLIBC__)
+# define LIBC gnu
+# define LIBC_X32 gnux32
+# if defined(__ARM_PCS_VFP)
+# define LIBC_ARM gnueabihf
+# else
+# define LIBC_ARM gnueabi
+# endif
+# if defined(__loongarch__)
+# if defined(__loongarch_soft_float)
+# define LIBC_LA gnusf
+# elif defined(__loongarch_single_float)
+# define LIBC_LA gnuf32
+# elif defined(__loongarch_double_float)
+# define LIBC_LA gnu
+# else
+# error unknown loongarch floating-point base abi
+# endif
+# endif
+# if defined(_MIPS_SIM)
+# if defined(__mips_hard_float)
+# if _MIPS_SIM == _ABIO32
+# define LIBC_MIPS gnu
+# elif _MIPS_SIM == _ABIN32
+# define LIBC_MIPS gnuabin32
+# elif _MIPS_SIM == _ABI64
+# define LIBC_MIPS gnuabi64
+# else
+# error unknown mips sim value
+# endif
+# else
+# if _MIPS_SIM == _ABIO32
+# define LIBC_MIPS gnusf
+# elif _MIPS_SIM == _ABIN32
+# define LIBC_MIPS gnuabin32sf
+# elif _MIPS_SIM == _ABI64
+# define LIBC_MIPS gnuabi64sf
+# else
+# error unknown mips sim value
+# endif
+# endif
+# endif
+# if defined(__SPE__)
+# define LIBC_PPC gnuspe
+# else
+# define LIBC_PPC gnu
+# endif
+# else
+// Heuristic to detect musl libc
+# include <stdarg.h>
+# ifdef __DEFINED_va_list
+# define LIBC musl
+# define LIBC_X32 muslx32
+# if defined(__ARM_PCS_VFP)
+# define LIBC_ARM musleabihf
+# else
+# define LIBC_ARM musleabi
+# endif
+# if defined(__loongarch__)
+# if defined(__loongarch_soft_float)
+# define LIBC_LA muslsf
+# elif defined(__loongarch_single_float)
+# define LIBC_LA muslf32
+# elif defined(__loongarch_double_float)
+# define LIBC_LA musl
+# else
+# error unknown loongarch floating-point base abi
+# endif
+# endif
+# if defined(_MIPS_SIM)
+# if defined(__mips_hard_float)
+# if _MIPS_SIM == _ABIO32
+# define LIBC_MIPS musl
+# elif _MIPS_SIM == _ABIN32
+# define LIBC_MIPS musln32
+# elif _MIPS_SIM == _ABI64
+# define LIBC_MIPS musl
+# else
+# error unknown mips sim value
+# endif
+# else
+# if _MIPS_SIM == _ABIO32
+# define LIBC_MIPS muslsf
+# elif _MIPS_SIM == _ABIN32
+# define LIBC_MIPS musln32sf
+# elif _MIPS_SIM == _ABI64
+# define LIBC_MIPS muslsf
+# else
+# error unknown mips sim value
+# endif
+# endif
+# endif
+# if defined(_SOFT_FLOAT) || defined(__NO_FPRS__)
+# define LIBC_PPC muslsf
+# else
+# define LIBC_PPC musl
+# endif
+# else
+# error unknown libc
+# endif
+# endif
+
+# if defined(__x86_64__) && defined(__LP64__)
+PLATFORM_TRIPLET=x86_64-linux-LIBC
+# elif defined(__x86_64__) && defined(__ILP32__)
+PLATFORM_TRIPLET=x86_64-linux-LIBC_X32
+# elif defined(__i386__)
+PLATFORM_TRIPLET=i386-linux-LIBC
+# elif defined(__aarch64__) && defined(__AARCH64EL__)
+# if defined(__ILP32__)
+PLATFORM_TRIPLET=aarch64_ilp32-linux-LIBC
+# else
+PLATFORM_TRIPLET=aarch64-linux-LIBC
+# endif
+# elif defined(__aarch64__) && defined(__AARCH64EB__)
+# if defined(__ILP32__)
+PLATFORM_TRIPLET=aarch64_be_ilp32-linux-LIBC
+# else
+PLATFORM_TRIPLET=aarch64_be-linux-LIBC
+# endif
+# elif defined(__alpha__)
+PLATFORM_TRIPLET=alpha-linux-LIBC
+# elif defined(__ARM_EABI__)
+# if defined(__ARMEL__)
+PLATFORM_TRIPLET=arm-linux-LIBC_ARM
+# else
+PLATFORM_TRIPLET=armeb-linux-LIBC_ARM
+# endif
+# elif defined(__hppa__)
+PLATFORM_TRIPLET=hppa-linux-LIBC
+# elif defined(__ia64__)
+PLATFORM_TRIPLET=ia64-linux-LIBC
+# elif defined(__loongarch__) && defined(__loongarch_lp64)
+PLATFORM_TRIPLET=loongarch64-linux-LIBC_LA
+# elif defined(__m68k__) && !defined(__mcoldfire__)
+PLATFORM_TRIPLET=m68k-linux-LIBC
+# elif defined(__mips__)
+# if defined(__mips_isa_rev) && (__mips_isa_rev >=6)
+# if defined(_MIPSEL) && defined(__mips64)
+PLATFORM_TRIPLET=mipsisa64r6el-linux-LIBC_MIPS
+# elif defined(_MIPSEL)
+PLATFORM_TRIPLET=mipsisa32r6el-linux-LIBC_MIPS
+# elif defined(__mips64)
+PLATFORM_TRIPLET=mipsisa64r6-linux-LIBC_MIPS
+# else
+PLATFORM_TRIPLET=mipsisa32r6-linux-LIBC_MIPS
+# endif
+# else
+# if defined(_MIPSEL) && defined(__mips64)
+PLATFORM_TRIPLET=mips64el-linux-LIBC_MIPS
+# elif defined(_MIPSEL)
+PLATFORM_TRIPLET=mipsel-linux-LIBC_MIPS
+# elif defined(__mips64)
+PLATFORM_TRIPLET=mips64-linux-LIBC_MIPS
+# else
+PLATFORM_TRIPLET=mips-linux-LIBC_MIPS
+# endif
+# endif
+# elif defined(__or1k__)
+PLATFORM_TRIPLET=or1k-linux-LIBC
+# elif defined(__powerpc64__)
+# if defined(__LITTLE_ENDIAN__)
+PLATFORM_TRIPLET=powerpc64le-linux-LIBC
+# else
+PLATFORM_TRIPLET=powerpc64-linux-LIBC
+# endif
+# elif defined(__powerpc__)
+PLATFORM_TRIPLET=powerpc-linux-LIBC_PPC
+# elif defined(__s390x__)
+PLATFORM_TRIPLET=s390x-linux-LIBC
+# elif defined(__s390__)
+PLATFORM_TRIPLET=s390-linux-LIBC
+# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
+PLATFORM_TRIPLET=sh4-linux-LIBC
+# elif defined(__sparc__) && defined(__arch64__)
+PLATFORM_TRIPLET=sparc64-linux-LIBC
+# elif defined(__sparc__)
+PLATFORM_TRIPLET=sparc-linux-LIBC
+# elif defined(__riscv)
+# if __riscv_xlen == 32
+PLATFORM_TRIPLET=riscv32-linux-LIBC
+# elif __riscv_xlen == 64
+PLATFORM_TRIPLET=riscv64-linux-LIBC
+# else
+# error unknown platform triplet
+# endif
+# else
+# error unknown platform triplet
+# endif
+/*
+ * END of Linux block
+ */
+#elif defined(__FreeBSD_kernel__)
+# if defined(__LP64__)
+PLATFORM_TRIPLET=x86_64-kfreebsd-gnu
+# elif defined(__i386__)
+PLATFORM_TRIPLET=i386-kfreebsd-gnu
+# else
+# error unknown platform triplet
+# endif
+#elif defined(__gnu_hurd__)
+PLATFORM_TRIPLET=i386-gnu
+#elif defined(__APPLE__)
+PLATFORM_TRIPLET=darwin
+#elif defined(__VXWORKS__)
+PLATFORM_TRIPLET=vxworks
+#elif defined(__wasm32__)
+# if defined(__EMSCRIPTEN__)
+PLATFORM_TRIPLET=wasm32-emscripten
+# elif defined(__wasi__)
+# if defined(_REENTRANT)
+PLATFORM_TRIPLET=wasm32-wasi-threads
+# else
+PLATFORM_TRIPLET=wasm32-wasi
+# endif
+# else
+# error unknown wasm32 platform
+# endif
+#elif defined(__wasm64__)
+# if defined(__EMSCRIPTEN__)
+PLATFORM_TRIPLET=wasm64-emscripten
+# elif defined(__wasi__)
+PLATFORM_TRIPLET=wasm64-wasi
+# else
+# error unknown wasm64 platform
+# endif
+#else
+# error unknown platform triplet
+#endif
--- a/configure.ac
+++ b/configure.ac
@@ -917,180 +917,14 @@ fi
AC_MSG_CHECKING([for the platform triplet based on compiler characteristics])
-cat > conftest.c <<EOF
-#undef bfin
-#undef cris
-#undef fr30
-#undef linux
-#undef hppa
-#undef hpux
-#undef i386
-#undef mips
-#undef powerpc
-#undef sparc
-#undef unix
-#if defined(__ANDROID__)
- # Android is not a multiarch system.
-#elif defined(__linux__)
-# if defined(__x86_64__) && defined(__LP64__)
- x86_64-linux-gnu
-# elif defined(__x86_64__) && defined(__ILP32__)
- x86_64-linux-gnux32
-# elif defined(__i386__)
- i386-linux-gnu
-# elif defined(__aarch64__) && defined(__AARCH64EL__)
-# if defined(__ILP32__)
- aarch64_ilp32-linux-gnu
-# else
- aarch64-linux-gnu
-# endif
-# elif defined(__aarch64__) && defined(__AARCH64EB__)
-# if defined(__ILP32__)
- aarch64_be_ilp32-linux-gnu
-# else
- aarch64_be-linux-gnu
-# endif
-# elif defined(__alpha__)
- alpha-linux-gnu
-# elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP)
-# if defined(__ARMEL__)
- arm-linux-gnueabihf
-# else
- armeb-linux-gnueabihf
-# endif
-# elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
-# if defined(__ARMEL__)
- arm-linux-gnueabi
-# else
- armeb-linux-gnueabi
-# endif
-# elif defined(__hppa__)
- hppa-linux-gnu
-# elif defined(__ia64__)
- ia64-linux-gnu
-# elif defined(__m68k__) && !defined(__mcoldfire__)
- m68k-linux-gnu
-# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6) && defined(_MIPSEL)
-# if _MIPS_SIM == _ABIO32
- mipsisa32r6el-linux-gnu
-# elif _MIPS_SIM == _ABIN32
- mipsisa64r6el-linux-gnuabin32
-# elif _MIPS_SIM == _ABI64
- mipsisa64r6el-linux-gnuabi64
-# else
-# error unknown platform triplet
-# endif
-# elif defined(__mips_hard_float) && defined(__mips_isa_rev) && (__mips_isa_rev >=6)
-# if _MIPS_SIM == _ABIO32
- mipsisa32r6-linux-gnu
-# elif _MIPS_SIM == _ABIN32
- mipsisa64r6-linux-gnuabin32
-# elif _MIPS_SIM == _ABI64
- mipsisa64r6-linux-gnuabi64
-# else
-# error unknown platform triplet
-# endif
-# elif defined(__mips_hard_float) && defined(_MIPSEL)
-# if _MIPS_SIM == _ABIO32
- mipsel-linux-gnu
-# elif _MIPS_SIM == _ABIN32
- mips64el-linux-gnuabin32
-# elif _MIPS_SIM == _ABI64
- mips64el-linux-gnuabi64
-# else
-# error unknown platform triplet
-# endif
-# elif defined(__mips_hard_float)
-# if _MIPS_SIM == _ABIO32
- mips-linux-gnu
-# elif _MIPS_SIM == _ABIN32
- mips64-linux-gnuabin32
-# elif _MIPS_SIM == _ABI64
- mips64-linux-gnuabi64
-# else
-# error unknown platform triplet
-# endif
-# elif defined(__or1k__)
- or1k-linux-gnu
-# elif defined(__powerpc__) && defined(__SPE__)
- powerpc-linux-gnuspe
-# elif defined(__powerpc64__)
-# if defined(__LITTLE_ENDIAN__)
- powerpc64le-linux-gnu
-# else
- powerpc64-linux-gnu
-# endif
-# elif defined(__powerpc__)
- powerpc-linux-gnu
-# elif defined(__s390x__)
- s390x-linux-gnu
-# elif defined(__s390__)
- s390-linux-gnu
-# elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
- sh4-linux-gnu
-# elif defined(__sparc__) && defined(__arch64__)
- sparc64-linux-gnu
-# elif defined(__sparc__)
- sparc-linux-gnu
-# elif defined(__riscv)
-# if __riscv_xlen == 32
- riscv32-linux-gnu
-# elif __riscv_xlen == 64
- riscv64-linux-gnu
-# else
-# error unknown platform triplet
-# endif
-# else
-# error unknown platform triplet
-# endif
-#elif defined(__FreeBSD_kernel__)
-# if defined(__LP64__)
- x86_64-kfreebsd-gnu
-# elif defined(__i386__)
- i386-kfreebsd-gnu
-# else
-# error unknown platform triplet
-# endif
-#elif defined(__gnu_hurd__)
- i386-gnu
-#elif defined(__APPLE__)
- darwin
-#elif defined(__VXWORKS__)
- vxworks
-#elif defined(__wasm32__)
-# if defined(__EMSCRIPTEN__)
- wasm32-emscripten
-# elif defined(__wasi__)
- wasm32-wasi
-# else
-# error unknown wasm32 platform
-# endif
-#elif defined(__wasm64__)
-# if defined(__EMSCRIPTEN__)
- wasm64-emscripten
-# elif defined(__wasi__)
- wasm64-wasi
-# else
-# error unknown wasm64 platform
-# endif
-#else
-# error unknown platform triplet
-#endif
-
-EOF
-
-if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
- PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
- case "$build_os" in
- linux-musl*)
- PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
- ;;
- esac
+if $CPP $CPPFLAGS $srcdir/Misc/platform_triplet.c >conftest.out 2>/dev/null; then
+ PLATFORM_TRIPLET=`grep '^PLATFORM_TRIPLET=' conftest.out | tr -d ' '`
+ PLATFORM_TRIPLET="${PLATFORM_TRIPLET@%:@PLATFORM_TRIPLET=}"
AC_MSG_RESULT([$PLATFORM_TRIPLET])
else
AC_MSG_RESULT([none])
fi
-rm -f conftest.c conftest.out
+rm -f conftest.out
AC_MSG_CHECKING([for multiarch])
AS_CASE([$ac_sys_system],

View File

@ -1,49 +0,0 @@
From 15d512cc35106392ed7583d0e000d9a1b865f1e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=A0imon=20Bo=C5=99ek?= <simon.borek@nic.cz>
Date: Mon, 27 Jun 2022 13:53:37 +0200
Subject: [PATCH 2/2] configure.ac: switch PLATFORM_TRIPLET suffix to '-musl'
based on `host_os` instead of `build_os`
As `build_os` and `host_os` are results of autoconf's `AC_CANONICAL_BUILD`
and `AC_CANONICAL_HOST` macros[^1], the former refers to the system running the build
and the latter to the system that will run the compiled program.
`PLATFORM_TRIPLET` should refer to the target platform when cross-compiling.
Its libc related part should be therefore derived from the target platform as well
- which is currently not the case - `PLATFORM_TRIPLET` '-gnu' suffix is/isn't switched to '-musl'
based on `build-os` rather than `host-os` which leads to error message[^2]
and build failure when compiling Python on glibc system for musl target.
[^1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Canonicalizing.html ,
https://www.gnu.org/software/autoconf/manual/autoconf-2.68/html_node/Specifying-Target-Triplets.html
[^2]: "internal configure error for the platform triplet, please file a bug report"
Co-authored-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Šimon Bořek <simon.borek@nic.cz>
---
configure | 2 +-
configure.ac | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/configure
+++ b/configure
@@ -6824,7 +6824,7 @@ EOF
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
- case "$build_os" in
+ case "$host_os" in
linux-musl*)
PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
;;
--- a/configure.ac
+++ b/configure.ac
@@ -1081,7 +1081,7 @@ EOF
if $CPP $CPPFLAGS conftest.c >conftest.out 2>/dev/null; then
PLATFORM_TRIPLET=`grep -v '^#' conftest.out | grep -v '^ *$' | tr -d ' '`
- case "$build_os" in
+ case "$host_os" in
linux-musl*)
PLATFORM_TRIPLET=`echo "$PLATFORM_TRIPLET" | sed 's/linux-gnu/linux-musl/'`
;;