Skip to content

Commit

Permalink
feat(build): support to build on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
acelyc111 committed Jan 23, 2022
1 parent db6adf6 commit c9dc69e
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 41 deletions.
2 changes: 1 addition & 1 deletion rdsn
Submodule rdsn updated 50 files
+16 −6 bin/dsn.cmake
+1 −1 include/dsn/dist/replication/mutation_duplicator.h
+1 −0 include/dsn/perf_counter/perf_counters.h
+2 −0 include/dsn/tool-api/file_io.h
+20 −3 include/dsn/utility/endians.h
+10 −82 include/dsn/utility/ports.h
+2 −0 include/dsn/utility/process_utils.h
+2 −0 include/dsn/utils/token_buckets.h
+13 −3 run.sh
+2 −2 scripts/linux/build.sh
+3 −0 src/aio/native_linux_aio_provider.cpp
+1 −1 src/aio/test/CMakeLists.txt
+9 −12 src/block_service/fds/fds_service.cpp
+1 −1 src/block_service/hdfs/CMakeLists.txt
+3 −0 src/block_service/test/CMakeLists.txt
+7 −4 src/block_service/test/fds_service_test.cpp
+1 −1 src/common/test/CMakeLists.txt
+3 −1 src/failure_detector/CMakeLists.txt
+2 −0 src/http/pprof_http_service.cpp
+1 −1 src/http/test/CMakeLists.txt
+3 −0 src/meta/CMakeLists.txt
+2 −1 src/meta/app_env_validator.cpp
+4 −1 src/meta/app_env_validator.h
+2 −15 src/meta/dump_file.h
+6 −13 src/meta/meta_state_service_simple.cpp
+1 −1 src/meta/test/CMakeLists.txt
+6 −10 src/nfs/nfs_client_impl.cpp
+6 −11 src/nfs/nfs_server_impl.cpp
+1 −1 src/nfs/test/CMakeLists.txt
+1 −1 src/perf_counter/test/CMakeLists.txt
+9 −1 src/replica/CMakeLists.txt
+2 −1 src/replica/duplication/duplication_pipeline.cpp
+1 −0 src/replica/duplication/mutation_batch.h
+4 −1 src/replica/log_file.cpp
+0 −8 src/replica/mutation.h
+2 −2 src/replica/storage/simple_kv/simple_kv.server.h
+3 −3 src/replica/storage/simple_kv/test/case.cpp
+4 −0 src/replica/test/CMakeLists.txt
+1 −1 src/runtime/rpc/thrift_message_parser.cpp
+1 −0 src/runtime/security/access_controller.h
+2 −0 src/runtime/task/task_spec.cpp
+18 −5 src/runtime/task/task_worker.cpp
+1 −1 src/utils/CMakeLists.txt
+0 −13 src/utils/coredump.posix.cpp
+6 −0 src/utils/filesystem.cpp
+1 −1 src/utils/latency_tracer.cpp
+1 −0 src/utils/process_utils.cpp
+26 −14 thirdparty/CMakeLists.txt
+14 −0 thirdparty/fix_fds_for_macos.patch
+0 −61 thirdparty/fix_s2_for_pegasus.patch
13 changes: 7 additions & 6 deletions src/base/pegasus_key_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
#pragma once

#include <stdint.h>
#include <string.h>
#include <string>
#include <dsn/utility/ports.h>
#include <dsn/utility/utils.h>
#include <dsn/utility/blob.h>
#include <dsn/utility/endians.h>
#include <dsn/utility/utils.h>
#include <dsn/utility/crc.h>
#include <dsn/c/api_utilities.h>
Expand All @@ -46,7 +47,7 @@ void pegasus_generate_key(::dsn::blob &key, const T &hash_key, const T &sort_key

// hash_key_len is in big endian
uint16_t hash_key_len = hash_key.length();
*((int16_t *)buf.get()) = htobe16((int16_t)hash_key_len);
*((int16_t *)buf.get()) = ::dsn::endian::hton((uint16_t)hash_key_len);

::memcpy(buf.get() + 2, hash_key.data(), hash_key_len);

Expand All @@ -68,7 +69,7 @@ void pegasus_generate_next_blob(::dsn::blob &next, const T &hash_key)
int hash_key_len = hash_key.length();
std::shared_ptr<char> buf(::dsn::utils::make_shared_array<char>(hash_key_len + 2));

*((int16_t *)buf.get()) = htobe16((int16_t)hash_key_len);
*((int16_t *)buf.get()) = ::dsn::endian::hton((uint16_t)hash_key_len);
::memcpy(buf.get() + 2, hash_key.data(), hash_key_len);

unsigned char *p = (unsigned char *)(buf.get() + hash_key_len + 1);
Expand Down Expand Up @@ -104,7 +105,7 @@ pegasus_restore_key(const ::dsn::blob &key, ::dsn::blob &hash_key, ::dsn::blob &
dassert(key.length() >= 2, "key length must be no less than 2");

// hash_key_len is in big endian
uint16_t hash_key_len = be16toh(*(int16_t *)(key.data()));
uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data()));

