Skip to content

Release Windows packages #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 26, 2022
Merged

Release Windows packages #5

merged 2 commits into from
Oct 26, 2022

Conversation

BewareMyPower
Copy link
Owner

No description provided.

### Motivation

Currently it's impossible to build Pulsar C++ client on Windows with
`LINK_STATIC=ON`. It means users have to package all 3rd-party DLLs as
well as `pulsar.dll`, which harms the experience.

### Modifications

Enable `LINK_STATIC` when the Vcpkg triplet is `xxx-static`. In this
case, find the 3rd party libraries with correct names on Windows. And
replace `Threads::Threads` with `CMAKE_THREAD_LIB_INIT`.

The most important change is replacing the `/MD` compile option with
`/MT`. It should have been done by setting the
[`MSVC_RUNTIME_LIBRARY`](https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html)
property, but it seems not work. So this PR just modifies the
`CMAKE_CXX_FLAGS_<CONFIG>` variables.

For `pulsarWithAllDeps.lib`, add the actual library (`*.lib`) to
`COMMON_LIBS` instead of the target name (`dlfcn-win32::dl`).

Some warnings on Windows caused by incorrect compile options are fixed
as well.

A workflow is added to verify the static build for x64 and x86 Windows.
And a simple example is added as `win-examples` to show the
`pulsarWithAllDeps.lib` can be linked without any other dependency to
run an executable.

### TODO

- Add the workflow to build Windows releases when pushing a tag
- Support debug building with `LINK_STATIC=ON`
@BewareMyPower BewareMyPower merged commit 4f965a9 into main Oct 26, 2022
@BewareMyPower BewareMyPower deleted the bewaremypower/win-release branch October 26, 2022 10:05
BewareMyPower added a commit that referenced this pull request Oct 26, 2022
* Support linking static dependencies when building with MSVC

   See apache#73

* Add Windows packaging
BewareMyPower added a commit that referenced this pull request Oct 28, 2022
BewareMyPower added a commit that referenced this pull request Nov 22, 2022
### Motivation

When I ran the tests of Python wrapper in my local env, I observed a
segmentation fault. See the key stacktrace:

```
#3  0x00007ffff6d742c5 in std::unique_lock<std::mutex>::lock() () from /usr/local/lib/python3.8/dist-packages/_pulsar.cpython-38-x86_64-linux-gnu.so
#4  0x00007ffff6d72523 in std::unique_lock<std::mutex>::unique_lock(std::mutex&) ()
   from /usr/local/lib/python3.8/dist-packages/_pulsar.cpython-38-x86_64-linux-gnu.so
#5  0x00007ffff67de193 in pulsar::ClientImpl::newRequestId (this=0x0) at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ClientImpl.cc:644
#6  0x00007ffff685d2c2 in pulsar::ConsumerImpl::~ConsumerImpl (this=0x7fff9800f9e0, __in_chrg=<optimized out>)
    at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ConsumerImpl.cc:116
```

In the destructor of `ConsumerImpl`, `client->newRequestId` might be
called. However, `client` might be a null pointer because it's returned
by `std::weak_ptr::lock()`.

### Modifications

Add null check to avoid the segfault.
BewareMyPower added a commit that referenced this pull request Nov 28, 2022
…#121)

### Motivation

When I ran the tests of Python wrapper in my local env, I observed a
segmentation fault. See the key stacktrace:

```
#3  0x00007ffff6d742c5 in std::unique_lock<std::mutex>::lock() () from /usr/local/lib/python3.8/dist-packages/_pulsar.cpython-38-x86_64-linux-gnu.so
#4  0x00007ffff6d72523 in std::unique_lock<std::mutex>::unique_lock(std::mutex&) ()
   from /usr/local/lib/python3.8/dist-packages/_pulsar.cpython-38-x86_64-linux-gnu.so
#5  0x00007ffff67de193 in pulsar::ClientImpl::newRequestId (this=0x0) at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ClientImpl.cc:644
#6  0x00007ffff685d2c2 in pulsar::ConsumerImpl::~ConsumerImpl (this=0x7fff9800f9e0, __in_chrg=<optimized out>)
    at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ConsumerImpl.cc:116
```

In the destructor of `ConsumerImpl`, `client->newRequestId` might be
called. However, `client` might be a null pointer because it's returned
by `std::weak_ptr::lock()`.

### Modifications

Add null check to avoid the segfault.
BewareMyPower added a commit that referenced this pull request Feb 7, 2023
…#121)

### Motivation

When I ran the tests of Python wrapper in my local env, I observed a
segmentation fault. See the key stacktrace:

```
#3  0x00007ffff6d742c5 in std::unique_lock<std::mutex>::lock() () from /usr/local/lib/python3.8/dist-packages/_pulsar.cpython-38-x86_64-linux-gnu.so
#4  0x00007ffff6d72523 in std::unique_lock<std::mutex>::unique_lock(std::mutex&) ()
   from /usr/local/lib/python3.8/dist-packages/_pulsar.cpython-38-x86_64-linux-gnu.so
#5  0x00007ffff67de193 in pulsar::ClientImpl::newRequestId (this=0x0) at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ClientImpl.cc:644
#6  0x00007ffff685d2c2 in pulsar::ConsumerImpl::~ConsumerImpl (this=0x7fff9800f9e0, __in_chrg=<optimized out>)
    at /home/xyz/github.com/apache/pulsar-client-cpp/lib/ConsumerImpl.cc:116
```

In the destructor of `ConsumerImpl`, `client->newRequestId` might be
called. However, `client` might be a null pointer because it's returned
by `std::weak_ptr::lock()`.

### Modifications

Add null check to avoid the segfault.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant