Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
[build] Bump minimum compiler versions and enable C++14 (kaldi-asr#4503)
Browse files Browse the repository at this point in the history
https://groups.google.com/g/kaldi-help/c/DkoacGpwGJ4/m/Zgj78rgfAgAJ
New minimum versions:
===================================
                Min. req. version:
Compiler       Current       New
===========    =======     ========
GCC             4.9.1   >    5.0
LLVM Clang      3.3     >    3.5
XCode Clang     5.0     >    6.0
===================================

At the same time, upgrade OpenFST to 1.7.2 (which I've been
using for quite a while without a glitch).

Close: kaldi-asr#4297
Close: kaldi-asr#4245
  • Loading branch information
kkm000 authored Apr 22, 2021
1 parent b0cfadf commit 38b8036
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 56 deletions.
72 changes: 36 additions & 36 deletions src/configure
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# This should be incremented after any significant change to the configure
# script, i.e. any change affecting kaldi.mk or the build system as a whole.
CONFIGURE_VERSION=12
CONFIGURE_VERSION=13

# We support bash version 3.2 (Macs still ship with this version as of 2019)
# and above.
Expand Down Expand Up @@ -95,7 +95,7 @@ Configuration options:
--host=HOST Host triple in the format 'cpu-vendor-os'
If provided, it is prepended to all toolchain programs.
--android-incdir=DIR Android include directory
--enable-kenlm enable kenlm runtime library installed in "../tools/kenlm"
--enable-kenlm enable kenlm runtime library installed in "../tools/kenlm"
via extras/install_kenlm_query_only.sh, [default=no]
Following environment variables can be used to override the default toolchain.
Expand Down Expand Up @@ -188,43 +188,43 @@ function check_library {
function check_compiler {

# Part of error message.
local supported_compiler="GNU g++ >= 4.7, Apple clang >= 5.0 or LLVM clang >= 3.3"
local supported_compiler="GNU g++ >= 5.0, Apple clang >= 6.0 or LLVM clang >= 3.5"
local compiler=$1
local compiler_ver_info compiler_ver compiler_ver_num

COMPILER=$1
if ! which $COMPILER >&/dev/null; then
failure "$COMPILER is not installed.
compiler_ver_info=$($compiler --version 2>/dev/null) ||
failure "$compiler is not installed.
You need $supported_compiler."
else
COMPILER_VER_INFO=$($COMPILER --version 2>/dev/null)
if [[ $COMPILER_VER_INFO == *[gc]"++"* ]]; then
GCC_VER=$($COMPILER -dumpversion)
GCC_VER_NUM=$(echo $GCC_VER | sed 's/\./ /g' | xargs printf "%d%02d%02d")
if [ $GCC_VER_NUM -lt 40700 ]; then
failure "$COMPILER (g++-$GCC_VER) is not supported.

case $compiler_ver_info in
*[gc]++*)
compiler_ver=$($compiler -dumpversion)
compiler_ver_num=$(echo $compiler_ver | sed 's/\./ /g' | xargs printf "%d%02d%02d")
(( compiler_ver_num < 50000 )) &&
failure "$compiler (g++-$compiler_ver) is not supported.
You need $supported_compiler."
elif [ $GCC_VER_NUM == 40801 ] || [ $GCC_VER_NUM == 40802 ]; then
failure "$COMPILER (g++-$GCC_VER) is not supported.
GCC 4.8.1 and 4.8.2 have a bug in the implementation of the nth_element
algorithm provided by the standard library. This will cause Kaldi to crash
(make test would fail). Please use another C++ compiler with C++11 support:
$supported_compiler."
fi
elif [[ $COMPILER_VER_INFO == *"Apple"* ]]; then
CLANG_VER=$(echo $COMPILER_VER_INFO | grep version | sed "s/.*version \([0-9\.]*\).*/\1/")
CLANG_VER_NUM=$(echo $COMPILER_VER_INFO | grep version | sed "s/.*clang-\([0-9]*\).*/\1/")
if [ $CLANG_VER_NUM -lt 500 ]; then
failure "$COMPILER (Apple clang-$CLANG_VER) is not supported.
;;

*Apple*)
compiler_ver=$(echo $compiler_ver_info | grep version | sed "s/.*version \([0-9\.]*\).*/\1/")
compiler_ver_num=$(echo $compiler_ver_info | grep version | sed "s/.*clang-\([0-9]*\).*/\1/")
(( compiler_ver_num < 600 )) &&
failure "$compiler (Apple clang-$compiler_ver) is not supported.
You need $supported_compiler."
fi
elif [[ $COMPILER_VER_INFO == *"LLVM"* ]]; then
CLANG_VER=$(echo $COMPILER_VER_INFO | grep version | sed "s/.*version \([0-9\.]*\).*/\1/")
CLANG_VER_NUM=$(echo $CLANG_VER | sed 's/\./ /g' | xargs printf "%d%02d")
if [ $CLANG_VER_NUM -lt 303 ]; then
failure "$COMPILER (LLVM clang-$CLANG_VER) is not supported.
;;

*LLVM*|*[Cc]lang)
compiler_ver=$(echo $compiler_ver_info | grep version | sed "s/.*version \([0-9\.]*\).*/\1/")
compiler_ver_num=$(echo $compiler_ver | sed 's/\./ /g' | xargs printf "%d%02d")
(( compiler_ver_num < 305 )) &&
failure "$compiler (LLVM clang-$compiler_ver) is not supported.
You need $supported_compiler."
fi
fi
fi
;;

