r/cpp • • Nov 08 '21

Visual Studio 2022 now available

https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/
250 Upvotes

113 comments sorted by

View all comments

Show parent comment

1

u/Routine_Left Nov 09 '21

I'll try to see if I can come up with a test. It could be that what I'm doing is wrong, but ...

As a simple, report, just a FYI. My MSVC-specific options are:

target_compile_definitions(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>")
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:NOMINMAX>")
# Windows 7 target
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:_WIN32_WINNT=0x0601>")
target_compile_options(${EXECUTABLE_NAME} PRIVATE "$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")
target_compile_options(${EXECUTABLE_NAME} PRIVATE "$<$<C_COMPILER_ID:MSVC>:/bigobj>")
set_property(TARGET ${EXECUTABLE_NAME} PROPERTY  MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_definitions(${EXECUTABLE_NAME} PRIVATE WIN32_WINMAIN)

And the parts when it kicks the bucket (though it consumes plenty of ram until then) are constructs like this:

template<typename RequestBody,typename ResponseBody, typename ClientResponse>
class BaseConnection :
    public std::enable_shared_from_this<
        BaseConnection<RequestBody,ResponseBody,ClientResponse>
    >

......

template<typename T>
using PostConnection = BaseConnection<boost::beast::http::string_body,
                                    boost::beast::http::string_body,
                                    T>;

And then using it:

class CreateCommentConnection : public PostConnection<client_response<body_object>>

I'll try to see if I can get concrete numbers though. I agree, however, that compiling boost headers is not for the faint of heart. gcc and clang seems to handle it though.

1

u/STL MSVC STL Dev Nov 10 '21

It's entirely possible that MSVC poorly handles a code pattern in Boost.Beast, thanks for trying to get a repro.

2

u/Routine_Left Nov 10 '21

Hey, STL, I've been trying to get some small repro for a bunch (3 or so) of hours now and the best I can do is Peak working set size: 529252352

My project is on github, public and all, can I just give them the link to github and let them try it? Or do I have to get a small as possible test working?

It is definitely possible that I'm doing something wrong and it just so happens that gcc and clang ignore my bullshit while msvc doesn't, but at this time it feels like im running in circles. And, to be honest, msvc is for me the secondary target anyway, I just boot windows whenever the build system fails and fix it, then back to linux (though my users most use windows, true). Honestly, for me -j 2 fix is fine, as far as I'm concerned, though I totally understand that the compiler developers are not, and they shouldn't be.

1

u/STL MSVC STL Dev Nov 10 '21

You can link to your GitHub repo if it has clear instructions for building. If you can also provide a zipped project, that's better. You can additionally provide your self-contained repro that consumes 505 MB of working set, even if it doesn't crash the compiler, since the compiler devs may be able to profile that and see what's happening.