Commit a3dd90c1 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Merge branch 'amiranda/121-build-with-clang' into 'main'

Resolve "Build with Clang"

Closes #121

See merge request !86
parents f49ce869 0d8d5b60
Loading
Loading
Loading
Loading
Loading
+30 −12
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ stages:
  - build
  - test

release_build:
gcc-release:
  stage: build
  script:
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
@@ -26,7 +26,7 @@ release_build:
      ..
    - make -j$(nproc) install

debug_build:
gcc-debug:
  stage: build
  script:
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
@@ -34,7 +34,7 @@ debug_build:
    - mkdir -p build
    - cd build
    - cmake
      -DCMAKE_BUILD_TYPE:STRING=ASan
      -DCMAKE_BUILD_TYPE:STRING=Debug
      -DCMAKE_PREFIX_PATH:STRING=/usr/local
      -DCMAKE_INSTALL_PREFIX:STRING=${CI_PROJECT_DIR}/compiled
      -DSCORD_BUILD_EXAMPLES:BOOL=ON
@@ -46,6 +46,7 @@ debug_build:
      ..
    - make -j$(nproc) install
  artifacts:
    expire_in: 2 days
    paths:
      - compiled/bin/
      - compiled/etc/
@@ -54,18 +55,35 @@ debug_build:
      - build/tests/
      - build/src/scord/scord
      - build/src/scord-ctl/scord-ctl
      # depending on your build setup it's most likely a good idea to cache outputs to reduce the build time
  cache:
    key: $CI_COMMIT_REF_SLUG
    paths:
      - build/
      - compiled/bin
      - compiled/etc

clang:
  stage: build
  parallel:
    matrix:
      - CMAKE_BUILD_TYPE: [ Debug, Release ]
  script:
    - export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
    - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig
    - mkdir -p build
    - cd build
    - cmake
      -DCMAKE_CXX_COMPILER=/usr/bin/clang++
      -DCMAKE_C_COMPILER=/usr/bin/clang
      -DCMAKE_PREFIX_PATH:STRING=/usr/local
      -DCMAKE_INSTALL_PREFIX:STRING=${CI_PROJECT_DIR}/compiled
      -DSCORD_BUILD_EXAMPLES:BOOL=ON
      -DSCORD_BUILD_TESTS:BOOL=ON
      -DSCORD_TRANSPORT_LIBRARY=libfabric
      -DSCORD_TRANSPORT_PROTOCOL=ofi+tcp
      -DSCORD_BIND_ADDRESS=127.0.0.1
      -DSCORD_BIND_PORT=52000
      ..
    - make -j$(nproc) install

# run RPC tests using the binary built before
rpc:
  stage: test
  needs: [debug_build]
  needs: [ gcc-debug ]
  script:
    - export ASAN_OPTIONS=detect_odr_violation=0:detect_leaks=0
    - export LSAN_OPTIONS=verbosity=1:log_threads=1:suppressions=${CI_PROJECT_DIR}/tests/LSanSuppress.supp
@@ -82,7 +100,7 @@ rpc:
# run unit tests
unit:
  stage: test
  needs: [debug_build]
  needs: [ gcc-debug ]
  script:
    - export ASAN_OPTIONS=detect_odr_violation=0
    - export LSAN_OPTIONS=verbosity=1:log_threads=1:suppressions=${CI_PROJECT_DIR}/tests/LSanSuppress.supp
+1 −6
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ set(EXPECTED_BUILD_TESTS OFF)
FetchContent_Declare(
  expected
  GIT_REPOSITORY https://github.com/TartanLlama/expected
  GIT_TAG 9d812f5e3b5bc68023f6e31d29489cdcaacef606 # latest
  GIT_TAG 3e304a4bdd00feef8d41f5b388c37bd9d6108025 # latest
  GIT_SHALLOW ON
  GIT_PROGRESS ON
)
@@ -303,11 +303,6 @@ find_package(RedisPlusPlus 1.3.3 REQUIRED)
add_compile_options("-Wall" "-Wextra" "-Werror" "$<$<CONFIG:RELEASE>:-O3>")
add_compile_definitions("$<$<CONFIG:DEBUG,ASan>:SCORD_DEBUG_BUILD>")
add_compile_definitions("$<$<CONFIG:DEBUG,ASan>:__LOGGER_ENABLE_DEBUG__>")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  add_compile_options("-stdlib=libc++")
else ()
  # nothing special for gcc at the moment
endif ()

add_subdirectory(etc)
add_subdirectory(src)
+2 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ RUN apt-get update && \
        automake \
        gcc \
        g++ \
        clang \
        libc++-dev \
        procps \
        # AGIOS dependencies
        libconfig-dev \
+3 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include <cassert>
#include <abt.h>
#include <fmt/format.h>
#include <bits/functexcept.h>

#ifndef SCORD_ABT_SHARED_MUTEX_HPP
#define SCORD_ABT_SHARED_MUTEX_HPP
@@ -124,7 +123,7 @@ public:
    unique_lock() noexcept : m_device(0), m_owns(false) {}

    explicit unique_lock(mutex_type& m)
        : m_device(std::__addressof(m)), m_owns(false) {
        : m_device(std::addressof(m)), m_owns(false) {
        lock();
        m_owns = true;
    }
@@ -235,7 +234,7 @@ public:
    shared_lock() noexcept : m_device(nullptr), m_owns(false) {}

    explicit shared_lock(mutex_type& m)
        : m_device(std::__addressof(m)), m_owns(true) {
        : m_device(std::addressof(m)), m_owns(true) {
        m.lock_shared();
    }

@@ -288,7 +287,7 @@ public:
    mutex_type*
    release() noexcept {
        m_owns = false;
        return std::__exchange(m_device, nullptr);
        return std::exchange(m_device, nullptr);
    }

    // Getters
+4 −6
Original line number Diff line number Diff line
@@ -133,17 +133,15 @@
#define LOGGER_LOG16                 LOGGER_LOGN
#define LOGGER_LOGN(level, fmt, ...) logger_log(level, fmt, __VA_ARGS__)

#define LOGGER_INFO(fmt, ...) LOGGER_LOG(info, fmt __VA_OPT__(, ) __VA_ARGS__);
#define LOGGER_INFO(fmt, ...) LOGGER_LOG(info, fmt, ##__VA_ARGS__);

#ifdef __LOGGER_ENABLE_DEBUG__
#define LOGGER_DEBUG(fmt, ...)                                                 \
    LOGGER_LOG(debug, fmt __VA_OPT__(, ) __VA_ARGS__);
#define LOGGER_DEBUG(fmt, ...) LOGGER_LOG(debug, fmt, ##__VA_ARGS__);
#endif

#define LOGGER_WARN(fmt, ...) LOGGER_LOG(warn, fmt __VA_OPT__(, ) __VA_ARGS__);
#define LOGGER_WARN(fmt, ...) LOGGER_LOG(warn, fmt, ##__VA_ARGS__);

#define LOGGER_ERROR(fmt, ...)                                                 \
    LOGGER_LOG(error, fmt __VA_OPT__(, ) __VA_ARGS__);
#define LOGGER_ERROR(fmt, ...) LOGGER_LOG(error, fmt, ##__VA_ARGS__);

#endif

Loading