Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Cross #722

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Cross #722

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
cf5d9bf
compilers_generic + crosstool-ng_generic: Added
mingwandroid Apr 15, 2017
d871b94
crosstool-ng_generic: Remove lto patch as it's in diorcety linux-targ…
mingwandroid Apr 28, 2017
a0911d9
compilers_generic: Remove imx351uc-isms
mingwandroid Apr 28, 2017
7e17b94
Tidy-ups, mostly from SARC
mingwandroid Apr 28, 2017
28e6232
compilers_generic more generic
mingwandroid Apr 29, 2017
50983ee
gnu => gnueabi, not generic ..
mingwandroid May 4, 2017
3c1c493
Add another duma dl url
mingwandroid May 4, 2017
553d387
compilers_generic: Resync with SARC changes
mingwandroid May 4, 2017
d14911f
Sourceforge mirrors are flaky (as usual) so allow SF to pick
mingwandroid May 4, 2017
05ef518
compilers_generic: Allow STUB_FAMILY_VERSION too (GCC needs this)
mingwandroid May 4, 2017
6403b47
fix activate.sh.bak removal, exit 0 at end.
mingwandroid May 4, 2017
621843e
compilers_generic: More resyncing
mingwandroid May 4, 2017
870e8ed
compilers_generic: Use gnu not glibc
mingwandroid May 5, 2017
98d5bfc
compilers_generic: target_platform back to cross_target_platform
mingwandroid May 5, 2017
92f5e27
compilers_generic: Skip rebuild if gfortran found, not .config program
mingwandroid May 5, 2017
a69bede
compilers_generic: Install GCCs liblto_plugin.so too
mingwandroid May 8, 2017
2efb442
specfile + gfortran fixes
mingwandroid Jun 2, 2017
e4452c6
Filter out problematic vars from the ct-ng sample
mingwandroid Jun 3, 2017
7b76034
more fortran fixes
mingwandroid Jun 3, 2017
0c2feca
compilers_generic: --enable-default-pie
mingwandroid Jun 4, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions cross-compilers/compilers_generic/activate-binutils.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# This function takes no arguments
# It tries to determine the name of this file in a programatic way.
function _get_sourced_filename() {
if [ -n "${BASH_SOURCE[0]}" ]; then
basename "${BASH_SOURCE[0]}"
elif [ -n "${(%):-%x}" ]; then
# in zsh use prompt-style expansion to introspect the same information
# see http://stackoverflow.com/questions/9901210/bash-source0-equivalent-in-zsh
basename "${(%):-%x}"
else
echo "UNKNOWN FILE"
fi
}

# The arguments to this are:
# 1. activation nature {activate|deactivate}
# 2. toolchain nature {build|host|ccc}
Expand Down Expand Up @@ -68,18 +82,16 @@ function _tc_activation() {
return 0
}

# We would like to add "-fstack-protector --param=ssp-buffer-size" to {C,CXX}FLAGS
# but uClibc has poor (or no) support for it.
env > /tmp/old-env-$$.txt
_tc_activation \
activate host @CHOST@ @CHOST@- \
addr2line ar as c++filt elfedit gprof ld nm objcopy objdump ranlib readelf size strings strip

if [ $? -ne 0 ]; then
echo "ERROR: $(basename ${BASH_SOURCE[0]}) failed, see above for details"
echo "ERROR: $(_get_sourced_filename) failed, see above for details"
#exit 1
else
env > /tmp/new-env-$$.txt
echo "INFO: $(basename ${BASH_SOURCE[0]}) made the following environmental changes:"
echo "INFO: $(_get_sourced_filename) made the following environmental changes:"
diff -U 0 -rN /tmp/old-env-$$.txt /tmp/new-env-$$.txt | tail -n +4 | grep "^-.*\|^+.*" | grep -v "CONDA_BACKUP_" | sort
fi
24 changes: 18 additions & 6 deletions cross-compilers/compilers_generic/activate-g++.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# This function takes no arguments
# It tries to determine the name of this file in a programatic way.
function _get_sourced_filename() {
if [ -n "${BASH_SOURCE[0]}" ]; then
basename "${BASH_SOURCE[0]}"
elif [ -n "${(%):-%x}" ]; then
# in zsh use prompt-style expansion to introspect the same information
# see http://stackoverflow.com/questions/9901210/bash-source0-equivalent-in-zsh
basename "${(%):-%x}"
else
echo "UNKNOWN FILE"
fi
}

