Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Compile] Support build with clang #7451

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
cmake_minimum_required(VERSION 3.19.2)

# set CMAKE_C_COMPILER, this must set before project command
if (DEFINED ENV{DORIS_GCC_HOME})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be an optional choice?

Copy link
Contributor Author

@yiguolei yiguolei Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, We should remove GCC HOME env.
User should only define CC and CXX env,
for example
export CC= XXXXXXXXXX
export CXX=xxxxxxxxxxxxxx

We define GCC HOME because bitshuffle's build process depend on GCC_HOME/ld. I will rewrite bitshuffle build method use cmake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to build with clang, then we export CC=XXXX/clang and CXX=XXXXXXX/clang++
If we want to build with gcc, then we export CC=xxxx/gcc and CXX=xxxxx/g++

set(CMAKE_C_COMPILER "$ENV{DORIS_GCC_HOME}/bin/gcc")
set(CMAKE_CXX_COMPILER "$ENV{DORIS_GCC_HOME}/bin/g++")
set(GCC_HOME $ENV{DORIS_GCC_HOME})
else()
message(FATAL_ERROR "DORIS_GCC_HOME environment variable is not set")
endif()

project(doris CXX C)

Expand Down Expand Up @@ -89,16 +82,6 @@ endif()
message(STATUS "make test: ${MAKE_TEST}")
option(WITH_MYSQL "Support access MySQL" ON)

# Check gcc
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.3.0")
message(FATAL_ERROR "Need GCC version at least 7.3.0")
endif()
message(STATUS "GCC version is greater than 7.3.0, disable -Werror. Be careful with compile warnings.")
elseif (NOT APPLE)
message(FATAL_ERROR "Compiler should be GNU")
endif()

set(PIC_LIB_PATH "${THIRDPARTY_DIR}")
if(PIC_LIB_PATH)
message(STATUS "defined PIC_LIB_PATH")
Expand Down
2 changes: 2 additions & 0 deletions be/src/exec/olap_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ inline CompareLargeFunc get_compare_func(PrimitiveType type) {

default:
DCHECK(false) << "Unsupported Compare type";
// Clang will report error if not all path have return value
return nullptr;
}
}

Expand Down
34 changes: 0 additions & 34 deletions be/src/olap/column_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ ScalarColumnVectorBatch<ScalarType>::ScalarColumnVectorBatch(const TypeInfo* typ
bool is_nullable)
: ColumnVectorBatch(type_info, is_nullable), _data(0) {}

template <class ScalarType>
ScalarColumnVectorBatch<ScalarType>::~ScalarColumnVectorBatch() = default;

template <class ScalarType>
Status ScalarColumnVectorBatch<ScalarType>::resize(size_t new_cap) {
if (capacity() < new_cap) { // before first init, _capacity is 0.
Expand Down Expand Up @@ -222,35 +219,4 @@ void ArrayColumnVectorBatch::prepare_for_read(size_t start_idx, size_t size, boo
}
}

template <class T>
DataBuffer<T>::DataBuffer(size_t new_size) : buf(nullptr), current_size(0), current_capacity(0) {
resize(new_size);
}

template <class T>
DataBuffer<T>::~DataBuffer() {
for (uint64_t i = current_size; i > 0; --i) {
(buf + i - 1)->~T();
}
if (buf) {
std::free(buf);
}
}

template <class T>
void DataBuffer<T>::resize(size_t new_size) {
if (new_size > current_capacity || !buf) {
if (buf) {
T* buf_old = buf;
buf = reinterpret_cast<T*>(std::malloc(sizeof(T) * new_size));
memcpy(buf, buf_old, sizeof(T) * current_size);
std::free(buf_old);
} else {
buf = reinterpret_cast<T*>(std::malloc(sizeof(T) * new_size));
}
current_capacity = new_size;
}
current_size = new_size;
}

} // namespace doris
34 changes: 34 additions & 0 deletions be/src/olap/column_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,37 @@ class DataBuffer {
void resize(size_t _size);
};

template <class T>
DataBuffer<T>::DataBuffer(size_t new_size) : buf(nullptr), current_size(0), current_capacity(0) {
resize(new_size);
}

template <class T>
DataBuffer<T>::~DataBuffer() {
for (uint64_t i = current_size; i > 0; --i) {
(buf + i - 1)->~T();
}
if (buf) {
std::free(buf);
}
}

