The generated configurations for both CMake and pkg-config included
absolute paths to dependencies (OpenSSL, MbedTLS). This is contrary
to the general CMake advise to create relocatable packages [1].
Additionally, when building both mbedtls and libevent via CMake's
FetchContent in the same project, loading the project would fail with
INTERFACE_INCLUDE_DIRECTORIES property contains path:
"/home/user/project/cmake-build/_deps/mbedtls-build/include"
which is prefixed in the source directory.
The required changes include:
- Adding the outer includes only to the BUILD_INTERFACE solves the
makes the CMake paths relocatable and thus solves the FetchContent
problem.
- Updates to libevent_*.pc.in fixes the relocatable issues for
pkg-config and properly declares currently missing dependencies.
- Using components for linking to OpenSSL (requiring CMake 3.4)
and MbedTLS. The new MbedTLS target names now match the component
names of the MbedTLS' CMake project.
- Use the Threads CMake library reference instead of a direct
reference to support both built-in pthread and -lpthread.
v2 (azat): get back CMAKE_REQUIRED_LIBRARIES
[1] https://cmake.org/cmake/help/v3.25/manual/cmake-packages.7.html#creating-relocatable-packages
As described in #1404, the explicit use of CMAKE_INSTALL_PREFIX conflicts with using command-line --prefix.
This simply removes all explicit use of CMAKE_INSTALL_PREFIX.
Otherwise this path will be duplicated:
$ cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=inst ..
$ DESTDIR=inst ninja install
...
-- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/util.h
-- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/ws.h
...
Fixes: #1404
Co-authored-by: Jeremy Murphy <jeremymu@blackmagicdesign.com>
* upstream/pr/1397:
Make sure exported include dirs are correct
Fix Configure_RPATH()
Install LibeventConfig.cmake similar to other cmake files
Use GNUInstallDirs for mapping installation directories
CMake config files don't need any logic to detect the location of
installed headers or DSOs, because these locations are already
determined at project configuration time. They also don't need
to distinguish between build and install trees, because that is
already handled by the generated `LibeventTargets-*.cmake` files.
compiler warning:
test/regress_http.c:968:38: warning: result of comparison of constant 65536 with expression of type 'enum evhttp_cmd_type' is always true [-Wtautological-constant-out-of-range-compare]
if (evhttp_request_get_command(req) != EVHTTP_REQ_CUSTOM) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
For the CMake release build with -DEVENT__ENABLE_GCC_WARNINGS=ON
and -DEVENT__DISABLE_MM_REPLACEMENT=ON, GCC version 11 and 12 may
complain about possibly uninitialized variable:
In function ‘event_debug_assert_not_added_’,
inlined from ‘event_assign’ at event.c:2184:2,
inlined from ‘event_new’ at event.c:2276:6:
cc1: error: ‘ev’ may be used uninitialized [-Werror=maybe-uninitialized]
event.c: In function ‘event_new’:
event.c:361:13: note: by argument 1 of type ‘const struct event *’ to event_debug_assert_not_added_.part.0’ declared here
361 | static void event_debug_assert_not_added_(const struct event *ev)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This warning is most likely a false positive and can be silenced
by explicitly disabling inlining for 'event_assign()'.
Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Previously in case when evbuffer_reserve_space() returns > 1, but
it was able to read only 1 IO vector, it will try to read the next one,
got 0 (EOF for mbedTLS or SSL_ERROR_ZERO_RETURN for OpenSSL) and will
trigger EOF, while instead, it should trigger EV_READ w/o EOF and only
after EOF.
Now that the jobs are running again, a number of deprecation warnings
have surfaced
https://github.com/libevent/libevent/actions/runs/4876367881:
```bash
Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: actions/checkout@v2.0.0.
```
Looks like the most straightforward thing todo here is just use the
newer version of the checkout action.
Also move to the v1 tag for the coveralls job, rather than a pinned,
much older version (the latest release is 1.2.5, https://github.com/coverallsapp/github-action/releases).
Same again for actions/cache.
It is not a thankless task to fix such issues on and on, let's just
prohibit this cases, and our build with -Werror on CI will show new
issues from now on.
Fixes: #1434
This is output when compiling (natively) on macOS systems, which is
confusing, because no cross-compilation is involved.
Split the message into separate cases.
SSL write may do partial writes in some cases. For example, document
of mbedtls_ssl_write says:
If the return value is non-negative but less than length, the function
must be called again with updated arguments: buf + ret, len - ret
(if ret is the return value) until it returns a value equal to the
last 'len' argument.
In case of partial writes, we should continue writing the same chain of
buffer, not the next chain.
github action reports "internal error" for builds on ubuntu 18.04:
linux-cmake-job (ubuntu-18.04, COMPILER_CLANG)
This is a scheduled Ubuntu-18.04 brownout. The Ubuntu-18.04 environment is deprecated and will be removed on April 1st, 2023. For more details, see https://github.com/actions/runner-images/issues/6002
linux-cmake-job (ubuntu-18.04, COMPILER_CLANG)
GitHub Actions has encountered an internal error when running your job.
Change made by setting top-level read-only permisisons, and any
other necessary permissions set as job-level.
Closes#1421
Signed-off-by: Diogo Teles Sant'Anna <diogoteles@google.com>
This just copies the same logic used to find OpenSSL on macOS using homebrew, for finding mbedtls via brew. Without it, the build will fail out the box with a brew installed mbedtls.
When libevent doesn't provide random the arc4 function, but they come from libc, there is no need to call this function, so make it do nothing.
Fixes: #1393
1. In d4de062, in Feb 2010, libevent adopted OpenBSD implementation of
arc4random_uniform.
2. In
728918cba9,
in Jun 2012, OpenBSD improved their implementation to be faster, by
changing arc4random_uniform() to calculate ``2**32 % upper_bound'' as
``-upper_bound % upper_bound''.
Alternatively we can simply remove arc4random_uniform() since it is not
used by libevent anyway, but let's just sync the header for now.