Add diagnostic output for TCP connections on both sides, llvm-jitlink and llvm-jitlink-executor.
Port the executor to use getaddrinfo(3) as well. This makes the code more symmetric and seems to be the recommended way for implementing the server side.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Follow-up patch that submits learnings from fixing D98579. The error it fixed would now print as:
Failed to connect TCP socket 'localhost:13921': Address resolution failed (Bad hints)
Some sample output for llvm-jitlink with various broken addresses:
Failed to connect TCP socket 'localhost:1': Connection refused (inactive)
Failed to connect TCP socket '8.8.8.8:1': Operation timed out (non-responding)
Failed to connect TCP socket '127.0.0.1:0': Can't assign requested address
Failed to connect TCP socket '127.0.0.1:-1': Address resolution failed (nodename nor servname provided, or not known)
Failed to connect TCP socket '127.0.0.1': Port for -oop-executor-connect can not be empty
Running llvm-jitlink-executor on a port that is busy:
Error on binding: Address already in use
In success case llvm-jitlink-executor dumps some convenient server'ish output:
> bin/llvm-jitlink-executor listen=localhost:13921 Listening at localhost:13921 Connection established. Running OrcRPCTPCServer...
llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp | ||
---|---|---|
94 | This line fails compilation on AIX in 64-bit mode: llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp:93:10: error: no matching function for call to 'accept' return accept(SockFD, AI->ai_addr, &AI->ai_addrlen); ^~~~~~ /usr/include/sys/socket.h:635:9: note: candidate function not viable: no known conversion from 'size_t *' (aka 'unsigned long *') to 'socklen_t *' (aka 'unsigned int *') for 3rd argument int accept(int, struct sockaddr *__restrict__, socklen_t *__restrict__); ^ 1 error generated. Error while processing llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp. The size is always going to fit into an unsigned int. So perhaps we need to store AI->ai_addrlen into a socklen_t temp first? |
Add special-case for calling accept(2) on AIX. I cannot test it here, @rzurob does this work for you?
llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp | ||
---|---|---|
94 | Interesting, the ai_addrlen field should be of type socklen_t naturally: struct addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; socklen_t ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct addrinfo *ai_next; }; Do you think it's fine to keep this as a special-case for AIX? Does the connect call on the client side in D98579 suffer from the same issue? |
LGTM
llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp | ||
---|---|---|
94 | You're right that the AIX header is not declaring ai_addrlen as what POSIX says. I've reported it to them. |
This breaks the build on Windows: http://45.33.8.238/win/35472/step_4.txt
Please take a look, and please revert for now and fix async if it takes a while to fix.
llvm/tools/llvm-jitlink/llvm-jitlink.cpp | ||
---|---|---|
680 | No, I think it's this one (at least partially). This here used to be behind LLVM_ON_UNIX but now it isn't. Probably just needs to go back behind that check. |
This line fails compilation on AIX in 64-bit mode:
The size is always going to fit into an unsigned int. So perhaps we need to store AI->ai_addrlen into a socklen_t temp first?