Repository navigation
Conversation
|
A skim across projects around libssh2 and curl, only LibreSSL sets it, when Why do we want to to automate this in libssh2 specifically? |
|
curl doesn't seem to use any extended POSIX functions that'd require this. But to explain better: libssh2 compilation currently assumes extended POSIX functions are always available. In practice this means the assumption that that the compiler compiles using There's three ways to approach fixing this:
I've gone with the first approach as that was the easiest and ensures that such non-portable occurrences are harder to re-introduce by the virtue of just globally enabling it everywhere. It might however be reasonable to just introduce a CI combination that uses |
I could probably scope similarly here. |
|
I meant to refer to libssh2 and curl dependencies, sorry for being vague. Can you say what errors do you see? I tried with Footnotes
|
Changed the checks to
Right, forgot about this. CMake's standard flag selection logic used to be quite buggy. This included
Precisely. Sorry for being so succint in the original PR. There's also cases in examples and tests: |
|
Thanks for the details! I wonder if it'd be a better approach to update the code to not use POSIX extensions? The chacha code uses types could be replaced with standard ones. In case of |
Absolutely, done! |
a17623e to
1c99926
Compare
|
I'll open a separate PR to try bump maximum CMake range and add to a |
c887f6d to
54a4940
Compare
|
@vszakats Minor ping. Let me know if I should bring the CI commit into this PR. 🙂 |
|
If you pull up to master it should fix CI. I don't see much else to do with this MR, is it ready to go? |
|
Rebased. As far as I am concerned this MR is ready. |
IV setup supports a 64-bit sequence number so might as well take them in.
These are BSD/SysV extensions not available in ISO C mode.
When compiling in ISO C mode these aren't defined without a macro enabling them.
In ISO C mode it doesn't get transitively included.
|
I have an alternate take on this in #1688 Did not have the resources to reconcile that with this PR. My concern with this |
|
CI changes are in #1683. I'm still chasing down one macOS issue related to the policy changes (CMP0128 must be |
#1683 is CMake-specific, raises minimum version, wants to changes policies, edit: it also should be done in the same PR that's doing the necessary fixes to |
|
|
||
| #ifdef HAVE_SYS_SELECT_H | ||
| #include <sys/select.h> | ||
| #endif |
There was a problem hiding this comment.
Why is this necessary? What is the error it's fixing?
There was a problem hiding this comment.
[13/108] Building C object example/CMakeFiles/direct_tcpip.dir/direct_tcpip.c.o
FAILED: [code=1] example/CMakeFiles/direct_tcpip.dir/direct_tcpip.c.o
/usr/bin/cc -DHAVE_CONFIG_H -I/home/raul/dev/libssh2/build/src -I/home/raul/dev/libssh2/src -I/home/raul/dev/libssh2/include -Wextra -Wall -pedantic -Wbad-function-cast -Wconversion -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wno-long-long -Wno-multichar -Wpointer-arith -Wshadow -Wsign-compare -Wundef -Wunused -Wwrite-strings -Waddress -Wattributes -Wcast-align -Wcast-qual -Wdeclaration-after-statement -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-security -Wignored-qualifiers -Wmissing-field-initializers -Wmissing-noreturn -Wno-format-nonliteral -Wno-system-headers -Wold-style-definition -Wredundant-decls -Wsign-conversion -Wno-error=sign-conversion -Wstrict-prototypes -Wtype-limits -Wunreachable-code -Wunused-macros -Wunused-parameter -Wvla -Wshift-sign-overflow -Wshorten-64-to-32 -Wformat=2 -Wlanguage-extension-token -Wdouble-promotion -Wenum-conversion -Wheader-guard -Wpragmas -Wsometimes-uninitialized -Wunused-const-variable -Wcomma -Wmissing-variable-declarations -Wassign-enum -Wextra-semi-stmt -Wimplicit-fallthrough -Wxor-used-as-pow -MD -MT example/CMakeFiles/direct_tcpip.dir/direct_tcpip.c.o -MF example/CMakeFiles/direct_tcpip.dir/direct_tcpip.c.o.d -o example/CMakeFiles/direct_tcpip.dir/direct_tcpip.c.o -c /home/raul/dev/libssh2/example/direct_tcpip.c
/home/raul/dev/libssh2/example/direct_tcpip.c:67:20: error: variable has incomplete type 'struct timeval'
67 | struct timeval tv;
| ^
/home/raul/dev/libssh2/example/direct_tcpip.c:67:12: note: forward declaration of 'struct timeval'
67 | struct timeval tv;
| ^
/home/raul/dev/libssh2/example/direct_tcpip.c:249:9: error: use of undeclared identifier 'fd_set'
249 | fd_set fds;
| ^~~~~~
/home/raul/dev/libssh2/example/direct_tcpip.c:250:9: error: use of undeclared identifier 'FD_ZERO'
250 | FD_ZERO(&fds);
| ^~~~~~~
/home/raul/dev/libssh2/example/direct_tcpip.c:250:18: error: use of undeclared identifier 'fds'
250 | FD_ZERO(&fds);
| ^~~
/home/raul/dev/libssh2/example/direct_tcpip.c:255:9: error: use of undeclared identifier 'FD_SET'
255 | FD_SET(forwardsock, &fds);
| ^~~~~~
/home/raul/dev/libssh2/example/direct_tcpip.c:255:30: error: use of undeclared identifier 'fds'
255 | FD_SET(forwardsock, &fds);
| ^~~
/home/raul/dev/libssh2/example/direct_tcpip.c:261:14: error: use of undeclared identifier 'select'
261 | rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv);
| ^~~~~~
/home/raul/dev/libssh2/example/direct_tcpip.c:261:46: error: use of undeclared identifier 'fds'
261 | rc = select((int)(forwardsock + 1), &fds, NULL, NULL, &tv);
| ^~~
/home/raul/dev/libssh2/example/direct_tcpip.c:270:18: error: use of undeclared identifier 'FD_ISSET'
270 | if(rc && FD_ISSET(forwardsock, &fds)) {
| ^~~~~~~~
/home/raul/dev/libssh2/example/direct_tcpip.c:270:41: error: use of undeclared identifier 'fds'
270 | if(rc && FD_ISSET(forwardsock, &fds)) {
| ^~~
10 errors generated.
Per POSIX those functions are in <sys/select.h>.
On most systems in GNU mode the other headers happen to pull that also in.
Doesn't seem to be the case in ISO C mode.
There was a problem hiding this comment.
Thanks. Could reproduce in CI with !tests and !_DEFAULT_SOURCE:
https://github.com/libssh2/libssh2/actions/runs/24107290427/job/70333563236
I'm readding them because it is the canonical header for select(), and
removing them in a683133 was not accurate.
Touching CMake is mostly auxiliary cleanup except for the side effect of setting Closing in favour of #1688 and will provide feedback on there to help get it into shape. 🙂 |
Note: On Linux with glibc, ISO mode also requires setting the `_DEFAULT_SOURCE` macro to enable necessary POSIX features when building tests (for `popen()`, `pclose()` and examples (for `fileno()`, `tcsetattr()`). On other platforms and environments it may require something else. - replace `strdup()` with local implementation. - replace `getline()` with C89 `fgets()`. - replace `u_char`, `u_int` with C89 types. - fix type mismatches in chacha-poly1305 code. - silence `-Wno-format-nonliteral` locally. The global method was not effective (like because it was overridden by `-Wformat=2`) and caused these warnings when building in C89 mode. - GHA: test ISO C89 in zlib-enabled Linux jobs with all crypto backends. - fix formatting nits along the way. - configure, cmake: silence silly `-Wno-comma` warnings with clang in C89 mode. - examples: include `select.h` again, where `select()` is used. As its canonical header. Seen required on Linux glibc non-GNU/ISO builds. Follow-up to a683133 #999 Assisted-by: Raul Tambre Ref: #1674 Closes #1688
If the compiler defaults to non-GNU mode
_DEFAULT_SOURCEneeds to be explicitly defined for Linux headers to expose definitions for various POSIX extensions.