From 0953f41c13a2b42a46059c956cf2b4f1c88c9af5 Mon Sep 17 00:00:00 2001 From: Simon Stelling Date: Sat, 11 Mar 2006 23:38:30 +0000 Subject: [PATCH] we've had enough ricer bugs for a while... this profile.bashrc filters out any flag that isn't recognized by the compiler (will make the -fPIC configure test fail) and spit out a warning. also spit out warnings for the flags that should never get set by the user (-m32, -fPIC, -fvisibility=hidden to name a few) --- profiles/default-linux/amd64/profile.bashrc | 65 +++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 profiles/default-linux/amd64/profile.bashrc diff --git a/profiles/default-linux/amd64/profile.bashrc b/profiles/default-linux/amd64/profile.bashrc new file mode 100644 index 000000000000..d67aee64b2e8 --- /dev/null +++ b/profiles/default-linux/amd64/profile.bashrc @@ -0,0 +1,65 @@ +getPROG() { + local var=$1 + local prog=$2 + + if [[ -n ${!var} ]] ; then + echo "${!var}" + return 0 + fi + + local search= + [[ -n $3 ]] && search=$(type -p "$3-${prog}") + [[ -z ${search} && -n ${CHOST} ]] && search=$(type -p "${CHOST}-${prog}") + [[ -n ${search} ]] && prog=${search##*/} + + export ${var}=${prog} + echo "${!var}" +} + +hasme() { + local x + + local me=$1 + shift + for x in "$@"; do + if [ "${x}" == "${me}" ]; then + return 0 + fi + done + return 1 +} + +test_broken_flags() { + local mygcc=${1} + shift + echo 'main(){}' | ${mygcc} ${@} -E - 2>&1 | egrep "unrecognized .*option" \ + | egrep -o -- '('\''|\"|`)-.*' | sed -r 's/('\''|`|")//g' +} + +if [[ ${EBUILD_PHASE} == "setup" ]]; then + trigger=0 + for flag in ${CFLAGS} ; do + broken_flag=$(test_broken_flags $(getPROG CC gcc) ${flag}) + if [[ -n ${broken_flag} ]]; then + ewarn "Filtering out the non-existing CFLAG \"${broken_flag}\"" + CFLAGS=${CFLAGS//${broken_flag}} + fi + done + for flag in ${CXXFLAGS} ; do + broken_flag=$(test_broken_flags $(getPROG CXX g++) ${flag}) + if [[ -n ${broken_flag} ]]; then + ewarn "Filtering out the non-existing CXXFLAG \"${broken_flag}\"" + CXXFLAGS=${CXXFLAGS//${broken_flag}} + fi + done + for flag in "-fvisibility=hidden" "-fvisibility-hidden" "-fvisibility-inline-hidden" "-fPIC" "-fweb" "-m32" "-m64" "-g3" "-ggdb3" ; do + hasme ${flag} ${CFLAGS} ${CXXFLAGS} && trigger=1 && \ + ewarn "Your C(XX)FLAGS contain(s) \"${flag}\" which can break packages." + done + if [[ ${trigger} -ge 1 ]]; then + ewarn "" + ewarn "Before you file a bug please remove these flags and " + ewarn "re-compile the package in question as well as all its dependencies" + fi +fi +unset trigger broken_flag -- 2.26.2