if (hash_key_len > 0) {
dassert(key.length() >= 2 + hash_key_len,
Expand All @@ -129,7 +130,7 @@ pegasus_restore_key(const ::dsn::blob &key, std::string &hash_key, std::string &
dassert(key.length() >= 2, "key length must be no less than 2");

// hash_key_len is in big endian
uint16_t hash_key_len = be16toh(*(int16_t *)(key.data()));
uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data()));

if (hash_key_len > 0) {
dassert(key.length() >= 2 + hash_key_len,
Expand All @@ -153,7 +154,7 @@ inline uint64_t pegasus_key_hash(const T &key)
dassert(key.size() >= 2, "key length must be no less than 2");

// hash_key_len is in big endian
uint16_t hash_key_len = be16toh(*(int16_t *)(key.data()));
uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(key.data()));

if (hash_key_len > 0) {
// hash_key_len > 0, compute hash from hash_key
Expand Down
2 changes: 1 addition & 1 deletion src/base/pegasus_value_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#pragma once

#include <stdint.h>
#include <string.h>
#include <array>
#include <string>
#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion src/base/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ set(MY_PROJ_LIBS
pegasus_base
gtest)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

set(MY_BINPLACES config.ini run.sh)

Expand Down
21 changes: 11 additions & 10 deletions src/client_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_include_directories(pegasus_client_impl_objects PUBLIC $<TARGET_PROPERTY:
# link the static lib of pegasus_client: combine pegasus_client_impl, pegasus_base, etc into a single static lib
set(pegasus_client_static_lib ${CMAKE_CURRENT_BINARY_DIR}/libpegasus_client_static.a)
add_custom_target(combine_lib
COMMAND ar -x ${DSN_ROOT}/lib/libdsn_utils.a
COMMAND ar -x ${DSN_ROOT}/lib/libdsn_runtime.a
COMMAND ar -x ${DSN_ROOT}/lib/libdsn_client.a
COMMAND ar -x ${DSN_ROOT}/lib/libdsn_replication_common.a
Expand All @@ -48,13 +49,13 @@ set_target_properties(pegasus_client_static
IMPORTED_LOCATION ${pegasus_client_static_lib})
install(FILES ${pegasus_client_static_lib} DESTINATION "lib")

# link the shared lib of pegasus client
add_library(pegasus_client_shared SHARED $<TARGET_OBJECTS:pegasus_client_impl_objects>)
target_link_libraries(pegasus_client_shared PRIVATE
pegasus_base
dsn_runtime
dsn_utils
dsn_client
dsn_replication_common
thrift)
install(TARGETS pegasus_client_shared DESTINATION "lib")
## link the shared lib of pegasus client
#add_library(pegasus_client_shared SHARED $<TARGET_OBJECTS:pegasus_client_impl_objects>)
#target_link_libraries(pegasus_client_shared PRIVATE
# pegasus_base
# dsn_runtime
# dsn_utils
# dsn_client
# dsn_replication_common
# thrift)
#install(TARGETS pegasus_client_shared DESTINATION "lib")
2 changes: 1 addition & 1 deletion src/geo/bench/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set(MY_PROJ_LIBS
dsn_utils
)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

set(MY_BINPLACES "config.ini")

Expand Down
2 changes: 1 addition & 1 deletion src/geo/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ set(MY_PROJ_LIBS
dsn_utils
gtest)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

add_definitions(-Wno-attributes)

Expand Down
2 changes: 1 addition & 1 deletion src/redis_protocol/proxy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set(MY_PROJ_LIBS pegasus.rproxylib

set(MY_BINPLACES "config.ini")

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

# Avoid megabytes of warnings like:
# rdsn/thirdparty/output/include/s2/s1angle.h:288:28: error:
Expand Down
2 changes: 1 addition & 1 deletion src/redis_protocol/proxy_ut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set(MY_PROJ_SRC "")
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

set(MY_PROJ_LIBS pegasus.rproxylib
pegasus_base
Expand Down
6 changes: 3 additions & 3 deletions src/server/available_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ void available_detector::on_day_report()
ddebug("start to report on new day, last_day = %s", _old_day.c_str());
int64_t detect_times = _recent_day_detect_times.fetch_and(0);
int64_t fail_times = _recent_day_fail_times.fetch_and(0);
int64_t succ_times = std::max(0L, detect_times - fail_times);
int64_t succ_times = std::max<int64_t>(0L, detect_times - fail_times);
int64_t available = 0;
std::string hash_key("detect_available_day");
std::string sort_key(_old_day);
Expand Down Expand Up @@ -437,7 +437,7 @@ void available_detector::on_hour_report()
ddebug("start to report on new hour, last_hour = %s", _old_hour.c_str());
int64_t detect_times = _recent_hour_detect_times.fetch_and(0);
int64_t fail_times = _recent_hour_fail_times.fetch_and(0);
int64_t succ_times = std::max(0L, detect_times - fail_times);
int64_t succ_times = std::max<int64_t>(0L, detect_times - fail_times);
int64_t available = 0;
std::string hash_key("detect_available_hour");
std::string sort_key(_old_hour);
Expand All @@ -461,7 +461,7 @@ void available_detector::on_minute_report()
ddebug("start to report on new minute, last_minute = %s", _old_minute.c_str());
int64_t detect_times = _recent_minute_detect_times.fetch_and(0);
int64_t fail_times = _recent_minute_fail_times.fetch_and(0);
int64_t succ_times = std::max(0L, detect_times - fail_times);
int64_t succ_times = std::max<int64_t>(0L, detect_times - fail_times);
int64_t available = 0;
std::string hash_key("detect_available_minute");
std::string sort_key(_old_minute);
Expand Down
3 changes: 2 additions & 1 deletion src/server/hashkey_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <dsn/c/api_utilities.h>
#include <dsn/utility/blob.h>
#include <dsn/utility/endians.h>

namespace pegasus {
namespace server {
Expand All @@ -46,7 +47,7 @@ class HashkeyTransform : public rocksdb::SliceTransform
}

// hash_key_len is in big endian
uint16_t hash_key_len = be16toh(*(int16_t *)(src.data()));
uint16_t hash_key_len = ::dsn::endian::ntoh(*(uint16_t *)(src.data()));
dassert(src.size() >= 2 + hash_key_len,
"key length must be no less than (2 + hash_key_len)");
return rocksdb::Slice(src.data(), 2 + hash_key_len);
Expand Down
2 changes: 1 addition & 1 deletion src/server/pegasus_server_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2830,7 +2830,7 @@ bool pegasus_server_impl::set_usage_scenario(const std::string &usage_scenario)
new_options["write_buffer_size"] = std::to_string(buffer_size);
uint64_t max_size = get_random_nearby(_data_cf_opts.max_bytes_for_level_base);
new_options["level0_file_num_compaction_trigger"] =
std::to_string(std::max(4UL, max_size / buffer_size));
std::to_string(std::max<uint64_t>(4UL, max_size / buffer_size));
}
} else if (usage_scenario == ROCKSDB_ENV_USAGE_SCENARIO_BULK_LOAD) {
// refer to Options::PrepareForBulkLoad()
Expand Down
15 changes: 8 additions & 7 deletions src/shell/commands/data_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include "shell/commands.h"
#include <fmt/printf.h>
#include "idl_utils.h"

static void
Expand Down Expand Up @@ -115,7 +116,7 @@ bool set_value(command_executor *e, shell_context *sc, arguments args)
fprintf(stderr, "\n");
fprintf(stderr, "app_id : %d\n", info.app_id);
fprintf(stderr, "partition_index : %d\n", info.partition_index);
fprintf(stderr, "decree : %ld\n", info.decree);
fmt::fprintf(stderr, "decree : %lld\n", info.decree);
fprintf(stderr, "server : %s\n", info.server.c_str());
return true;
}
Expand Down Expand Up @@ -149,7 +150,7 @@ bool multi_set_value(command_executor *e, shell_context *sc, arguments args)
fprintf(stderr, "\n");
fprintf(stderr, "app_id : %d\n", info.app_id);
fprintf(stderr, "partition_index : %d\n", info.partition_index);
fprintf(stderr, "decree : %ld\n", info.decree);
fmt::fprintf(stderr, "decree : %lld\n", info.decree);
fprintf(stderr, "server : %s\n", info.server.c_str());
return true;
}
Expand Down Expand Up @@ -403,7 +404,7 @@ bool delete_value(command_executor *e, shell_context *sc, arguments args)
fprintf(stderr, "\n");
fprintf(stderr, "app_id : %d\n", info.app_id);
fprintf(stderr, "partition_index : %d\n", info.partition_index);
fprintf(stderr, "decree : %ld\n", info.decree);
fmt::fprintf(stderr, "decree : %lld\n", info.decree);
fprintf(stderr, "server : %s\n", info.server.c_str());
return true;
}
Expand Down Expand Up @@ -433,7 +434,7 @@ bool multi_del_value(command_executor *e, shell_context *sc, arguments args)
fprintf(stderr, "\n");
fprintf(stderr, "app_id : %d\n", info.app_id);
fprintf(stderr, "partition_index : %d\n", info.partition_index);
fprintf(stderr, "decree : %ld\n", info.decree);
fmt::fprintf(stderr, "decree : %lld\n", info.decree);
fprintf(stderr, "server : %s\n", info.server.c_str());
return true;
}
Expand Down Expand Up @@ -664,7 +665,7 @@ bool incr(command_executor *e, shell_context *sc, arguments args)
fprintf(stderr, "\n");
fprintf(stderr, "app_id : %d\n", info.app_id);
fprintf(stderr, "partition_index : %d\n", info.partition_index);
fprintf(stderr, "decree : %ld\n", info.decree);
fmt::fprintf(stderr, "decree : %lld\n", info.decree);
fprintf(stderr, "server : %s\n", info.server.c_str());
return true;
}
Expand Down Expand Up @@ -819,7 +820,7 @@ bool check_and_set(command_executor *e, shell_context *sc, arguments args)
fprintf(stderr, "\n");
fprintf(stderr, "app_id : %d\n", info.app_id);
fprintf(stderr, "partition_index : %d\n", info.partition_index);
fprintf(stderr, "decree : %ld\n", info.decree);
fmt::fprintf(stderr, "decree : %lld\n", info.decree);
fprintf(stderr, "server : %s\n", info.server.c_str());
return true;
}
Expand Down Expand Up @@ -983,7 +984,7 @@ bool check_and_mutate(command_executor *e, shell_context *sc, arguments args)
fprintf(stderr, "\n");
fprintf(stderr, "app_id : %d\n", info.app_id);
fprintf(stderr, "partition_index : %d\n", info.partition_index);
fprintf(stderr, "decree : %ld\n", info.decree);
fmt::fprintf(stderr, "decree : %lld\n", info.decree);
fprintf(stderr, "server : %s\n", info.server.c_str());