template <class T>
void DataBuffer<T>::resize(size_t new_size) {
if (new_size > current_capacity || !buf) {
if (buf) {
T* buf_old = buf;
buf = reinterpret_cast<T*>(std::malloc(sizeof(T) * new_size));
memcpy(buf, buf_old, sizeof(T) * current_size);
std::free(buf_old);
} else {
buf = reinterpret_cast<T*>(std::malloc(sizeof(T) * new_size));
}
current_capacity = new_size;
}
current_size = new_size;
}

template class DataBuffer<bool>;
template class DataBuffer<int8_t>;
template class DataBuffer<int16_t>;
Expand Down Expand Up @@ -161,6 +192,9 @@ class ScalarColumnVectorBatch : public ColumnVectorBatch {
DataBuffer<ScalarCppType> _data;
};

template <class ScalarType>
ScalarColumnVectorBatch<ScalarType>::~ScalarColumnVectorBatch() = default;

// util class for read array's null signs.
class ArrayNullColumnVectorBatch : public ColumnVectorBatch {
public:
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ struct CppTypeTraits<OLAP_FIELD_TYPE_UNSIGNED_BIGINT> {
template <>
struct CppTypeTraits<OLAP_FIELD_TYPE_LARGEINT> {
using CppType = int128_t;
using UnsignedCppType = unsigned int128_t;
using UnsignedCppType = uint128_t;
};
template <>
struct CppTypeTraits<OLAP_FIELD_TYPE_FLOAT> {
Expand Down
9 changes: 5 additions & 4 deletions be/src/runtime/dpp_sink_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ namespace doris {
PartRangeKey PartRangeKey::_s_pos_infinite(1);
PartRangeKey PartRangeKey::_s_neg_infinite(-1);

// Clang will check constructor method not exist
PartRange PartRange::_s_all_range = {
._start_key = PartRangeKey::neg_infinite(),
._end_key = PartRangeKey::pos_infinite(),
._include_start_key = true,
._include_end_key = true,
PartRangeKey::neg_infinite(),
PartRangeKey::pos_infinite(),
true,
true
};

RollupSchema::RollupSchema() {}
Expand Down
1 change: 1 addition & 0 deletions be/src/runtime/raw_value_ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// under the License.

#include "runtime/raw_value.h"
#include "runtime/string_value.hpp"
#include "util/types.h"

namespace doris {
Expand Down
4 changes: 0 additions & 4 deletions be/src/util/bitmap_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -1735,10 +1735,6 @@ class BitmapValue {
// }
class BitmapValueIterator {
public:
BitmapValueIterator()
: _bitmap(BitmapValue()) {
}

BitmapValueIterator(const BitmapValue& bitmap, bool end = false)
: _bitmap(bitmap), _end(end) {

Expand Down
7 changes: 7 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ set -eo pipefail
ROOT=`dirname "$0"`
ROOT=`cd "$ROOT"; pwd`


export DORIS_HOME=${ROOT}

. ${DORIS_HOME}/env.sh
Expand Down Expand Up @@ -201,6 +202,12 @@ make

# Clean and build Backend
if [ ${BUILD_BE} -eq 1 ] ; then
# Has to set CC and CXX here
# --gcc-toolchain=/usr/local/gcc-10.1.0
# Could set use clang here to build BE with clang
#export CC="/data/common/clang-11/bin/clang --gcc-toolchain=${DORIS_GCC_HOME}"
#export CXX="/data/common/clang-11/bin/clang++ --gcc-toolchain=${DORIS_GCC_HOME}"

CMAKE_BUILD_TYPE=${BUILD_TYPE:-Release}
echo "Build Backend: ${CMAKE_BUILD_TYPE}"
CMAKE_BUILD_DIR=${DORIS_HOME}/be/build_${CMAKE_BUILD_TYPE}
Expand Down
7 changes: 0 additions & 7 deletions contrib/udf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@
cmake_minimum_required(VERSION 3.19.2)

# set CMAKE_C_COMPILER, this must set before project command
if (DEFINED ENV{DORIS_GCC_HOME})
set(CMAKE_C_COMPILER "$ENV{DORIS_GCC_HOME}/bin/gcc")
set(CMAKE_CXX_COMPILER "$ENV{DORIS_GCC_HOME}/bin/g++")
set(GCC_HOME $ENV{DORIS_GCC_HOME})
else()
message(FATAL_ERROR "DORIS_GCC_HOME environment variable is not set")
endif()

project(doris_udf)

Expand Down