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

scripts: add --compiler option for build; fix clang compile error #103

Merged
merged 2 commits into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion include/dsn/tool-api/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class rpc_request_task : public task

message_ex *get_request() const { return _request; }

DSN_API void enqueue() override;
void enqueue() override;

void exec() override
{
Expand Down Expand Up @@ -587,7 +587,11 @@ class aio_task : public task
aio_task(task_code code, aio_handler &&cb, int hash = 0, service_node *node = nullptr);
~aio_task();

// tell the compiler that we want both the enqueue from base task and ours
// to prevent the compiler complaining -Werror,-Woverloaded-virtual.
using task::enqueue;
void enqueue(error_code err, size_t transferred_size);

size_t get_transferred_size() const { return _transferred_size; }
disk_aio *aio() { return _aio; }

Expand Down
20 changes: 18 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function usage_build()
echo " -t|--type build type: debug|release, default is debug"
echo " -c|--clear clear environment before building, but not clear thirdparty"
echo " --clear_thirdparty clear environment before building, including thirdparty"
echo " --compiler specify c and cxx compiler, sperated by ','"
echo " e.g., \"gcc,g++\" or \"clang-3.9,clang++-3.9\""
echo " default is \"gcc,g++\""
echo " -j|--jobs <num> the number of jobs to run simultaneously, default 8"
echo " -b|--boost_dir <dir> specify customized boost directory, use system boost if not set"
echo " -w|--warning_all open all warnings when build, default no"
Expand All @@ -66,6 +69,8 @@ function usage_build()
}
function run_build()
{
C_COMPILER="gcc"
CXX_COMPILER="g++"
BUILD_TYPE="release"
CLEAR=NO
CLEAR_THIRDPARTY=NO
Expand All @@ -92,6 +97,17 @@ function run_build()
--clear_thirdparty)
CLEAR_THIRDPARTY=YES
;;
--compiler)
C_COMPILER=`echo $2 | awk -F',' '{print $1}'`
CXX_COMPILER=`echo $2 | awk -F',' '{print $2}'`
if [ "x"$C_COMPILER == "x" -o "x"$CXX_COMPILER == "x" ]; then
echo "ERROR: invalid compiler option: $2"
echo
usage_build
exit 1
fi
shift
;;
-j|--jobs)
JOB_NUM="$2"
shift
Expand Down Expand Up @@ -156,8 +172,8 @@ function run_build()
if [ "$ONLY_BUILD" == "NO" ]; then
run_start_zk
fi
BUILD_TYPE="$BUILD_TYPE" ONLY_BUILD="$ONLY_BUILD" \
CLEAR="$CLEAR" JOB_NUM="$JOB_NUM" \
C_COMPILER="$C_COMPILER" CXX_COMPILER="$CXX_COMPILER" BUILD_TYPE="$BUILD_TYPE" \
ONLY_BUILD="$ONLY_BUILD" CLEAR="$CLEAR" JOB_NUM="$JOB_NUM" \
BOOST_DIR="$BOOST_DIR" WARNING_ALL="$WARNING_ALL" ENABLE_GCOV="$ENABLE_GCOV" \
RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" $scripts_dir/build.sh
}
Expand Down
13 changes: 10 additions & 3 deletions scripts/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# CLEAR YES|NO
# JOB_NUM <num>
# BUILD_TYPE debug|release
# C_COMPILER <str>
# CXX_COMPILER <str>
# ONLY_BUILD YES|NO
# RUN_VERBOSE YES|NO
# WARNING_ALL YES|NO
Expand All @@ -13,8 +15,8 @@
# TEST_MODULE "<module1> <module2> ..."
#
# CMake options:
# -DCMAKE_C_COMPILER=gcc
# -DCMAKE_CXX_COMPILER=g++
# -DCMAKE_C_COMPILER=gcc|clang
# -DCMAKE_CXX_COMPILER=g++|clang++
# [-DCMAKE_BUILD_TYPE=Debug]
# [-DDSN_GIT_SOURCE=github|xiaomi]
# [-DWARNING_ALL=TRUE]
Expand All @@ -28,7 +30,12 @@ GCOV_DIR="$ROOT/gcov_report"
GCOV_TMP="$ROOT/.gcov_tmp"
GCOV_PATTERN=`find $ROOT/include $ROOT/src -name '*.h' -o -name '*.cpp'`
TIME=`date --rfc-3339=seconds`
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++"

