Skip to content

Commit

Permalink
replace hiredis for compile error in macos (OpenAtomFoundation#2011)
Browse files Browse the repository at this point in the history
* replace hiredis for compile error in macos

* fix header file path

* update hiredis library name

* remove librt dependency

* disable O_DIRECT in macos

---------

Co-authored-by: J1senn <[email protected]>
  • Loading branch information
A2ureStone and J1senn authored Sep 25, 2023
1 parent 06102c7 commit 6c22723
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pika.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ jobs:
- name: Configure CMake
run: |
export CC=/usr/local/opt/gcc@10/bin/gcc-10
cmake -B build -DCMAKE_C_COMPILER=/usr/local/opt/gcc@10/bin/gcc-10 -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address
cmake -B build -DCMAKE_C_COMPILER=/usr/local/opt/gcc@10/bin/gcc-10 -DUSE_PIKA_TOOLS=ON -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_CXX_FLAGS_DEBUG=-fsanitize=address
- name: Build
run: |
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ option(USE_PIKA_TOOLS "compile pika-tools" OFF)
if (USE_PIKA_TOOLS)
ExternalProject_Add(hiredis
URL
https://github.com/vipshop/hiredis-vip/archive/refs/tags/0.3.0.tar.gz
https://github.com/redis/hiredis/archive/refs/tags/v1.2.0.tar.gz
URL_HASH
MD5=e4d4a2928188b11f696d35ca1c52e9a4
MD5=119767d178cfa79718a80c83e0d0e849
DOWNLOAD_NO_PROGRESS
1
UPDATE_COMMAND
Expand All @@ -654,7 +654,7 @@ if (USE_PIKA_TOOLS)
INSTALL_COMMAND
make PREFIX=${STAGED_INSTALL_PREFIX} -j${CPU_CORE} install
)
set(HIREDIS_LIBRARY ${INSTALL_LIBDIR}/libhiredis_vip.a)
set(HIREDIS_LIBRARY ${INSTALL_LIBDIR}/libhiredis.a)

ExternalProject_Add(bz2
URL
Expand Down
3 changes: 2 additions & 1 deletion tools/benchmark_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ target_link_libraries(benchmark_client ${HIREDIS_LIBRARY})
set_target_properties(benchmark_client PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
CMAKE_COMPILER_IS_GNUCXX TRUE
COMPILE_FLAGS ${CXXFLAGS})
COMPILE_FLAGS ${CXXFLAGS})
add_dependencies(benchmark_client snappy hiredis)
2 changes: 1 addition & 1 deletion tools/benchmark_client/benchmark_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <random>
#include <vector>

#include "hiredis-vip/hiredis.h"
#include "hiredis/hiredis.h"
#include "pstd/include/pstd_status.h"
#include "pstd/include/pstd_string.h"

Expand Down
5 changes: 3 additions & 2 deletions tools/pika-port/pika_port_3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ add_executable(pika_port ${BASE_OBJS})
target_include_directories(pika_port PRIVATE ${INSTALL_INCLUDEDIR}
PRIVATE ${PROJECT_SOURCE_DIR})

target_link_libraries(pika_port ${ROCKSDB_LIBRARY} pthread rt net pstd storage ${GLOG_LIBRARY}
target_link_libraries(pika_port ${ROCKSDB_LIBRARY} pthread net pstd storage ${GLOG_LIBRARY}
${GFLAGS_LIBRARY} ${SNAPPY_LIBRARY} ${ZLIB_LIBRARY} ${BZ2_LIBRARY}
${LZ4_LIBRARY} ${ZSTD_LIBRARY})
set_target_properties(pika_port PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
CMAKE_COMPILER_IS_GNUCXX TRUE
COMPILE_FLAGS ${CXXFLAGS})
COMPILE_FLAGS ${CXXFLAGS})
add_dependencies(pika_port rocksdb glog gflags snappy zlib bz2 lz4 zstd)
6 changes: 5 additions & 1 deletion tools/pika-port/pika_port_3/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ static int lockFile(int fd) {
}

static void createPidFile(const char* file) {
int fd = open(file, O_RDWR | O_CREAT | O_DIRECT, S_IRUSR | S_IWUSR);
int flags = O_RDWR | O_CREAT;
#if !defined(OS_MACOSX) && !defined(OS_OPENBSD) && !defined(OS_SOLARIS)
flags |= O_DIRECT;
#endif
int fd = open(file, flags, S_IRUSR | S_IWUSR);
if (-1 == fd) {
LOG(FATAL) << "open(" << file << ") = " << fd;
}
Expand Down
5 changes: 3 additions & 2 deletions tools/pika_to_txt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ target_include_directories(pika_to_txt PRIVATE ${INSTALL_INCLUDEDIR}
PRIVATE ${PROJECT_SOURCE_DIR})

target_link_libraries(pika_to_txt storage net pstd ${ROCKSDB_LIBRARY} pthread ${SNAPPY_LIBRARY}
${ZLIB_LIBRARY} ${BZ2_LIBRARY} ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} rt)
${ZLIB_LIBRARY} ${BZ2_LIBRARY} ${GLOG_LIBRARY} ${GFLAGS_LIBRARY})
set_target_properties(pika_to_txt PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
CMAKE_COMPILER_IS_GNUCXX TRUE
COMPILE_FLAGS ${CXXFLAGS})
COMPILE_FLAGS ${CXXFLAGS})
add_dependencies(pika_to_txt rocksdb snappy zlib bz2 glog gflags)
3 changes: 2 additions & 1 deletion tools/rdb_to_pika/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ target_link_libraries(redisConn ${HIREDIS_LIBRARY})
set_target_properties(redisConn PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
CMAKE_COMPILER_IS_GNUCXX TRUE
COMPILE_FLAGS ${CXXFLAGS})
COMPILE_FLAGS ${CXXFLAGS})
add_dependencies(redisConn hiredis)
2 changes: 1 addition & 1 deletion tools/rdb_to_pika/protocoltopika.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <sstream>
#include <string>
#include "hiredis-vip/hiredis.h"
#include "hiredis/hiredis.h"

void Usage() {
std::cout << "Usage:" << std::endl;
Expand Down
5 changes: 3 additions & 2 deletions tools/txt_to_pika/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ target_include_directories(txt_to_pika PRIVATE ${INSTALL_INCLUDEDIR}
${CMAKE_CURRENT_SOURCE_DIR})

target_link_libraries(txt_to_pika storage net pstd ${ROCKSDB_LIBRARY} pthread ${SNAPPY_LIBRARY}
${ZLIB_LIBRARY} ${BZ2_LIBRARY} ${GLOG_LIBRARY} ${GFLAGS_LIBRARY} rt)
${ZLIB_LIBRARY} ${BZ2_LIBRARY} ${GLOG_LIBRARY} ${GFLAGS_LIBRARY})
set_target_properties(txt_to_pika PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
CMAKE_COMPILER_IS_GNUCXX TRUE
COMPILE_FLAGS ${CXXFLAGS})
COMPILE_FLAGS ${CXXFLAGS})
add_dependencies(txt_to_pika rocksdb snappy zlib bz2 glog gflags)

0 comments on commit 6c22723

Please sign in to comment.