|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed with |
| 5 | +# this work for additional information regarding copyright ownership. |
| 6 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | +# (the "License"); you may not use this file except in compliance with |
| 8 | +# the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | + |
| 18 | +while read -r line; do |
| 19 | + val=$(echo "$line" | awk '{print $3}') |
| 20 | + if [[ $line =~ __clang__ ]]; then |
| 21 | + CLANG=${val} |
| 22 | + elif [[ $line =~ __GNUC__ ]]; then |
| 23 | + GNUC=${val} |
| 24 | + elif [[ $line =~ __GNUC_MINOR__ ]]; then |
| 25 | + GNUC_MINOR=${val} |
| 26 | + elif [[ $line =~ __GNUC_PATCHLEVEL__ ]]; then |
| 27 | + GNUC_PATCHLEVEL=${val} |
| 28 | + fi |
| 29 | +done < <("${CXX:-c++}" -dM -E - < /dev/null | grep "__clang__\|__GNUC__\|__GNUC_MINOR__\|__GNUC_PATCHLEVEL__") |
| 30 | + |
| 31 | +if [ -n "$GNUC" ] && [ -n "$GNUC_MINOR" ] && [ -n "$GNUC_PATCHLEVEL" ]; then |
| 32 | + # Calculate GCC/Clang version |
| 33 | + GCC_VERSION=$((GNUC * 10000 + GNUC_MINOR * 100 + GNUC_PATCHLEVEL)) |
| 34 | + if [ -n "$CLANG" ] && [ "40000" -lt $GCC_VERSION ] && [ $GCC_VERSION -lt "40800" ]; then |
| 35 | + # Make version of clang >= 4.8 so that it's not rejected by config_brpc.sh |
| 36 | + GCC_VERSION=40800 |
| 37 | + fi |
| 38 | + echo $GCC_VERSION |
| 39 | +else |
| 40 | + echo 0 |
| 41 | +fi |
0 commit comments