Giter VIP home page Giter VIP logo

Comments (13)

ac000 avatar ac000 commented on August 30, 2024 1

That's their perogative. I don't see a compelling reason why we shouldn't.

from unit.

ac000 avatar ac000 commented on August 30, 2024 1

Lets move this to a separate issue...

from unit.

ac000 avatar ac000 commented on August 30, 2024

A long known issue between musl libc and clang.

One way to workaround this would be to create our own wrapper around CMSG_NXTHDR and do the #pragma thing...

Something like the following perhaps...

diff --git a/src/nxt_socket_msg.h b/src/nxt_socket_msg.h
index 04de1761..fca82f05 100644
--- a/src/nxt_socket_msg.h
+++ b/src/nxt_socket_msg.h
@@ -69,6 +69,19 @@ NXT_EXPORT ssize_t nxt_recvmsg(nxt_socket_t s,
     nxt_iobuf_t *iob, nxt_uint_t niob, nxt_recv_oob_t *oob);
 
 
+static inline struct cmsghdr *
+NXT_CMSG_NXTHDR(struct msghdr *msg, struct cmsghdr *cmsg)
+{
+#ifndef __GLIBC__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wsign-compare"
+#endif
+    return CMSG_NXTHDR(msg, cmsg);
+#ifndef __GLIBC__
+#pragma clang diagnostic pop
+#endif
+}
+
 nxt_inline void
 nxt_socket_msg_oob_init(nxt_send_oob_t *oob, int *fds)
 {
@@ -135,7 +148,7 @@ nxt_socket_msg_oob_get_fds(nxt_recv_oob_t *oob, nxt_fd_t *fd
)
 
     for (cmsg = CMSG_FIRSTHDR(&msg);
          cmsg != NULL;
-         cmsg = CMSG_NXTHDR(&msg, cmsg))
+         cmsg = NXT_CMSG_NXTHDR(&msg, cmsg))
     {
         size = cmsg->cmsg_len - CMSG_LEN(0);
 
@@ -174,7 +187,7 @@ nxt_socket_msg_oob_get(nxt_recv_oob_t *oob, nxt_fd_t *fd, nx
t_pid_t *pid)
 
     for (cmsg = CMSG_FIRSTHDR(&msg);
          cmsg != NULL;
-         cmsg = CMSG_NXTHDR(&msg, cmsg))
+         cmsg = NXT_CMSG_NXTHDR(&msg, cmsg))
     {
         size = cmsg->cmsg_len - CMSG_LEN(0);
 

from unit.

hongzhidao avatar hongzhidao commented on August 30, 2024

Hi,

@ac000 @andypost
Could you try NGINX with the same OS?

> git clone https://github.com/nginx/nginx.git
> cd nginx
> ./auto/configure && make

@andrey-zelenkov Do we need to add it to BB?

from unit.

ac000 avatar ac000 commented on August 30, 2024

nginx has the same issue

$ auto/configure --with-cc=clang && make -j4
...
clang -c -pipe  -O -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/event/quic -I src/os/unix -I objs \
        -o objs/src/event/ngx_event_connect.o \
        src/event/ngx_event_connect.c
src/event/ngx_event_udp.c:143:25: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
                 cmsg = CMSG_NXTHDR(&msg, cmsg))
                        ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
        __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

from unit.

hongzhidao avatar hongzhidao commented on August 30, 2024

Good catch, thanks.

from unit.

thresheek avatar thresheek commented on August 30, 2024

See https://trac.nginx.org/nginx/ticket/2534 for the related issue in nginx. They decided not to fix that.

from unit.

andypost avatar andypost commented on August 30, 2024

@ac000 thank you for patch! it allows to build meantime exposed issues on armv7 and armv8 and riscv64

checking for GCC __builtin_expect() ... not found
checking for GCC __builtin_unreachable() ... not found
checking for GCC __builtin_prefetch() ... not found
checking for GCC __builtin_clz() ... not found
checking for GCC __builtin_popcount() ... not found
checking for GCC __attribute__ visibility ... not found
checking for GCC __attribute__ aligned ... not found
checking for GCC __attribute__ malloc ... not found
checking for GCC __attribute__ packed ... not found
checking for GCC __attribute__ unused ... not found
checking for GCC builtin atomic operations ... not found
checking for Solaris builtin atomic operations ... not found
checking for xlC builtin atomic operations ... not found
./configure: error: no atomic operations found.

maybe it's related to clang for this arches but at least "GCC" prefix for atomics is confusing when building with clang

from unit.

andypost avatar andypost commented on August 30, 2024

Using clang 15.0.7 I'm getting the same error

from unit.

ac000 avatar ac000 commented on August 30, 2024

@andypost

Thanks for testing.

@ac000 thank you for patch! it allows to build meantime exposed issues on armv7 and armv8 and riscv64

checking for GCC __builtin_expect() ... not found
checking for GCC __builtin_unreachable() ... not found
checking for GCC __builtin_prefetch() ... not found
checking for GCC __builtin_clz() ... not found
checking for GCC __builtin_popcount() ... not found
checking for GCC __attribute__ visibility ... not found
checking for GCC __attribute__ aligned ... not found
checking for GCC __attribute__ malloc ... not found
checking for GCC __attribute__ packed ... not found
checking for GCC __attribute__ unused ... not found
checking for GCC builtin atomic operations ... not found
checking for Solaris builtin atomic operations ... not found
checking for xlC builtin atomic operations ... not found
./configure: error: no atomic operations found.

maybe it's related to clang for this arches but at least "GCC" prefix for atomics is confusing when building with clang

Hmm, we just have the three above checks here, one for GCC 4.1+ (heh, I'm just quoting the auto/atomic script), Solaris 10 & AIX xlC. The mind boggles, I suspect these just came straight from nginx...

It's also weird that it failed to find all the builtins and attributes...

I assume GCC builds Unit fine on such systems?

Some more investigation is probably required...

from unit.

andypost avatar andypost commented on August 30, 2024

Yes, using GCC it builds/works fine, I just attempted to use clang to see effect

from unit.

ac000 avatar ac000 commented on August 30, 2024

Thanks for confirming.

No, sure, while GCC is my compiler of choice I see value in also testing with clang, they both find different issues in code.

from unit.

ac000 avatar ac000 commented on August 30, 2024

Fix was committed.

from unit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.