Fix glibc-ports with the new framework

While here, also consider patched by anything other than "bundled patches"
as per-target sources. Add scary warnings in case of a failure.

Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
Alexey Neyman
2017-08-25 08:42:19 -07:00
parent 961ea19382
commit 5324905c14
5 changed files with 109 additions and 70 deletions

View File

@ -52,30 +52,36 @@ config PATCH_BUNDLED
config PATCH_LOCAL config PATCH_LOCAL
bool bool
prompt "Local only" prompt "Local only (EXPERIMENTAL)"
select PATCH_USE_LOCAL select PATCH_USE_LOCAL
depends on EXPERIMENTAL
help help
Only apply your local patches. Only apply your local patches. Many components require patching
to build or work properly; please review the bundled patches and
copy them into your local directory if needed.
config PATCH_BUNDLED_LOCAL config PATCH_BUNDLED_LOCAL
bool bool
prompt "Bundled, then local" prompt "Bundled, then local"
select PATCH_USE_LOCAL select PATCH_USE_LOCAL
help help
Apply the patches bundled with crosstool-NG, Apply the patches bundled with crosstool-NG, then apply your local
then apply your local patches. patches.
config PATCH_LOCAL_BUNDLED config PATCH_LOCAL_BUNDLED
bool bool
prompt "Local, then bundled" prompt "Local, then bundled"
select PATCH_USE_LOCAL select PATCH_USE_LOCAL
depends on EXPERIMENTAL
help help
Apply your local patches, then apply the patches Apply your local patches, then apply the patches bundled with
bundled with crosstool-NG. crosstool-NG. Note that the bundled patches cannot be guaranteed
to apply on top of your local patches.
config PATCH_NONE config PATCH_NONE
bool bool
prompt "None" prompt "None"
depends on EXPERIMENTAL
help help
Don't use any patch at all. Don't use any patch at all.

View File

