diff --git a/.github/workflows/ci.macos.arm.yml b/.github/workflows/ci.macos.arm.yml index c8e17718..77ad0230 100644 --- a/.github/workflows/ci.macos.arm.yml +++ b/.github/workflows/ci.macos.arm.yml @@ -7,7 +7,7 @@ on: branches: [ "main", "release/*" ] jobs: - macOS-clang-debug: + macOS-clang-release: runs-on: [self-hosted, macOS, ARM64] steps: @@ -26,9 +26,9 @@ jobs: - name: Build run: | - cmake -B ${{github.workspace}}/build -D PHOTON_BUILD_TESTING=ON -D CMAKE_BUILD_TYPE=Debug \ + cmake -B ${{github.workspace}}/build -D PHOTON_BUILD_TESTING=ON -D CMAKE_BUILD_TYPE=Release \ -D PHOTON_ENABLE_SASL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 - cmake --build ${{github.workspace}}/build -j -- VERBOSE=1 + cmake --build ${{github.workspace}}/build -j - name: Test working-directory: ${{github.workspace}}/build diff --git a/.github/workflows/ci.macos.yml b/.github/workflows/ci.macos.yml index 5e75d552..2ecfae9e 100644 --- a/.github/workflows/ci.macos.yml +++ b/.github/workflows/ci.macos.yml @@ -7,7 +7,7 @@ on: branches: [ "main", "release/*" ] jobs: - macOS-12-Monterey-debug: + macOS-12-Monterey-release: runs-on: macos-12 steps: @@ -26,9 +26,9 @@ jobs: - name: Build run: | - cmake -B ${{github.workspace}}/build -D PHOTON_BUILD_TESTING=ON -D CMAKE_BUILD_TYPE=Debug \ + cmake -B ${{github.workspace}}/build -D PHOTON_BUILD_TESTING=ON -D CMAKE_BUILD_TYPE=Release \ -D PHOTON_ENABLE_SASL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@3 - cmake --build ${{github.workspace}}/build -j -- VERBOSE=1 + cmake --build ${{github.workspace}}/build -j - name: Test working-directory: ${{github.workspace}}/build diff --git a/CMakeLists.txt b/CMakeLists.txt index b92e2c5d..f71d6c2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,8 +45,8 @@ if (NOT (${ARCH} STREQUAL x86_64) AND NOT (${ARCH} STREQUAL aarch64) AND NOT (${ endif () ProcessorCount(NumCPU) -# Compiler options -add_compile_options(-Wall) # -Werror is not enable yet +# Global compiler options, only effective within this project +add_compile_options(-Wall -Werror -Wno-error=pragmas) set(CMAKE_CXX_STANDARD ${PHOTON_CXX_STANDARD}) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5c8b91e4..b0cc4a1e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,5 @@ +add_definitions(-w) + add_executable(simple-example simple/simple.cpp) target_link_libraries(simple-example PRIVATE photon_static) diff --git a/fs/subfs.cpp b/fs/subfs.cpp index 102037f0..ab30c89b 100644 --- a/fs/subfs.cpp +++ b/fs/subfs.cpp @@ -231,56 +231,56 @@ namespace fs return underlayfs->mknod(path, mode, dev); } - virtual ssize_t getxattr(const char *path, const char *name, void *value, size_t size) + virtual ssize_t getxattr(const char *path, const char *name, void *value, size_t size) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); PathCat __(this, path); return underlay_xattrfs->getxattr(path, name, value, size); } - virtual ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) + virtual ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); PathCat __(this, path); return underlay_xattrfs->lgetxattr(path, name, value, size); } - virtual ssize_t listxattr(const char *path, char *list, size_t size) + virtual ssize_t listxattr(const char *path, char *list, size_t size) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); PathCat __(this, path); return underlay_xattrfs->listxattr(path, list, size); } - virtual ssize_t llistxattr(const char *path, char *list, size_t size) + virtual ssize_t llistxattr(const char *path, char *list, size_t size) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); PathCat __(this, path); return underlay_xattrfs->llistxattr(path, list, size); } - virtual int setxattr(const char *path, const char *name, const void *value, size_t size, int flags) + virtual int setxattr(const char *path, const char *name, const void *value, size_t size, int flags) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); PathCat __(this, path); return underlay_xattrfs->setxattr(path, name, value, size, flags); } - virtual int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags) + virtual int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); PathCat __(this, path); return underlay_xattrfs->lsetxattr(path, name, value, size, flags); } - virtual int removexattr(const char *path, const char *name) + virtual int removexattr(const char *path, const char *name) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); PathCat __(this, path); return underlay_xattrfs->removexattr(path, name); } - virtual int lremovexattr(const char *path, const char *name) + virtual int lremovexattr(const char *path, const char *name) override { if (!underlay_xattrfs) LOG_ERROR_RETURN(ENOTSUP, -1, "xattr is not supported by underlay fs"); diff --git a/net/basic_socket.cpp b/net/basic_socket.cpp index 8446b8dd..5b5e8ac3 100644 --- a/net/basic_socket.cpp +++ b/net/basic_socket.cpp @@ -284,7 +284,7 @@ ssize_t ISocketStream::recv_at_least_mutable(struct iovec *iov, int iovcnt, if (ret == 0) break; // EOF if ((n += ret) >= least) break; auto r = v.extract_front(ret); - assert(r == ret); (void)r; + assert((ssize_t) r == ret); (void)r; } while (v.iovcnt && v.iov->iov_len); return n; } diff --git a/net/http/headers.cpp b/net/http/headers.cpp index 39f262e4..ef997f5c 100644 --- a/net/http/headers.cpp +++ b/net/http/headers.cpp @@ -146,7 +146,14 @@ HeadersBase::KV* HeadersBase::kv_add_sort(KV kv) { if ((char*)(begin - 1) <= m_buf + m_buf_size) LOG_ERROR_RETURN(ENOBUFS, nullptr, "no buffer"); auto it = std::lower_bound(begin, kv_end(), kv, HA(this)); +#ifndef __clang__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wclass-memaccess" +#endif memmove(begin - 1, begin, sizeof(KV) * (it - begin)); +#ifndef __clang__ +#pragma GCC diagnostic pop +#endif m_kv_size++; *(it - 1) = kv; return it - 1; diff --git a/net/http/url.cpp b/net/http/url.cpp index 0c66f5f6..e5a534a6 100644 --- a/net/http/url.cpp +++ b/net/http/url.cpp @@ -27,7 +27,7 @@ void URL::fix_target() { if (m_target.size() == 0 || t.front() != '/') { m_tmp_target = (char*)malloc(m_target.size() + 1); m_tmp_target[0] = '/'; - strncpy(m_tmp_target+1, t.data(), t.size()); + memcpy(m_tmp_target+1, t.data(), t.size()); m_target = rstring_view16(0, m_target.size()+1); m_path = rstring_view16(0, m_path.size()+1); } diff --git a/net/security-context/tls-stream.cpp b/net/security-context/tls-stream.cpp index dc3ffc59..ad12e61e 100644 --- a/net/security-context/tls-stream.cpp +++ b/net/security-context/tls-stream.cpp @@ -101,6 +101,8 @@ class TLSContextImpl : public TLSContext { case TLSVersion::SSL23: method = SSLv23_method(); break; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" case TLSVersion::TLS11: method = TLSv1_1_method(); break; @@ -109,6 +111,7 @@ class TLSContextImpl : public TLSContext { break; default: method = TLSv1_2_method(); +#pragma GCC diagnostic pop } ctx = SSL_CTX_new(method); if (ctx == nullptr) { diff --git a/thread/thread.cpp b/thread/thread.cpp index f9f1a67e..9ddcd274 100644 --- a/thread/thread.cpp +++ b/thread/thread.cpp @@ -928,15 +928,15 @@ R"( size_t randomizer = (rand() % 32) * (1024 + 8); stack_size = align_up(randomizer + stack_size + sizeof(thread), PAGE_SIZE); char* ptr = (char*)photon_thread_alloc(stack_size); - auto p = ptr + stack_size - sizeof(thread) - randomizer; - (uint64_t&)p &= ~63; - auto th = new (p) thread; + uint64_t p = (uint64_t) ptr + stack_size - sizeof(thread) - randomizer; + p = align_down(p, 64); + auto th = new((char*) p) thread; th->buf = ptr; th->stackful_alloc_top = ptr; th->start = start; th->stack_size = stack_size; th->arg = arg; - auto sp = align_down((uint64_t)p - reserved_space, 64); + auto sp = align_down(p - reserved_space, 64); th->stack.init((void*)sp, &_photon_thread_stub, th); AtomicRunQ arq(rq); th->vcpu = arq.vcpu;