diff --git a/tools/extras/install_srilm.sh b/tools/extras/install_srilm.sh index 3b3a9e9d69b..5d709e8a38b 100755 --- a/tools/extras/install_srilm.sh +++ b/tools/extras/install_srilm.sh @@ -29,6 +29,15 @@ mkdir -p srilm cd srilm tar -xvzf ../srilm.tgz +major=`awk -F. '{ print $1 }' RELEASE` +minor=`awk -F. '{ print $2 }' RELEASE` +micro=`awk -F. '{ print $3 }' RELEASE` + +if [ $major -le 1 ] && [ $minor -le 7 ] && [ $micro -le 1 ]; then + echo "Detected version 1.7.1 or earlier. Applying patch." + patch -p0 < ../extras/srilm.patch +fi + # set the SRILM variable in the top-level Makefile to this directory. cp Makefile tmpf diff --git a/tools/extras/srilm.patch b/tools/extras/srilm.patch new file mode 100644 index 00000000000..c54ad21aa8b --- /dev/null +++ b/tools/extras/srilm.patch @@ -0,0 +1,17 @@ +--- dstruct/src/Trie.orig 2016-11-08 19:53:40.524000000 +0000 ++++ dstruct/src/Trie.cc 2016-11-08 19:53:59.088000000 +0000 +@@ -200,11 +200,14 @@ + if (removedData == 0) { + Trie node; + if (sub.remove(keys[0], &node)) { ++#if !defined(__GNUC__) || !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 9 || __GNUC__ > 4) + /* + * XXX: Call subtrie destructor explicitly since we're not + * passing the removed node to the caller. ++ * !!! Triggers bug with gcc >= 4.9 optimization !!! + */ + node.~Trie(); ++#endif + return true; + } else { + return false;