This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 7747a7c01 [build-support] allow building with gcc/g++-7 on SLES
7747a7c01 is described below

commit 7747a7c0149d6e8f894ad3216c54db9f27b3d372
Author: Alexey Serbin <ale...@apache.org>
AuthorDate: Thu Apr 20 20:51:45 2023 -0700

    [build-support] allow building with gcc/g++-7 on SLES
    
    SLES15 has GCC7 as the system compiler, so Kudu can be built with it
    instead of installing GCC8 packages from the Development Tools Module.
    If both GCC7 and GCC8 are present, prefer GCC8 over GCC7 to build Kudu.
    
    This patch also updates the enable_devtoolset.sh script to properly
    handle the absence of the `lsb_release` binary.
    
    Change-Id: I4fd08cfb1cdc336b44b9568cb4dc019575f01efa
    Reviewed-on: http://gerrit.cloudera.org:8080/19778
    Tested-by: Kudu Jenkins
    Reviewed-by: Ashwani Raina <ara...@cloudera.com>
    Reviewed-by: Yingchun Lai <laiyingc...@apache.org>
---
 build-support/ccache-gcc-7/c++     | 21 ++++++++++++
 build-support/ccache-gcc-7/cc      | 21 ++++++++++++
 build-support/enable_devtoolset.sh | 67 +++++++++++++++++++++++++-------------
 3 files changed, 86 insertions(+), 23 deletions(-)

diff --git a/build-support/ccache-gcc-7/c++ b/build-support/ccache-gcc-7/c++
new file mode 100755
index 000000000..7702ccda8
--- /dev/null
+++ b/build-support/ccache-gcc-7/c++
@@ -0,0 +1,21 @@
+#!/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
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Helper script that invokes gcc-7's c++ via ccache.
+
+exec ccache /usr/bin/g++-7 "$@"
diff --git a/build-support/ccache-gcc-7/cc b/build-support/ccache-gcc-7/cc
new file mode 100755
index 000000000..551d4dc14
--- /dev/null
+++ b/build-support/ccache-gcc-7/cc
@@ -0,0 +1,21 @@
+#!/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
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Helper script that invokes gcc-7's c++ via ccache.
+
+exec ccache /usr/bin/gcc-7 "$@"
diff --git a/build-support/enable_devtoolset.sh 
b/build-support/enable_devtoolset.sh
index 7977d6d0e..ef86daf9a 100755
--- a/build-support/enable_devtoolset.sh
+++ b/build-support/enable_devtoolset.sh
@@ -34,34 +34,55 @@ set -e
 
 ROOT=$(cd $(dirname "$BASH_SOURCE") ; pwd)
 
-if [[ "$OSTYPE" =~ ^linux ]] && \
-   [[ "$(lsb_release -irs)" =~ 
(CentOS|RedHatEnterpriseServer|OracleServer)[[:space:]]+(6|7)\.[[:digit:]]+ ]]; 
then
-  # 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:]]+1[25]\.[[: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++"
+if [[ "$OSTYPE" =~ ^linux ]]; then
+  if ! lsb_release -irs > /dev/null 2>&1; then
+    echo "ERROR: could not retrieve Linux distribution info; "
+    echo "       make sure the 'lsb_release' utility is present in PATH"
+    exit 1
   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"
+  LSB_INFO="$(lsb_release -irs)"
+  if [[ "$LSB_INFO" =~ 
(CentOS|RedHatEnterpriseServer|OracleServer)[[:space:]]+(6|7)\.[[:digit:]]+ ]]; 
then
+    # 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 [[ "$LSB_INFO" =~ (SUSE)[[:space:]]+1[25]\.[[:digit:]]+ ]]; then
+    # On SLES12 and SLES15, Kudu can be built both by gcc-8 and gcc-7 since
+    # either one supports the C++17 standard. Prefer gcc-8 over gcc-7 if both
+    # compilers are present.
+    GCC_MAJOR_VERSION=
+    if /usr/bin/gcc-8 -v > /dev/null 2>&1 && /usr/bin/g++-8 -v > /dev/null 
2>&1; then
+      GCC_MAJOR_VERSION=8
+    elif /usr/bin/gcc-7 -v > /dev/null 2>&1 && /usr/bin/g++-7 -v > /dev/null 
2>&1; then
+      GCC_MAJOR_VERSION=7
+    fi
+
+    if [ -z "$GCC_MAJOR_VERSION" ]; then
+      echo "ERROR: found neither gcc/g++-8 nor gcc/g++-7 in /usr/bin"
+      exit 2
+    fi
+
+    # If ccache was on the PATH and CC/CXX have not already been set,
+    # set them to gcc-[7,8] specific ccache helper scripts, enabling ccache.
+    if which ccache > /dev/null 2>&1 && [ ! "$CC" -a ! "$CXX" ]; then
+      export CC="$ROOT/ccache-gcc-$GCC_MAJOR_VERSION/cc"
+      export CXX="$ROOT/ccache-gcc-$GCC_MAJOR_VERSION/c++"
+    fi
+
+    # If CC/CXX have not already been set, set them accordingly.
+    if [ ! "$CC" -a ! "$CXX" ]; then
+      export CC="/usr/bin/gcc-$GCC_MAJOR_VERSION"
+      export CXX="/usr/bin/g++-$GCC_MAJOR_VERSION"
+    fi
   fi
 
-  # TODO(aserbin): patch the protobuf in thirdparty to allow building with
-  #                gcc-8/g++-8 and remove these x_FOR_BUILD below
+  # TODO(aserbin): patch the protobuf in thirdparty to accept standard CC
+  #                and CXX environment variables to allow for building with
+  #                versioned gcc/g++ binaries on SLES and remove x_FOR_BUILD
   export CC_FOR_BUILD="$CC"
   export CPP_FOR_BUILD="$CC -E"
   export CXXCPP_FOR_BUILD="$CXX -E"
-
-  # Execute the arguments
-  $@
-else
-  $@
 fi
+
+# Execute the arguments
+$@

Reply via email to