*)
echo >&2 "WARNING: Unfamiliar compiler $compiler. Use at your risk and peril."
esac

}

function check_for_slow_expf {
Expand Down Expand Up @@ -278,7 +278,7 @@ Either your CUDA is too new or too old."

COMPILER_VER_INFO=$($CXX --version 2>/dev/null)
if [[ $COMPILER_VER_INFO == *[gc]"++"* ]]; then
GCC_VER=$($COMPILER -dumpversion)
GCC_VER=$($CXX -dumpversion)
GCC_VER_NUM=$(echo $GCC_VER | sed 's/\./ /g' | xargs printf "%d%02d%02d")
case $CUDA_VERSION in
# Disabling CUDA 7 and CUDA 8 because we now use C++14 to compile CUDA code
Expand Down Expand Up @@ -340,7 +340,7 @@ Either your CUDA is too new or too old."
9_*) CUDA_ARCH="-gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70" ;;
10_*) CUDA_ARCH="-gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75" ;;
11_0) CUDA_ARCH="-gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80" ;;
11_1 | 11_*) CUDA_ARCH="-gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86" ;;
11_1 | 11_*) CUDA_ARCH="-gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86" ;;
*) echo "Unsupported CUDA_VERSION (CUDA_VERSION=$CUDA_VERSION), please report it to Kaldi mailing list, together with 'nvcc -h' or 'ptxas -h' which lists allowed -gencode values..."; exit 1 ;;
esac
;;
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/android_openblas.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $(error Android build does not support compiling with $(CXX).
Supported compilers: clang++)
endif