@ -458,8 +458,10 @@ do_gcc_core_backend() {
# Pass-2 should be able to get it from the headers, but for some options # Pass-2 should be able to get it from the headers, but for some options
# (such as --with-long-double-128) we need to get it right even in pass-1. # (such as --with-long-double-128) we need to get it right even in pass-1.
# GCC expects just two numbers separated by a dot. # GCC expects just two numbers separated by a dot.
local glibc_version=`CT_GetPkgVersion GLIBC | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/'` local glibc_version
CT_GetPkgVersion GLIBC glibc_version
glibc_version=`echo "${glibc_version}" | sed 's/\([1-9][0-9]*\.[1-9][0-9]*\).*/\1/'`
extra_config+=("--with-glibc-version=${glibc_version}") extra_config+=("--with-glibc-version=${glibc_version}")
fi fi

View File

@ -5,7 +5,6 @@
do_libc_get() { do_libc_get() {
local date local date
local version local version
local -a addons_list
CT_Fetch GLIBC CT_Fetch GLIBC
if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then
@ -15,13 +14,18 @@ do_libc_get() {
} }
do_libc_extract() { do_libc_extract() {
local addon
CT_ExtractPatch GLIBC CT_ExtractPatch GLIBC
if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then if [ "${CT_GLIBC_USE_PORTS_EXTERNAL}" = "y" ]; then
CT_ExtractPatch GLIBC_PORTS CT_ExtractPatch GLIBC_PORTS
# This may create a bogus symlink if glibc-ports is using custom
# sources or has an overlay (and glibc is shared). However,
# we do not support concurrent use of the source directory
# and next run, if using different glibc-ports source, will override
# this symlink anyway.
CT_DoExecLog ALL ln -sf "${CT_GLIBC_PORTS_SRC_DIR}/${CT_GLIBC_PORTS_BASENAME}" \
"${CT_GLIBC_SRC_DIR}/${CT_GLIBC_BASENAME}/ports"
fi fi
# TBD make patches for addons (ports? anything else?) uniformly using short names
# TBD make the configure timestamp fix in all patched packages (e.g. part of CT_ExtractPatch) # TBD make the configure timestamp fix in all patched packages (e.g. part of CT_ExtractPatch)
} }

View File

@ -173,7 +173,7 @@ CT_PKGVERSION="crosstool-NG ${CT_VERSION}${CT_TOOLCHAIN_PKGVERSION:+ - ${CT_TOOL
# Compute the working directories names # Compute the working directories names
CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs" CT_TARBALLS_DIR="${CT_WORK_DIR}/tarballs"
CT_COMMON_SRC_DIR="${CT_WORK_DIR}/src" CT_COMMON_SRC_DIR="${CT_WORK_DIR}/src"
CT_SRC_DIR="${CT_BUILD_DIR}/src" CT_SRC_DIR="${CT_BUILD_TOP_DIR}/src"
CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools" CT_BUILDTOOLS_PREFIX_DIR="${CT_BUILD_TOP_DIR}/buildtools"
CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state" CT_STATE_DIR="${CT_WORK_DIR}/${CT_TARGET}/state"
# Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a # Note about HOST_COMPLIBS_DIR: it's always gonna be in the buildtools dir, or a

View File

@ -155,8 +155,28 @@ CT_OnError() {
CT_DoLog ERROR ">> For more info on this error, look at the file: '${CT_BUILD_LOG#${CT_TOP_DIR}/}'" CT_DoLog ERROR ">> For more info on this error, look at the file: '${CT_BUILD_LOG#${CT_TOP_DIR}/}'"
fi fi
CT_DoLog ERROR ">> There is a list of known issues, some with workarounds, in:" CT_DoLog ERROR ">> There is a list of known issues, some with workarounds, in:"
CT_DoLog ERROR ">> '${CT_DOC_DIR#${CT_TOP_DIR}/}/B - Known issues.txt'" if [ -r "${CT_DOC_DIR}/manual/B_Known_issues.md" ]; then
CT_DoLog ERROR ">> '${CT_DOC_DIR#${CT_TOP_DIR}/}/manual/B_Known_issues.md'"
else
CT_DoLog ERROR ">> https://crosstool-ng.github.io/docs/known-issues/"
fi
CT_DoLog ERROR ">>" CT_DoLog ERROR ">>"
if [ -n "${CT_EXPERIMENTAL}" ]; then
CT_DoLog ERROR ">> NOTE: Your configuration includes features marked EXPERIMENTAL."
CT_DoLog ERROR ">> Before submitting a bug report, try to reproduce it without enabling"
CT_DoLog ERROR ">> any experimental features. Otherwise, you'll need to debug it"
CT_DoLog ERROR ">> and present an explanation why it is a bug in crosstool-NG - or"
CT_DoLog ERROR ">> preferably, a fix."
CT_DoLog ERROR ">>"
fi
if [ "${CT_PATCH_ORDER}" != "bundled" ]; then
CT_DoLog ERROR ">> NOTE: You configuration uses non-default patch sets. Please"
CT_DoLog ERROR ">> select 'bundled' as the set of patches applied and attempt"
CT_DoLog ERROR ">> to reproduce this issue. Issues reported with other patch"
CT_DoLog ERROR ">> set selections (none, local, bundled+local) are going to be"
CT_DoLog ERROR ">> closed without explanation."
CT_DoLog ERROR ">>"
fi
CT_DoLog ERROR ">> If you feel this is a bug in crosstool-NG, report it at:" CT_DoLog ERROR ">> If you feel this is a bug in crosstool-NG, report it at:"
CT_DoLog ERROR ">> https://github.com/crosstool-ng/crosstool-ng/issues/" CT_DoLog ERROR ">> https://github.com/crosstool-ng/crosstool-ng/issues/"
CT_DoLog ERROR ">>" CT_DoLog ERROR ">>"
@ -178,7 +198,7 @@ trap CT_OnError ERR
set -E set -E
# Make pipes fail on the _first_ failed command # Make pipes fail on the _first_ failed command
# Not supported on bash < 3.x, but we need it, so drop the obsoleting bash-2.x # Not supported on bash < 3.x, but we need it, so drop the obsolete bash-2.x
set -o pipefail set -o pipefail
# Don't hash commands' locations, and search every time it is requested. # Don't hash commands' locations, and search every time it is requested.
@ -1678,6 +1698,7 @@ CT_PackageRun()
{ {
local sym="${1}" local sym="${1}"
local run="${2}" local run="${2}"
local src_dir="/unknown-src-dir"
local v local v
# Get rid of our arguments # Get rid of our arguments
@ -1712,7 +1733,7 @@ CT_PackageRun()
# Save certain variables that may be modified by the callback. # Save certain variables that may be modified by the callback.
# Fetching the sources is run in the main process, so no need to # Fetching the sources is run in the main process, so no need to
# use CT_EnvModify. # use CT_EnvModify.
for v in devel_branch devel_revision basename version; do for v in devel_branch devel_revision basename version src_dir; do
eval "[ \"\${${v}}\" != \"\${CT_${use}_${v^^}}\" ] || continue" eval "[ \"\${${v}}\" != \"\${CT_${use}_${v^^}}\" ] || continue"
eval "CT_${use}_${v^^}=\${${v}}" eval "CT_${use}_${v^^}=\${${v}}"
eval "CT_DoLog DEBUG \"Override CT_${use}_${v^^}=\${CT_${use}_${v^^}}\"" eval "CT_DoLog DEBUG \"Override CT_${use}_${v^^}=\${CT_${use}_${v^^}}\""
@ -1790,7 +1811,7 @@ CT_DoFetch()
elif [ "${src_custom}" = "y" ]; then elif [ "${src_custom}" = "y" ]; then
# Will be handled during extraction/patching # Will be handled during extraction/patching
version="local" version="local"
basename="${pkg_name}-${version}" basename="${dir_name}"
:; :;
else else
CT_Abort "No known source for ${pkg_name}" CT_Abort "No known source for ${pkg_name}"
@ -1857,22 +1878,46 @@ CT_DoExtractPatch()
local -a patch_dirs local -a patch_dirs
local bundled_patch_dir local bundled_patch_dir
local local_patch_dir local local_patch_dir
local overlay
# If using overlay, prepare it first - we need to determine where to unpack
# this component.
if [ "${CT_TARGET_USE_OVERLAY}" = "y" -a ! -d "${CT_BUILD_DIR}/overlay" ]; then
CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}/overlay"
overlay="${CT_OVERLAY_LOCATION}/${CT_ARCH}_${CT_OVERLAY_NAME:-overlay}"
ext=`CT_GetFileExtension "${overlay}"`
if [ ! -r "${overlay}${ext}" ]; then
CT_Abort "Overlay ${overlay} not found"
fi
CT_Extract "${overlay}${ext}" "${CT_BUILD_DIR}/overlay"
fi
# Can use common location only if using non-custom source, only bundled patches
# and no overlays. Otherwise, this source directory is custom-tailored for this
# particular configuration and cannot be reused by different configurations.
if [ "${src_custom}" != "y" -a \
"${CT_PATCH_ORDER}" = "bundled" -a \
! -d "${CT_BUILD_DIR}/overlay/${dir_name}" ]; then
src_dir="${CT_COMMON_SRC_DIR}"
else
src_dir="${CT_SRC_DIR}"
fi
if [ "${src_custom}" != "y" ]; then if [ "${src_custom}" != "y" ]; then
# Non-custom: extract to shared location # Non-custom: extract to shared location
# If the previous extraction/patching was aborted, clean up. # If the previous extraction/patching was aborted, clean up.
if [ -r "${CT_COMMON_SRC_DIR}/.${basename}.extracting" -o \ if [ -r "${src_dir}/.${basename}.extracting" -o \
-r "${CT_COMMON_SRC_DIR}/.${basename}.patching" ]; then -r "${src_dir}/.${basename}.patching" ]; then
CT_DoLog WARN "Sources for ${basename} were partially extracted/patched, cleaning up" CT_DoLog WARN "Sources for ${basename} were partially extracted/patched, cleaning up"
CT_DoExecLog ALL rm -rf "${CT_COMMON_SRC_DIR}/${basename}" CT_DoExecLog ALL rm -rf "${src_dir}/${basename}"
CT_DoExecLog ALL rm -f "${CT_COMMON_SRC_DIR}/.${basename}".* CT_DoExecLog ALL rm -f "${src_dir}/.${basename}".*
fi fi
if [ -f "${CT_COMMON_SRC_DIR}/.${basename}.extracted" ]; then if [ -f "${src_dir}/.${basename}.extracted" ]; then
CT_DoLog DEBUG "Already extracted ${basename}" CT_DoLog DEBUG "Already extracted ${basename}"
else else
CT_DoLog EXTRA "Extracting ${basename}" CT_DoLog EXTRA "Extracting ${basename}"
CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.extracting" CT_DoExecLog ALL touch "${src_dir}/.${basename}.extracting"
if [ "${src_release}" = "y" ]; then if [ "${src_release}" = "y" ]; then
archive="${archive_filename}" archive="${archive_filename}"
else else
@ -1881,21 +1926,21 @@ CT_DoExtractPatch()
# TBD save/discover the extension while fetching # TBD save/discover the extension while fetching
ext=`CT_GetFileExtension "${CT_TARBALLS_DIR}/${archive}"` ext=`CT_GetFileExtension "${CT_TARBALLS_DIR}/${archive}"`
if [ "${archive_dirname}" = "." ]; then if [ "${archive_dirname}" = "." ]; then
CT_mkdir_pushd "${CT_COMMON_SRC_DIR}/${basename}" CT_mkdir_pushd "${src_dir}/${basename}"
CT_Extract "${CT_TARBALLS_DIR}/${archive}${ext}" "${CT_COMMON_SRC_DIR}/${basename}" CT_Extract "${CT_TARBALLS_DIR}/${archive}${ext}" "${src_dir}/${basename}"
CT_Popd CT_Popd
else else
CT_Extract "${CT_TARBALLS_DIR}/${archive}${ext}" "${CT_COMMON_SRC_DIR}" CT_Extract "${CT_TARBALLS_DIR}/${archive}${ext}" "${src_dir}"
fi fi
CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.extracted" CT_DoExecLog ALL touch "${src_dir}/.${basename}.extracted"
CT_DoExecLog ALL rm -f "${CT_COMMON_SRC_DIR}/.${basename}.extracting" CT_DoExecLog ALL rm -f "${src_dir}/.${basename}.extracting"
fi fi
if [ -f "${CT_COMMON_SRC_DIR}/.${basename}.patched" ]; then if [ -f "${src_dir}/.${basename}.patched" ]; then
CT_DoLog DEBUG "Already patched ${basename}" CT_DoLog DEBUG "Already patched ${basename}"
else else
CT_DoLog EXTRA "Patching ${basename}" CT_DoLog EXTRA "Patching ${basename}"
CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.patching" CT_DoExecLog ALL touch "${src_dir}/.${basename}.patching"
bundled_patch_dir="${CT_LIB_DIR}/packages/${pkg_name}/${version}" bundled_patch_dir="${CT_LIB_DIR}/packages/${pkg_name}/${version}"
local_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkg_name}/${version}" local_patch_dir="${CT_LOCAL_PATCH_DIR}/${pkg_name}/${version}"
@ -1908,7 +1953,7 @@ CT_DoExtractPatch()
none) patch_dirs=;; none) patch_dirs=;;
esac esac
CT_Pushd "${CT_COMMON_SRC_DIR}/${basename}" CT_Pushd "${src_dir}/${basename}"
for d in "${patch_dirs[@]}"; do for d in "${patch_dirs[@]}"; do
CT_DoLog DEBUG "Looking for patches in '${d}'..." CT_DoLog DEBUG "Looking for patches in '${d}'..."
if [ -n "${d}" -a -d "${d}" ]; then if [ -n "${d}" -a -d "${d}" ]; then
@ -1945,8 +1990,8 @@ CT_DoExtractPatch()
CT_Popd CT_Popd
CT_DoExecLog ALL touch "${CT_COMMON_SRC_DIR}/.${basename}.patched" CT_DoExecLog ALL touch "${src_dir}/.${basename}.patched"
CT_DoExecLog ALL rm -f "${CT_COMMON_SRC_DIR}/.${basename}.patching" CT_DoExecLog ALL rm -f "${src_dir}/.${basename}.patching"
fi fi
else else
CT_DoLog WARN "${pkg_name}: using custom location, no patches applied" CT_DoLog WARN "${pkg_name}: using custom location, no patches applied"
@ -1954,50 +1999,33 @@ CT_DoExtractPatch()
# Symlink/copy/overlay into per-target source directory # Symlink/copy/overlay into per-target source directory
if [ "${src_custom}" = "y" ]; then if [ "${src_custom}" = "y" ]; then
# Custom sources: unpack or copy into per-target directory # Custom sources: unpack or copy into per-target directory. Note that
if [ "${CT_TARGET_USE_OVERLAY}" ]; then # ${src_dir} is never ${CT_COMMON_SRC_DIR} in this case.
CT_DoLog WARN "${pkg_name}: using custom location, no overlays applied"
fi
if [ -d "${custom_location}" ]; then if [ -d "${custom_location}" ]; then
CT_DoExecLog ALL cp -av "${custom_location}" "${CT_SRC_DIR}/${dir_name}" CT_DoExecLog ALL cp -av "${custom_location}" "${src_dir}/${dir_name}"
elif [ -f "${custom_location}" ]; then elif [ -f "${custom_location}" ]; then
# Assume "foo.tar.gz" (or likes) contain the "foo" directory # Assume "foo.tar.gz" (or likes) contain the "foo" directory
local bn local bn
CT_Extract "${custom_location}" "${CT_SRC_DIR}" CT_Extract "${custom_location}" "${src_dir}"
bn=`CT_GetFileBasename "${custom_location##*/}"` bn=`CT_GetFileBasename "${custom_location##*/}"`
CT_TestOrAbort "Unknown file extension: ${custom_location}" -n "${bn}" CT_TestOrAbort "Unknown file extension: ${custom_location}" -n "${bn}"
CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/${bn%${ext}}" "${CT_SRC_DIR}/${dir_name}" CT_DoExecLog ALL mv -v "${src_dir}/${bn%${ext}}" "${src_dir}/${dir_name}"
else else
CT_Abort "Neither file nor directory: ${custom_location}" CT_Abort "Neither file nor directory: ${custom_location}"
fi fi
elif [ "${CT_TARGET_USE_OVERLAY}" = "y" ]; then
# Possibly has overlays; check and if it has, copy from common source and apply
# overlays.
local overlay
if [ ! -d "${CT_BUILD_DIR}/overlay" ]; then
CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}/overlay"
overlay="${CT_OVERLAY_LOCATION}/${CT_ARCH}_${CT_OVERLAY_NAME:-overlay}"
ext=`CT_GetFileExtension "${overlay}"`
if [ ! -r "${overlay}${ext}" ]; then
CT_Abort "Overlay ${overlay} not found"
fi
CT_Extract "${overlay}${ext}" "${CT_BUILD_DIR}/overlay"
fi
if [ -d "${CT_BUILD_DIR}/overlay/${dir_name}" ]; then
CT_DoExecLog ALL cp -a "${CT_COMMON_SRC_DIR}/${basename}" "${CT_SRC_DIR}/${dir_name}"
tar cf - -C "${CT_BUILD_DIR}/overlay" "${dir_name}" | \
CT_DoExecLog FILE tar xvf - -C "${CT_SRC_DIR}"
else
# No overlay for this component, just symlink
CT_DoExecLog ALL ln -s "${CT_COMMON_SRC_DIR}/${basename}" "${CT_SRC_DIR}/${dir_name}"
fi
else else
# Common source, just symlink # Common source, just symlink
CT_DoExecLog ALL ln -s "${CT_COMMON_SRC_DIR}/${basename}" "${CT_SRC_DIR}/${dir_name}" CT_DoExecLog ALL ln -s "${src_dir}/${basename}" "${CT_SRC_DIR}/${dir_name}"
fi fi
# Check if it has overlays and if it has, apply
if [ "${CT_TARGET_USE_OVERLAY}" = "y" -a \
-d "${CT_BUILD_DIR}/overlay/${dir_name}" ]; then
tar cf - -C "${CT_BUILD_DIR}/overlay" "${dir_name}" | \
CT_DoExecLog FILE tar xvf - -C "${src_dir}"
fi
} }
# Extract/copy the sources to the shared source directory, then either symlink # Extract/copy the sources to the shared source directory, then either symlink
@ -2011,13 +2039,12 @@ CT_ExtractPatch()
CT_PackageRun "${pkg}" CT_DoExtractPatch "$@" CT_PackageRun "${pkg}" CT_DoExtractPatch "$@"
} }
CT_DoGetPkgVersion() # Set the specified variable to the version of the package (main or fork)
{ # Usage: CT_GetPkgVersion PKG VAR
echo "${version}"
}
# Get the version of the package (main or fork)
CT_GetPkgVersion() CT_GetPkgVersion()
{ {
CT_PackageRun "${1}" CT_DoGetPkgVersion local rv
__do_GetPkgVersion() { rv="${version}"; }
CT_PackageRun "${1}" __do_GetPkgVersion
eval "${2}=\"${rv}\""
} }