return true;
Expand Down
3 changes: 2 additions & 1 deletion src/shell/commands/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ bool rdb_value_hex2str(command_executor *e, shell_context *sc, arguments args)
std::string pegasus_value = rocksdb::LDBCommand::HexToString(hex_rdb_value);
auto expire_ts = static_cast<int64_t>(pegasus::pegasus_extract_expire_ts(0, pegasus_value)) +
pegasus::utils::epoch_begin; // TODO(wutao): pass user specified version
fmt::print(stderr, "\nWhen to expire:\n {:%Y-%m-%d %H:%M:%S}\n", *std::localtime(&expire_ts));
std::time_t tm(expire_ts);
fmt::print(stderr, "\nWhen to expire:\n {:%Y-%m-%d %H:%M:%S}\n", *std::localtime(&tm));

dsn::blob user_data;
pegasus::pegasus_extract_user_data(0, std::move(pegasus_value), user_data);
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ set(MY_PROJ_LIBS
krb5
)

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

set(MY_BINPLACES "config.ini")

Expand Down
3 changes: 2 additions & 1 deletion src/test/bench_test/rand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

#include <algorithm>
#include <random>

namespace pegasus {
Expand All @@ -37,7 +38,7 @@ std::string generate_string(uint64_t len)

// fill with random int
uint64_t random_int = next_u64();
key.append(reinterpret_cast<char *>(&random_int), std::min(len, 8UL));
key.append(reinterpret_cast<char *>(&random_int), std::min<uint64_t>(len, 8UL));

// append with '0'
key.resize(len, '0');
Expand Down
2 changes: 1 addition & 1 deletion src/test/kill_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ set(MY_PROJ_LIBS
)
set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

if (UNIX)
SET(CMAKE_INSTALL_RPATH ".")
Expand Down
2 changes: 1 addition & 1 deletion src/test/pressure_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ set(MY_PROJ_LIBS

set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config-pressure.ini")

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

if (UNIX)
SET(CMAKE_INSTALL_RPATH ".")
Expand Down
2 changes: 1 addition & 1 deletion src/test/upgrade_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ set(MY_PROJ_LIBS
)
set(MY_BINPLACES "${CMAKE_CURRENT_SOURCE_DIR}/config.ini")

set(MY_BOOST_LIBS Boost::system Boost::filesystem)
set(MY_BOOST_LIBS Boost::system Boost::filesystem Boost::regex)

if (UNIX)
SET(CMAKE_INSTALL_RPATH ".")
Expand Down

0 comments on commit c9dc69e

Please sign in to comment.