Skip to content

Commit

Permalink
Work around Windows-only problems
Browse files Browse the repository at this point in the history
The Unifex unit test suite won't build for Windows with async stack
injection enabled *unless* PR #619 (Make any_sender_of<> play nicer with
MSVC) is also merged, but that PR causes Windows + Clang + ASAN errors
in Meta-internal builds.

This diff works around the above conflict by disabling async stack
injection in Windows builds by default so we don't need PR #619. We can
change the default once we figure out a proper resolution to the ASAN
problem.
  • Loading branch information
ispeters committed Jul 16, 2024
1 parent b3ddfc1 commit a37253f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
18 changes: 16 additions & 2 deletions include/unifex/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,21 @@
#endif

#if defined(__has_builtin)
#define UNIFEX_HAS_BUILTIN(...) __has_builtin(__VA_ARGS__)
# define UNIFEX_HAS_BUILTIN(...) __has_builtin(__VA_ARGS__)
#else
#define UNIFEX_HAS_BUILTIN(...) 0
# define UNIFEX_HAS_BUILTIN(...) 0
#endif

#if !defined(UNIFEX_NO_ASYNC_STACKS)
// default:
// - release builds do not have async stacks
// - Windows builds do not have async stacks
//
// adding async stacks adds non-trivial binary size at the moment, and I can't
// figure out how to make all the relevant Windows builds succeed
# if defined(NDEBUG) || defined(_MSC_VER)
# define UNIFEX_NO_ASYNC_STACKS 1
# else
# define UNIFEX_NO_ASYNC_STACKS 0
# endif
#endif // !defined(UNIFEX_NO_ASYNC_STACKS)
14 changes: 13 additions & 1 deletion include/unifex/sender_concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,23 @@ struct _fn {
}
};

#if UNIFEX_NO_ASYNC_STACKS
public:
template(typename S, typename R) //
(requires sender<S> AND receiver<R>) //
auto
operator()(S&& s, R&& r) const
noexcept(noexcept(_impl{}(std::forward<S>(s), std::forward<R>(r))))
-> decltype(_impl{}(std::forward<S>(s), std::forward<R>(r))) {
return _impl{}(std::forward<S>(s), std::forward<R>(r));
}
#else
template <typename S, typename R>
using op_t = _inject::op_wrapper<std::invoke_result_t<_impl, S, _inject::receiver_t<R>>, R>;

public:
template(typename S, typename R) //
(requires sender<S> AND receiver<R>)
(requires sender<S> AND receiver<R>) //
auto
operator()(S&& s, R&& r) const
noexcept(noexcept(_inject::make_op_wrapper(std::forward<S>(s), std::forward<R>(r), _impl{})))
Expand All @@ -287,6 +298,7 @@ struct _fn {
std::forward<R>(r),
_impl{});
}
#endif
};

} // namespace _cpo
Expand Down
5 changes: 5 additions & 0 deletions include/unifex/tracing/inject_async_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#pragma once

#include <unifex/config.hpp>

#if !UNIFEX_NO_ASYNC_STACKS

#include <unifex/receiver_concepts.hpp>
#include <unifex/tracing/async_stack.hpp>
#include <unifex/tracing/get_async_stack_frame.hpp>
Expand Down Expand Up @@ -235,3 +238,5 @@ auto make_op_wrapper(S&& s, R&& r, Fn&& fn) noexcept(
} // namespace unifex

#include <unifex/detail/epilogue.hpp>

#endif // !UNIFEX_NO_ASYNC_STACKS

0 comments on commit a37253f

Please sign in to comment.