# The arguments to this are:
# 1. activation nature {activate|deactivate}
# 2. toolchain nature {build|host|ccc}
Expand Down Expand Up @@ -68,20 +82,18 @@ function _tc_activation() {
return 0
}

# We would like to add "-fstack-protector --param=ssp-buffer-size" to {C,CXX}FLAGS
# but uClibc has poor (or no) support for it.
env > /tmp/old-env-$$.txt
_tc_activation \
activate host @CHOST@ @CHOST@- \
c++ g++ \
"CXXFLAGS,${CXXFLAGS:--std=c++11 -march=armv6k -mtune=arm1136jf-s -mfloat-abi=soft -mabi=aapcs-linux -mtls-dialect=gnu -fPIC -fPIE -fvisibility-inlines-hidden -O2 -pipe}" \
"DEBUG_CXXFLAGS,${DEBUG_CXXFLAGS:--Og -g -fvar-tracking-assignments}"
"CXXFLAGS,${CXXFLAGS:-@CXXFLAGS@}" \
"DEBUG_CXXFLAGS,${DEBUG_CXXFLAGS:-@DEBUG_CXXFLAGS@}"

if [ $? -ne 0 ]; then
echo "ERROR: $(basename ${BASH_SOURCE[0]}) failed, see above for details"
echo "ERROR: $(_get_sourced_filename) failed, see above for details"
#exit 1
else
env > /tmp/new-env-$$.txt
echo "INFO: $(basename ${BASH_SOURCE[0]}) made the following environmental changes:"
echo "INFO: $(_get_sourced_filename) made the following environmental changes:"
diff -U 0 -rN /tmp/old-env-$$.txt /tmp/new-env-$$.txt | tail -n +4 | grep "^-.*\|^+.*" | grep -v "CONDA_BACKUP_" | sort
fi
28 changes: 20 additions & 8 deletions cross-compilers/compilers_generic/activate-gcc.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# This function takes no arguments
# It tries to determine the name of this file in a programatic way.
function _get_sourced_filename() {
if [ -n "${BASH_SOURCE[0]}" ]; then
basename "${BASH_SOURCE[0]}"
elif [ -n "${(%):-%x}" ]; then
# in zsh use prompt-style expansion to introspect the same information
# see http://stackoverflow.com/questions/9901210/bash-source0-equivalent-in-zsh
basename "${(%):-%x}"
else
echo "UNKNOWN FILE"
fi
}

# The arguments to this are:
# 1. activation nature {activate|deactivate}
# 2. toolchain nature {build|host|ccc}
Expand Down Expand Up @@ -68,22 +82,20 @@ function _tc_activation() {
return 0
}

# We would like to add "-fstack-protector --param=ssp-buffer-size" to {C,CXX}FLAGS
# but uClibc has poor (or no) support for it.
env > /tmp/old-env-$$.txt
_tc_activation \
activate host @CHOST@ @CHOST@- \
cc cpp gcc gcc-ar gcc-nm gcc-ranlib \
"CPPFLAGS,${CPPFLAGS:--D_FORTIFY_SOURCE=2}" \
"CFLAGS,${CFLAGS:--march=armv6k -mtune=arm1136jf-s -mfloat-abi=soft -mabi=aapcs-linux -mtls-dialect=gnu -fPIC -fPIE -O2 -pipe}" \
"LDFLAGS,${LDFLAGS:--Wl,-O1,--sort-common,--as-needed,-z,relro}" \
"DEBUG_CFLAGS,${DEBUG_CFLAGS:--Og -g -fvar-tracking-assignments}"
"CPPFLAGS,${CPPFLAGS:-@CPPFLAGS@}" \
"CFLAGS,${CFLAGS:-@CFLAGS@}" \
"LDFLAGS,${LDFLAGS:-@LDFLAGS@}" \
"DEBUG_CFLAGS,${DEBUG_CFLAGS:-@DEBUG_CFLAGS@}"

if [ $? -ne 0 ]; then
echo "ERROR: $(basename ${BASH_SOURCE[0]}) failed, see above for details"
echo "ERROR: $(_get_sourced_filename) failed, see above for details"
#exit 1
else
env > /tmp/new-env-$$.txt
echo "INFO: $(basename ${BASH_SOURCE[0]}) made the following environmental changes:"
echo "INFO: $(_get_sourced_filename) made the following environmental changes:"
diff -U 0 -rN /tmp/old-env-$$.txt /tmp/new-env-$$.txt | tail -n +4 | grep "^-.*\|^+.*" | grep -v "CONDA_BACKUP_" | sort
fi
29 changes: 22 additions & 7 deletions cross-compilers/compilers_generic/activate-gfortran.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
#!/bin/bash

