Conversation
Changes: - Change 'static const' to 'inline const' for ssl_category and stream_category - Add optional SSL support via ASIO_ENABLE_SSL CMake option (default: OFF) - Resolves 'cannot export symbol with internal linkage' compilation error The inline specifier ensures external linkage while maintaining semantics.
- Fix typo in asio-gmf.h: 'openssl / conf.h' -> 'openssl/conf.h' - Add SYSTEM keyword for OpenSSL include directories - Change ASIO_ENABLE_SSL default to ON - Add detailed logging for OpenSSL paths
|
Great! 🎉 |
ecoezen
left a comment
There was a problem hiding this comment.
hey! import std in asio.ixx must be moved after asio module declaration, but remaining comments are not critical that requires changes, an left for general discussion, and potential quality improvements.
|
Does import std;
import asio;work under any of the compilers? without ifdef-ing includes out, I got the impression it probably doesn't as of today. Are you running the test suite importing instead of including? |
|
At least it did in 2022 (see my plenary talk at CppCon 2022 and some of my later talks), and it still does today. I've tested with msvc and clang back then, but not with gcc (for obvious reasons). |
|
I've done a quick check with VS2026, building Asio with the additional changeset both as a named module and a header unit. The build of a small in-house application of ours together with the modularized standard library and a couple of other modules is fine, and the application works a expected. |
yes, not all compilers(Not Only the current
NOT yet, I need to write CMakeLists.txt for the tests, I dit is years ago, It should be possible again. |
|
I've done a little playing and this fails to compile under clang-22/libc++/Ubuntu 24.04: import std;
import asio;
#include <iterator>Interestingly, this builds fine: import asio;
#include <iterator>I recalled that the problems with mixing include and import std happened transitively, but it looks like this is not the case anymore. |
|
FYI, in my Boost modularization prototype I'm using the notion of "compatibility headers", which will include the standard header or not depending on a config macro (like your https://github.com/anarthal/config/blob/feature/cxx20-modules/include/boost/config/std/algorithm.hpp |
yes, actually i personally adopted compat headers way as well. it is far more cleaner than preprocessor clutter. i am working on it now. |
introduce per-header wrappers (include/asio/detail/std/) and a cmake script (module/module_compat.cmake) to manage them atomically. core invariant: std headers are never reachable in module purview. - without import std: headers included in gmf only - with import std: only macro-providing headers in gmf (types come from import std; macros cannot) - purview: always blocked for std headers asio-gmf.h now owns the ASIO_IN_GMF define lifecycle. all asio includes rewritten via the cmake script. ran module_compat.cmake to generate headers and update existing header files to use generated wrapper headers for std includes.
|
i'll look at CI stuff soon. fyi @ClausKlein |
|
@ecoezen we should add a Windows CI build on |
- add CMakePresets.json with initial configurations for MSVC, GCC, and Clang [WIP] - extract experimental 'import std' logic into cmake/enable_import_std.cmake - clean up root CMakeLists.txt by moving fragile, hardcoded compiler flags into presets - adapts CMakeLists.txt to changes accordingly
|
hey @ClausKlein. I clean up cmake a bit, introduce an initial cmake presets configuration and updated actions accordingly. i noticed we werent tested import std properly in previous workflows. current failures are import std failures with both clang and gcc. msvc works fine on both modes. feel free to tweak workflows, run conditions etc as i may have changed your initial configurations. notes/todos:
current failure:
=> last 2 commits are still WIP in nature. if you don't like the direction, please feel free to revert it and direct me accordingly. @ClausKlein |
|
Note that for gcc, include and then import works for std, but the other way around doesn't. This applies even if the included file is located in a TU that becomes reachable through an import. |
by the commit b12e96c, there is no longer any std includes in module purview. all std includes strictly restricted in global module fragment, with the help of compability headers that guard std header inclusions with ASIO_IN_GMF preprocessor definition. thus, the aforementioned error has been already resolved for the standard library usage in asio. fyi. logic is as following:
|
…ON path resolution when building with libc++
… to fix module link errors msvc 19.50 incorrectly drops definitions of unexported inline variables.
|
hey @ClausKlein, I pushed a few updates to the PR. when you have a chance, could you take a look and let me know what you think? happy to iterate further if needed. |
| extern "C++"{ | ||
| inline const winsock_init<>& winsock_init_instance = winsock_init<>(false); | ||
| } |
There was a problem hiding this comment.
You understand that enclosing a declaration with an extern "C++" linkage specification [dcl.link] doesn't affect the linkage of inline variable 'winsock_init_instance' at all, right? It has module linkage, "C++" language linkage like before. The only change is in attachment.
That variable will get initialized as soon as module 'asio' is nominated for import for the first time in transitive appearance order of the module interface dependency tree.
There was a problem hiding this comment.
you are right, my wording was poor. the intent is indeed to detach the declaration from the named module so it is no longer attached to asio. i still sometimes (incorrectly) use terms like external/global linkage when i really mean module attachment tweaks, so thanks for the correction.
with msvc 19.50 we observed that an unexported inline definition attached to the module can be discarded if it is not referenced within the module unit itself. when consumers import asio and instantiate templates that reference winsock_init_instance, the linker then fails to find the definition.
placing it inside a linkage-specification detaches the declaration, which makes msvc emit the definition normally and resolves the linker errors. i also considered __declspec(selectany) as an alternative, but this approach seemed preferable since it avoids compiler-specific attributes.
There was a problem hiding this comment.
I don't see that in my own current tests using cl.exe 19.50.35725, but did some time in the past:
Miscompiled dynamic initializers
Anyway, do whatever you prefer, it doesn't really matter.
There was a problem hiding this comment.
This is a different problem: you see a missing linker symbol. I never did.
The problem that I've reported back to the compiler team was the fact that the code for initializing the variable (i.e. the call to the initializer) wasn't even generated in the first place. 💥at the first instance where an initialized WinSock is required. This is what I am testing for.
There was a problem hiding this comment.
yes! that's why i got a bit confused because the error i was facing was a simple codegen bug that boom during linking. i hope this fix survives your initialization tests without any 💥!
e049443 Feat: Modernize
CMakeLists.txtto build and installCXX_MODULE asiothe Daniela's wayimport std;where toolchain supports itimport std;too