CXXFLAGS = -std=c++11 -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self -Wno-mismatched-tags \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/cygwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ifndef OPENFSTLIBS
$(error OPENFSTLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -U__STRICT_ANSI__ -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -U__STRICT_ANSI__ -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ifndef OPENFSTLIBS
$(error OPENFSTLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/darwin_clapack.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CLAPACKLIBS = $(CLAPACKROOT)/CLAPACK-3.2.1/lapack.a $(CLAPACKROOT)/CLAPACK-3.2.1
$(CLAPACKROOT)/CBLAS/lib/cblas.a \
$(CLAPACKROOT)/f2c_BLAS-3.8.0/blas.a $(CLAPACKROOT)/libf2c/libf2c.a

CXXFLAGS = -std=c++11 -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -I$(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_atlas.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ifndef ATLASLIBS
$(error ATLASLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_atlas_arm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ifndef ATLASLIBS
$(error ATLASLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_atlas_ppc64le.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ifndef ATLASLIBS
$(error ATLASLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_clapack.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ CLAPACKLIBS = $(CLAPACKROOT)/CLAPACK-3.2.1/lapack.a $(CLAPACKROOT)/CLAPACK-3.2.1
$(CLAPACKROOT)/CBLAS/lib/cblas.a \
$(CLAPACKROOT)/f2c_BLAS-3.8.0/blas.a $(CLAPACKROOT)/libf2c/libf2c.a

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_clapack_arm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ifndef OPENFSTLIBS
$(error OPENFSTLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_openblas.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ifndef OPENBLASLIBS
$(error OPENBLASLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_openblas_aarch64.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ifndef OPENBLASLIBS
$(error OPENBLASLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_openblas_arm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ifndef OPENBLASLIBS
$(error OPENBLASLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_openblas_ppc64le.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ifndef OPENBLASLIBS
$(error OPENBLASLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 $(EXTRA_CXXFLAGS) \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
2 changes: 1 addition & 1 deletion src/makefiles/linux_x86_64_mkl.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ifndef OPENFSTLIBS
$(error OPENFSTLIBS not defined.)
endif

CXXFLAGS = -std=c++11 -I.. -isystem $(OPENFSTINC) -O1 \
CXXFLAGS = -std=c++14 -I.. -isystem $(OPENFSTINC) -O1 \
-Wall -Wno-sign-compare -Wno-unused-local-typedefs \
-Wno-deprecated-declarations -Winit-self \
-DKALDI_DOUBLEPRECISION=$(DOUBLE_PRECISION) \
Expand Down
10 changes: 4 additions & 6 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ CC ?= gcc # used for sph2pipe

WGET ?= wget

# Note: OpenFst requires a relatively recent C++ compiler with C++11 support,
# e.g. g++ >= 4.7, Apple clang >= 5.0 or LLVM clang >= 3.3.
OPENFST_VERSION ?= 1.6.7
OPENFST_VERSION ?= 1.7.2
CUB_VERSION ?= 1.8.0
# No '?=', since there exists only one version of sph2pipe.
SPH2PIPE_VERSION = 2.5
Expand All @@ -22,9 +20,9 @@ OPENFST_CONFIGURE ?= --enable-static --enable-shared --enable-far \
--enable-ngram-fsts --enable-lookahead-fsts --with-pic

OPENFST_VER_NUM := $(shell echo $(OPENFST_VERSION) | sed 's/\./ /g' | xargs printf "%d%02d%02d")
ifeq ("$(shell expr $(OPENFST_VER_NUM) \< 10600)","1")
ifeq ("$(shell expr $(OPENFST_VER_NUM) \< 10607)","1")
$(error OpenFst-$(OPENFST_VERSION) is not supported. \
Supported versions: >= 1.6.0)
Supported versions: >= 1.6.7)
endif

.PHONY: all clean distclean
Expand Down Expand Up @@ -84,7 +82,7 @@ endif
openfst-$(OPENFST_VERSION)/Makefile: openfst-$(OPENFST_VERSION)
cd openfst-$(OPENFST_VERSION)/ && \
./configure --prefix=`pwd` $(OPENFST_CONFIGURE) CXX="$(CXX)" \
CXXFLAGS="$(CXXFLAGS) $(openfst_add_CXXFLAGS)" \
CXXFLAGS="$(openfst_add_CXXFLAGS) $(CXXFLAGS)" \
LDFLAGS="$(LDFLAGS)" LIBS="-ldl"

openfst-$(OPENFST_VERSION): openfst-$(OPENFST_VERSION).tar.gz
Expand Down

0 comments on commit 38b8036

Please sign in to comment.