# This function takes no arguments
# It tries to determine the name of this file in a programatic way.
function _get_sourced_filename() {
if [ -n "${BASH_SOURCE[0]}" ]; then
basename "${BASH_SOURCE[0]}"
elif [ -n "${(%):-%x}" ]; then
# in zsh use prompt-style expansion to introspect the same information
# see http://stackoverflow.com/questions/9901210/bash-source0-equivalent-in-zsh
basename "${(%):-%x}"
else
echo "UNKNOWN FILE"
fi
}

# The arguments to this are:
# 1. activation nature {activate|deactivate}
# 2. toolchain nature {build|host|ccc}
Expand Down Expand Up @@ -68,21 +82,22 @@ function _tc_activation() {
return 0
}

# We would like to add "-fstack-protector --param=ssp-buffer-size" to {C,CXX}FLAGS
# but uClibc has poor (or no) support for it.
env > /tmp/old-env-$$.txt
_tc_activation \
activate host @CHOST@ @CHOST@- \
gfortran f95 \
"FFLAGS,${FFLAGS:--march=nocona -Wall -Wextra -O3}" \
"FORTRANFLAGS,${FORTRANFLAGS:--march=nocona -Wall -Wextra -O3}" \
"DEBUG_FFLAGS,${DEBUG_FFLAGS:--Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none}"
"FFLAGS,${FFLAGS:-@FFLAGS@}" \
"FORTRANFLAGS,${FORTRANFLAGS:-@FFLAGS@}" \
"DEBUG_FFLAGS,${DEBUG_FFLAGS:-@FFLAGS@ @DEBUG_FFLAGS@}"

# extra one - doesn't quite match the naming scheme that works for everything else.
export FC="$GFORTRAN"

if [ $? -ne 0 ]; then
echo "ERROR: $(basename ${BASH_SOURCE[0]}) failed, see above for details"
echo "ERROR: $(_get_sourced_filename) failed, see above for details"
#exit 1
else
env > /tmp/new-env-$$.txt
echo "INFO: $(basename ${BASH_SOURCE[0]}) made the following environmental changes:"
echo "INFO: $(_get_sourced_filename) made the following environmental changes:"
diff -U 0 -rN /tmp/old-env-$$.txt /tmp/new-env-$$.txt | tail -n +4 | grep "^-.*\|^+.*" | grep -v "CONDA_BACKUP_" | sort
fi
114 changes: 75 additions & 39 deletions cross-compilers/compilers_generic/build.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
#!/bin/bash

CHOST="${cpu_arch}-${vendor}-linux-uclibcgnueabi"
mkdir -p .build/src
mkdir -p .build/tarballs

# Necessary because crosstool-ng looks in the wrong location for this one.
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/linux-3.2.43.tar.xz" ]]; then
curl -L https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.43.tar.xz -o ${SYS_PREFIX}/conda-bld/src_cache/linux-3.2.43.tar.xz
# Some kernels are not on kernel.org, such as the CentOS 5.11 one used (and heavily patched) by RedHat.
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/linux-${kernel}.tar.bz2" ]] && \
[[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/linux-${kernel}.tar.xz" ]]; then
if [[ ${kernel} == 2.6.* ]]; then
curl -L ftp://ftp.be.debian.org/pub/linux/kernel/v2.6/linux-${kernel}.tar.bz2 -o ${SYS_PREFIX}/conda-bld/src_cache/linux-${kernel}.tar.bz2
elif [[ ${kernel} == 3.* ]]; then
# Necessary because crosstool-ng looks in the wrong location for this one.
curl -L https://www.kernel.org/pub/linux/kernel/v3.x/linux-${kernel}.tar.bz2 -o ${SYS_PREFIX}/conda-bld/src_cache/linux-${kernel}.tar.bz2
elif [[ ${kernel} == 4.* ]]; then
curl -L https://www.kernel.org/pub/linux/kernel/v4.x/linux-${kernel}.tar.xz -o ${SYS_PREFIX}/conda-bld/src_cache/linux-${kernel}.tar.xz
fi
fi

