This is an automated email from the ASF dual-hosted git repository. granthenke pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 737877d3456d1b031222ba4825b6913bafac8495 Author: Grant Henke <[email protected]> AuthorDate: Wed Jan 6 08:26:18 2021 -0600 [build] Automate using GCC-8 on SLES 12 When building Kudu on SLES 12 a newer version of GCC is required. This patch adjusts the documentation and automates the use of GCC-8 via the `enable_devtoolset.sh` script. This matches how we use newer dev toolsets on RHEL based systems. Change-Id: I50237cc900c9450bf1b5fbc7866353c17e3ef10b Reviewed-on: http://gerrit.cloudera.org:8080/16927 Tested-by: Kudu Jenkins Reviewed-by: Alexey Serbin <[email protected]> --- .../{enable_devtoolset.sh => ccache-gcc-8/c++} | 22 ++---------- .../{enable_devtoolset.sh => ccache-gcc-8/cc} | 22 ++---------- build-support/enable_devtoolset.sh | 40 +++++++++++++++++----- docs/installation.adoc | 24 +++++++++---- thirdparty/preflight.py | 2 +- 5 files changed, 56 insertions(+), 54 deletions(-) diff --git a/build-support/enable_devtoolset.sh b/build-support/ccache-gcc-8/c++ similarity index 50% copy from build-support/enable_devtoolset.sh copy to build-support/ccache-gcc-8/c++ index d2966b9..b3aab92 100755 --- a/build-support/enable_devtoolset.sh +++ b/build-support/ccache-gcc-8/c++ @@ -1,5 +1,4 @@ -#!/bin/bash -# +#!/bin/bash -e # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -17,21 +16,6 @@ # specific language governing permissions and limitations # under the License. # -# Enables the Red Hat devtoolset and executes the arguments on RHEL-based -# systems where the default C++ compiler does not support all features -# necessary to compile Kudu from source (C++17). On other (newer) RHEL-based -# systems and non-RHEL systems, the arguments are executed without changes -# to the environment. -# -# USAGE: ./enable_devtoolset.sh <command> <args>... +# Helper script that invokes gcc-8's c++ via ccache. -set -e -if [[ "$OSTYPE" =~ ^linux ]] && \ - [[ "$(lsb_release -irs)" =~ (CentOS|RedHatEnterpriseServer|OracleServer)[[:space:]]+(6|7)\.[[:digit:]]+ ]]; then - # Invoke the inner script, which may do some additional customization within - # the devtoolset. - ROOT=$(cd $(dirname "$BASH_SOURCE") ; pwd) - scl enable devtoolset-8 "$ROOT/enable_devtoolset_inner.sh $*" -else - $@ -fi +exec ccache /usr/bin/g++-8 "$@" \ No newline at end of file diff --git a/build-support/enable_devtoolset.sh b/build-support/ccache-gcc-8/cc similarity index 50% copy from build-support/enable_devtoolset.sh copy to build-support/ccache-gcc-8/cc index d2966b9..18a0ed8 100755 --- a/build-support/enable_devtoolset.sh +++ b/build-support/ccache-gcc-8/cc @@ -1,5 +1,4 @@ -#!/bin/bash -# +#!/bin/bash -e # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -17,21 +16,6 @@ # specific language governing permissions and limitations # under the License. # -# Enables the Red Hat devtoolset and executes the arguments on RHEL-based -# systems where the default C++ compiler does not support all features -# necessary to compile Kudu from source (C++17). On other (newer) RHEL-based -# systems and non-RHEL systems, the arguments are executed without changes -# to the environment. -# -# USAGE: ./enable_devtoolset.sh <command> <args>... +# Helper script that invokes gcc-8's c++ via ccache. -set -e -if [[ "$OSTYPE" =~ ^linux ]] && \ - [[ "$(lsb_release -irs)" =~ (CentOS|RedHatEnterpriseServer|OracleServer)[[:space:]]+(6|7)\.[[:digit:]]+ ]]; then - # Invoke the inner script, which may do some additional customization within - # the devtoolset. - ROOT=$(cd $(dirname "$BASH_SOURCE") ; pwd) - scl enable devtoolset-8 "$ROOT/enable_devtoolset_inner.sh $*" -else - $@ -fi +exec ccache /usr/bin/gcc-8 "$@" diff --git a/build-support/enable_devtoolset.sh b/build-support/enable_devtoolset.sh index d2966b9..81e1cb3 100755 --- a/build-support/enable_devtoolset.sh +++ b/build-support/enable_devtoolset.sh @@ -17,21 +17,45 @@ # specific language governing permissions and limitations # under the License. # -# Enables the Red Hat devtoolset and executes the arguments on RHEL-based -# systems where the default C++ compiler does not support all features -# necessary to compile Kudu from source (C++17). On other (newer) RHEL-based -# systems and non-RHEL systems, the arguments are executed without changes -# to the environment. +# If on a RHEL-based system where the default C++ compiler does not support +# all features necessary to compile Kudu from source (C++17), this script +# enables the Red Hat devtoolset and executes the arguments. +# +# If on a SUSE-based system where the default C++ compiler does not support +# all features necessary to compile Kudu from source (C++17), this script +# enables the GCC-8 compiler as the default CC and GCC. +# +# On other any other systems, the arguments are executed without changes to +# the environment. # # USAGE: ./enable_devtoolset.sh <command> <args>... set -e + +ROOT=$(cd $(dirname "$BASH_SOURCE") ; pwd) + if [[ "$OSTYPE" =~ ^linux ]] && \ [[ "$(lsb_release -irs)" =~ (CentOS|RedHatEnterpriseServer|OracleServer)[[:space:]]+(6|7)\.[[:digit:]]+ ]]; then - # Invoke the inner script, which may do some additional customization within - # the devtoolset. - ROOT=$(cd $(dirname "$BASH_SOURCE") ; pwd) + # Enable devtoolset-8 and invoke the inner script, which may do some + # additional customization within the devtoolset. scl enable devtoolset-8 "$ROOT/enable_devtoolset_inner.sh $*" +elif [[ "$OSTYPE" =~ ^linux ]] && \ + [[ "$(lsb_release -irs)" =~ (SUSE)[[:space:]]+12\.[[:digit:]]+ ]]; then + # If ccache was on the PATH and CC/CXX have not already been set, + # set them to gcc-8 specific ccache helper scripts (thus enabling ccache). + if which ccache > /dev/null 2>&1 && [ ! "$CC" -a ! "$CXX" ]; then + export CC="$ROOT/ccache-gcc-8/cc" + export CXX="$ROOT/ccache-gcc-8/c++" + fi + + # If CC/CXX have not already been set, set them to gcc-8. + if [ ! "$CC" -a ! "$CXX" ]; then + export CC="/usr/bin/gcc-8" + export CXX="/usr/bin/g++-8" + fi + + # Execute the arguments + $@ else $@ fi diff --git a/docs/installation.adoc b/docs/installation.adoc index ffce4be..e463682 100644 --- a/docs/installation.adoc +++ b/docs/installation.adoc @@ -99,8 +99,8 @@ $ sudo yum install autoconf automake cyrus-sasl-devel cyrus-sasl-gssapi \ ---- . If building on RHEL or CentOS older than 8.0, install the Red Hat Developer Toolset. -. Below are the steps required for CentOS. If you are on RHEL, follow their documentation -. [here:https://developers.redhat.com/products/developertoolset/hello-world]. +Below are the steps required for CentOS. If you are on RHEL, follow their documentation +https://developers.redhat.com/products/developertoolset/hello-world[here]. + ---- $ sudo yum install centos-release-scl-rh @@ -399,9 +399,15 @@ $ sudo zypper install autoconf automake curl cyrus-sasl-devel \ pkg-config python rsync unzip vim ---- +. If you are building on SUSE 12 or older, install GCC-8. ++ +---- +$ sudo zypper install gcc8 gcc8-c++ +---- + . Optional: If support for Kudu's NVM (non-volatile memory) block cache is desired, install the memkind library. -+ ++__ ---- $ sudo zypper install memkind ---- @@ -431,7 +437,7 @@ $ cd kudu + [source,bash] ---- -$ thirdparty/build-if-necessary.sh +$ build-support/enable_devtoolset.sh thirdparty/build-if-necessary.sh ---- . Build Kudu, using the utilities installed in the previous step. Choose a build @@ -442,7 +448,8 @@ except for the `kudu` directory itself. ---- mkdir -p build/release cd build/release -../../thirdparty/installed/common/bin/cmake \ +../../build-support/enable_devtoolset.sh \ + ../../thirdparty/installed/common/bin/cmake \ -DCMAKE_BUILD_TYPE=release ../.. make -j4 ---- @@ -460,6 +467,7 @@ E.g., use the following variation of `cmake` command if you need to install only libraries and headers: [source,bash] ---- +../../build-support/enable_devtoolset.sh \ ../../thirdparty/installed/common/bin/cmake \ -DKUDU_CLIENT_INSTALL=OFF \ -DKUDU_TSERVER_INSTALL=OFF \ @@ -501,12 +509,14 @@ sudo zypper install -y autoconf automake curl cyrus-sasl-devel \ cyrus-sasl-gssapi flex gcc gcc-c++ gdb git java-1_8_0-openjdk-devel \ krb5-devel libtool lsb-release make ntp openssl-devel patch \ pkg-config python rsync unzip vim +sudo zypper install gcc8 gcc8-c++ git clone https://github.com/apache/kudu cd kudu -thirdparty/build-if-necessary.sh +build-support/enable_devtoolset.sh thirdparty/build-if-necessary.sh mkdir -p build/release cd build/release -../../thirdparty/installed/common/bin/cmake \ +../../build-support/enable_devtoolset.sh \ + ../../thirdparty/installed/common/bin/cmake \ -DCMAKE_BUILD_TYPE=release \ ../.. make -j4 diff --git a/thirdparty/preflight.py b/thirdparty/preflight.py index 89fd6ce..f8fc0dd 100755 --- a/thirdparty/preflight.py +++ b/thirdparty/preflight.py @@ -154,7 +154,7 @@ def check_openssl(): def main(): print("Running pre-flight checks") print("-------------------------") - print("Using C compiler: " + CXX) + print("Using C compiler: " + CC) print("Using C++ compiler: " + CXX) print("") print(" (Set $CC and $CXX to change compiler)")