echo "C_COMPILER=$C_COMPILER"
echo "CXX_COMPILER=$CXX_COMPILER"
CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_C_COMPILER=$C_COMPILER -DCMAKE_CXX_COMPILER=$CXX_COMPILER"

echo "JOB_NUM=$JOB_NUM"
MAKE_OPTIONS="$MAKE_OPTIONS -j$JOB_NUM"

if [ "$CLEAR" == "YES" ]
Expand Down
2 changes: 0 additions & 2 deletions src/core/tests/autoref_ptr_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ TEST(RefCountedUnitTest, TestSelfAssignment)
dsn::ref_ptr<SelfAssign> var(p);
var = var;
EXPECT_EQ(var.get(), p);
var = std::move(var);
EXPECT_EQ(var.get(), p);

// please uncomment these lines when swap are supported in ref_ptr
// var.swap(var);
Expand Down
16 changes: 6 additions & 10 deletions src/dist/block_service/local/local_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ dsn::task_ptr local_service::create_file(const create_file_request &req,
if (req.ignore_metadata) {
create_file_response resp;
resp.err = ERR_OK;
resp.file_handle = new local_file_object(
this, ::dsn::utils::filesystem::path_combine(_root, req.file_name));
resp.file_handle =
new local_file_object(::dsn::utils::filesystem::path_combine(_root, req.file_name));
tsk->enqueue_with(resp);
return tsk;
}
Expand All @@ -124,14 +124,14 @@ dsn::task_ptr local_service::create_file(const create_file_request &req,

if (::dsn::utils::filesystem::file_exists(file_path)) {
ddebug("file: %s already exist", file_path.c_str());
resp.file_handle = new local_file_object(this, file_path);
resp.file_handle = new local_file_object(file_path);
} else {
ddebug("start create file, file = %s", file_path.c_str());
if (!::dsn::utils::filesystem::create_file(file_path)) {
derror("create file: %s fail", file_path.c_str());
resp.err = ERR_FS_INTERNAL;
} else {
resp.file_handle = new local_file_object(this, file_path);
resp.file_handle = new local_file_object(file_path);
ddebug("create file succeed, file = %s", resp.file_handle->file_name().c_str());
}
}
Expand Down Expand Up @@ -238,16 +238,12 @@ dsn::task_ptr local_service::remove_path(const remove_path_request &req,
}

// local_file_object
local_file_object::local_file_object(local_service *local_svc, const std::string &name)
: block_file(name), _local_service(local_svc), _md5_value()
local_file_object::local_file_object(const std::string &name) : block_file(name)
{
_md5_value = compute_md5();
}

local_file_object::~local_file_object()
{
// do nothing
}
local_file_object::~local_file_object() {}

const std::string &local_file_object::get_md5sum() { return _md5_value; }

Expand Down
3 changes: 1 addition & 2 deletions src/dist/block_service/local/local_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class local_service : public block_filesystem
class local_file_object : public block_file
{
public:
local_file_object(local_service *local_svc, const std::string &name);
local_file_object(const std::string &name);

virtual ~local_file_object();

Expand Down Expand Up @@ -79,7 +79,6 @@ class local_file_object : public block_file
std::string compute_md5();

private:
local_service *_local_service;
std::string _md5_value;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct meta_storage
void delete_node_impl(std::string &&node, std::function<void()> &&cb, bool is_recursive);

private:
friend class operation;
friend struct operation;

dist::meta_state_service *_remote;
dsn::task_tracker *_tracker;
Expand Down