# Necessary because uclibc let their certificate expire.
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/uClibc-0.9.33.2.tar.xz" ]]; then
curl -L --insecure https://www.uclibc.org/downloads/uClibc-0.9.33.2.tar.xz -o ${SYS_PREFIX}/conda-bld/src_cache/uClibc-0.9.33.2.tar.xz
# Necessary because uclibc let their certificate expire, this is a bit hacky.
if [[ ${libc} == uClibc ]]; then
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/uClibc-${uClibc}.tar.xz" ]]; then
curl -L --insecure https://www.uclibc.org/downloads/uClibc-${uClibc}.tar.xz -o ${SYS_PREFIX}/conda-bld/src_cache/uClibc-${uClibc}.tar.xz
fi
else
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/glibc-${gnu}.tar.bz2" ]]; then
curl -L --insecure https://ftp.gnu.org/gnu/libc/glibc-${gnu}.tar.bz2 -o ${SYS_PREFIX}/conda-bld/src_cache/glibc-${gnu}.tar.bz2
fi
fi

# Necessary because CentOS5.11 is having some certificate issues.
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/duma_2_5_15.tar.gz" ]]; then
curl -L --insecure https://dronedata.dl.sourceforge.net/project/duma/duma/2.5.15/duma_2_5_15.tar.gz -o ${SYS_PREFIX}/conda-bld/src_cache/duma_2_5_15.tar.gz
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/duma_${duma//./_}.tar.gz" ]]; then
curl -L --insecure https://sourceforge.net/projects/duma/files/duma/${duma}/duma_${duma//./_}.tar.gz/download -o ${SYS_PREFIX}/conda-bld/src_cache/duma_${duma//./_}.tar.gz
fi

# Ditto.
if [[ ! -e "${SYS_PREFIX}/conda-bld/src_cache/expat-2.2.0.tar.bz2" ]]; then
curl -L --insecure https://dronedata.dl.sourceforge.net/project/expat/expat/2.2.0/expat-2.2.0.tar.bz2 ${SYS_PREFIX}/conda-bld/src_cache/expat-2.2.0.tar.bz2
curl -L --insecure https://sourceforge.net/projects/expat/files/expat/2.2.0/expat-2.2.0.tar.bz2/download -o ${SYS_PREFIX}/conda-bld/src_cache/expat-2.2.0.tar.bz2
fi


BUILD_NCPUS=4
if [ "$(uname)" == "Linux" ]; then
BUILD_NCPUS=$(grep -c ^processor /proc/cpuinfo)
Expand All @@ -33,36 +46,45 @@ elif [ "$OSTYPE" == "msys" ]; then
BUILD_NCPUS=${NUMBER_OF_PROCESSORS}
fi

# If dirty is unset or the g++ binary doesn't exist yet, then run ct-ng
if [[ ! -e "${SRC_DIR}/gcc_built/bin/${CHOST}-g++" ]]; then
bash ${RECIPE_DIR}/write_ctng_config
cp .config .config.emitted
sed -i.bak "s|CT_PARALLEL_JOBS=4|CT_PARALLEL_JOBS=${BUILD_NCPUS}|g" .config
rm .config.bak
# building oldconfig will ensure that the build platform specific crosstool-ng
# configuration values (e.g. CT_CONFIGURE_has_stat_flavor_GNU) get mixed with
# the host platform .config file.
yes "" | ct-ng oldconfig
[[ -d ${SRC_DIR}/gcc_built ]] || mkdir -p ${SRC_DIR}/gcc_built

# If the gfortran binary doesn't exist yet, then run ct-ng
if [[ ! -n $(find ${SRC_DIR}/gcc_built -iname ${cpu_arch}-${vendor}-*-gfortran) ]]; then
source ${RECIPE_DIR}/write_ctng_config

yes "" | ct-ng ${ctng_sample}
write_ctng_config_before .config
# Apply some adjustments for conda.
sed -i.bak "s|# CT_DISABLE_MULTILIB_LIB_OSDIRNAMES is not set|CT_DISABLE_MULTILIB_LIB_OSDIRNAMES=y|g" .config
sed -i.bak "s|CT_CC_GCC_USE_LTO=n|CT_CC_GCC_USE_LTO=y|g" .config
cat .config | grep CT_DISABLE_MULTILIB_LIB_OSDIRNAMES=y || exit 1
cat .config | grep CT_CC_GCC_USE_LTO=y || exit 1
# Not sure why this is getting set to y since it depends on ! STATIC_TOOLCHAIN
sed -i.bak "s|CT_CC_GCC_ENABLE_PLUGINS=y|CT_CC_GCC_ENABLE_PLUGINS=n|g" .config
if [[ ${ctng_nature} == static ]]; then
sed -i.bak "s|CT_CC_GCC_ENABLE_PLUGINS=y|CT_CC_GCC_ENABLE_PLUGINS=n|g" .config
fi
if [[ $(uname) == Darwin ]]; then
sed -i.bak "s|CT_WANTS_STATIC_LINK=y|CT_WANTS_STATIC_LINK=n|g" .config
rm .config.bak
sed -i.bak "s|CT_CC_GCC_STATIC_LIBSTDCXX=y|CT_CC_GCC_STATIC_LIBSTDCXX=n|g" .config
rm .config.bak
sed -i.bak "s|CT_STATIC_TOOLCHAIN=y|CT_STATIC_TOOLCHAIN=n|g" .config
rm .config.bak
sed -i.bak "s|CT_BUILD=\"x86_64-pc-linux-gnu\"|CT_BUILD=\"x86_64-apple-darwin11\"|g" .config
rm .config.bak
cat .config | grep CT_BUILD
fi
# while [[ 1 == 1 ]]; do
# echo "Debug this $(pwd)"
# echo "Debug this ${PATH}"
# sleep 5
# done
# Now ensure any changes we made above pull in other requirements by running oldconfig.
yes "" | ct-ng oldconfig
# Now filter out 'things that cause problems'. For example, depending on the base sample, you can end up with
# two different glibc versions in-play.
sed -i.bak '/CT_LIBC/d' .config
sed -i.bak '/CT_LIBC_GLIBC/d' .config
# And undo any damage to version numbers => the seds above could be moved into this too probably.
write_ctng_config_after .config
if cat .config | grep "CT_GDB_NATIVE=y"; then
if ! cat .config | grep "CT_EXPAT_TARGET=y"; then
echo "ERROR: CT_GDB_NATIVE=y but CT_EXPAT_TARGET!=y"
cat .config
echo "ERROR: CT_GDB_NATIVE=y but CT_EXPAT_TARGET!=y"
exit 1
fi
fi
unset CFLAGS CXXFLAGS LDFLAGS
ct-ng build
fi
Expand All @@ -73,25 +95,39 @@ if [[ $(uname) == Linux ]]; then
ulimit -s 32768
fi

CHOST=$(${SRC_DIR}/.build/*-*-*-*/build/build-cc-gcc-final/gcc/xgcc -dumpmachine)

# pushd .build/${CHOST}/build/build-cc-gcc-final
# make -k check || true
# popd

# .build/src/gcc-${PKG_VERSION}/contrib/test_summary

find . -name "*activate*.sh" -exec sed -i.bak "s|@CHOST@|${CHOST}|g" "{}" \;
find . -name "*activate*.sh.bak" -exec sed rm "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@CPPFLAGS@|${FINAL_CPPFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@CFLAGS@|${FINAL_CFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@DEBUG_CFLAGS@|${FINAL_DEBUG_CFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@CXXFLAGS@|${FINAL_CXXFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@DEBUG_CXXFLAGS@|${FINAL_DEBUG_CXXFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@DEBUG_CXXFLAGS@|${FINAL_DEBUG_CXXFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@FFLAGS@|${FINAL_FFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@DEBUG_FFLAGS@|${FINAL_DEBUG_FFLAGS}|g" "{}" \;
find . -name "*activate*.sh" -exec sed -i.bak "s|@LDFLAGS@|${FINAL_LDFLAGS}|g" "{}" \;

find . -name "*activate*.sh.bak" -exec rm "{}" \;

chmod -R u+w ${SRC_DIR}/gcc_built

# Next problem: macOS targetting uClibc ends up with broken symlinks in sysroot/usr/lib:
if [[ $(uname) == Darwin ]]; then
pushd ${SRC_DIR}/gcc_built/${CHOST}/sysroot/usr/lib
links=$(find . -type l | cut -c 3-)
for link in ${links}; do
target=$(readlink ${link} | sed 's#^/##' | sed 's#//#/#')
rm ${link}
ln -s ${target} ${link}
done
links=$(find . -type l | cut -c 3-)
for link in ${links}; do
target=$(readlink ${link} | sed 's#^/##' | sed 's#//#/#')
rm ${link}
ln -s ${target} ${link}
done
popd
fi

exit 0
36 changes: 0 additions & 36 deletions cross-compilers/compilers_generic/conda_build_config.yaml

This file was deleted.