13 ms·
MSVC's implementation of the C++ Standard Library
- ezoe 7y agoDue to its nature of C++ templates, MSVC STL source code was practically available to anybody. I think in theory, I could get hand on free of charge version of MSVC without agreeing the MS EULA then extract the archive, again without agreeing the MS UELA, and peak the source code. In reality, I don't bother to do that and whenever I teach C++, I ignore MSVC and its STL. I'm willing to teach but Nooo, it's MS who prohibit me to do so. Now I can't use that excuse anymore.
- saagarjha 7y agoOoh, nice! It’s always fun to look at alternative STL implementations to see how a class is implemented.
- userbinator 7y agoThe MSVC library has always been "source available" with Visual Studio, but I guess MS thought that they're very unlikely to actually make a profit from it[1] so they're giving it a permissive license instead. [1] The "new MS" seems to delight a lot of people, but IMHO it's not all great; I'd much rather they not be "shedding" all this open-source stuff and kept selling software, if it meant they wouldn't stuff telemetry in everything they touch.
- muststopmyths 7y agoActually, the c++ lib has never been available to my recollection (only the base CRT). And they don't even ship the CRT with the compiler any more.
- intern4tional 7y agoCorrect, this is a net new release. Right now it's a little rough with lots of pieces missing, but once it's all out there it should have benefit. An example would be if any performance enhancements can be ported to other C++ implementations.
- puetzk 7y ago> And they don't even ship the CRT with the compiler any more Just in case you/any other reader didn't know: That's just because they don't consider the ucrt compiler-version-specific anymore, it's distribution (binaries and source) moved into the windows SDK, E.g. Windows Kits\10\Source\10.0.17763.0\ucrt. The vcruntime is still with MSVC. But this source never included the STL.
- muststopmyths 7y agoYou are correct. I'm using an obsolete name for the library that contains the dang functions I want to debug :) I honestly don't understand the rationale for putting it in the Windows SDK. It's not like any other compiler is going to use it and you could just update it with VC patches if it changed. The underlying OS API is even less likely to change anyway (UCRT being the C99 lib) so tying it to the Windows SDK is puzzling. I'll concede I'm probably missing some obvious gotcha.
- userbinator 7y agoBut this source never included the STL. You mean things like vector, map, etc. ? The source for those is already in the header files.
- Rusky 7y agoThey mean the entire C++ standard library. There's plenty of non-header code in there.
- StephanTLavavej 7y agoThe separately compiled parts of the C++ Standard Library have shipped in VS installations for many years (look for xrngdev.cpp in a subdirectory typically named crt/src, that should be distinctive enough). This was intended for debugging purposes, covered by the VS EULA as always. These parts weren’t standalone-buildable and we occasionally forgot to ship a file or two, but we always tried to make it all source-readable. Now, being open source enables much more.
- vedantroy 7y agoThat last statement was very bold. Do you think there is a direct link between open-sourcing this library and increased telemetry? What about VSCode and increased telemetry?
- UserIsUnused 7y agoI think the intent was not stating a connection but just a old vs new pros and cons.
- muststopmyths 7y agoI was looking for this a couple of months ago but I couldn't find it in the CRT source. I don't see any tags indicating compiler version releases, so it's a bit useless for debugging purposes (which is the main use I would have for it). CRT source really should also be also in an easy to find place instead of tucked away in the Windows SDK. But I've given up expecting any kind of actual developer consideration from the new Microsoft.
- Avery3R 7y agoParts of the CRT are closed source, headers are shippped as a part of MSVC. (Edited after correction)
- adzm 7y agoThe source is also shipped as part of the Windows SDK.
- lstamour 7y agoI’d suggest this is the opposite, this is Microsoft changing their ways for the better. It’s really hard to open source legacy code, this new code should be the restart of open source releases going forward, and who knows, maybe they’ll upload historical tags at some point in future. Personally I think there will be a lot tighter integration between open source git repos and Microsoft’s newer developer tools efforts, including eventually cross-platform versions.
- muststopmyths 7y ago>It’s really hard to open source legacy code Of course, but my point about the new Microsoft was in relation to UCRT source, which used to be part of the standard VC runtime library and distributed with the compiler. This new release of the c++ stdlib is fine and I'd actually be fine with the entire C/C++ runtime (including UCRT) being on github. At least there'd be just one place to look for it.
- 7y ago
- nurettin 7y agoI would like to stop here and thank one of the microsoft STL contributors Stephan T. Lavavej[1] for all the work he has done on maintaining his own MinGW repository for many many years, keeping his hand compiled gcc, SDL and boost versions up to date. 1. https://nuwen.net/stl.html https://nuwen.net/stl.html
- chewxy 7y agoSTL contributes to STL. Aptonym is apt
- StephanTLavavej 7y agoYou’re welcome! My MinGW distro is due for an update, which I should hopefully have time for soon.
- nurettin 7y agoIt is a bit embarrassing to admit that I've been a fan of your works since early 2000s. Learned sockets from libnuwen. https://github.com/nurettin/libnuwen https://github.com/nurettin/libnuwen
- StephanTLavavej 7y agoWow, I didn’t know anyone followed my personal library (when I was still learning the language)! Glad it helped. Cool to meet a true fan :-)
- deleted 7y ago[deleted]
- wycliffb 7y agoThanks for the distro. I use it for dev on my Windows machine. Can't wait for the update!
- jpfr 7y agoIs the current MSVC STL still derived from the original Dinkumware STL? It’s surprising to see it Apache licensed if that is the case. It seems Plauger is still selling it to other specialized compiler vendors. https://en.m.wikipedia.org/wiki/P._J._Plauger#Dinkumware https://en.m.wikipedia.org/wiki/P._J._Plauger#Dinkumware
- bla3 7y agoCool! Are you going to accept patches to port this to other operating systems? It would be cool if `clang -stdlib=msvc` joined -stdlib=libc++ and -stdlib=libstdc++.
- jfultz 7y agoI'm at CppCon and attended the talk today where Microsoft announced this to the CppCon attendees. The folks speaking made it clear that they do intend to accept pull requests, and that they're positive about it being used outside of the VC++ environment under the appropriate license (Apache 2 with LLVM Exception).
- lsllc 7y agoWhat's the LLVM Exception? (asking for a friend ...)
- wyldfire 7y agoFrom https://llvm.org/foundation/relicensing/LICENSE.txt https://llvm.org/foundation/relicensing/LICENSE.txt --- LLVM Exceptions to the Apache 2.0 License ---- As an exception, if, as a result of your compiling your source code, portions of this Software are embedded into an Object form of such source code, you may redistribute such embedded portions in such Object form without complying with the conditions of Sections 4(a), 4(b) and 4(d) of the License. In addition, if you combine or link compiled forms of this Software with software that is licensed under the GPLv2 ("Combined Software") and if a court of competent jurisdiction determines that the patent provision (Section 3), the indemnity provision (Section 9) or other Section of the License conflicts with the conditions of the GPLv2, you may retroactively and prospectively choose to deem waived or otherwise exclude such Section(s) of the License, but only in their entirety and only with respect to the Combined Software.
- corysama 7y agoThanks! Now, can anyone ELI5 the high-level goal of this exception? At a glance it looks like GPL2 folks are still not happy with the patent provisions of Apache 2.0 and this is added to appease them.
- harry8 7y agoThey want you to contribute but you have to assign microsoft your copyright and give them a guarantee in case anyone sues microsoft over your work. (People sue without merit literally all the time and legal fees are bankruptcy material for any individual). No, flipping, thanks. Surely microsoft can, you know, pay you for the copyright if they want own it when they decide to merge your work? Or just take it on the same license. And as far as providing legal guarantees for microsoft? Yeah that's gonna be a no from any sane individual. Perhaps a big company like google might agree to those terms but also, perhaps not. So no they don't want you to contribute, at all, or they'd do it right. This looks quite disappointing. But as noted elsewhere you can read some source, or fork and refuse to contribute back I guess... But why?
- mumblemumble 7y agoNone of this is particularly unusual in a FOSS project, and is done for good reasons. https://www.gnu.org/licenses/why-assign.html https://www.gnu.org/licenses/why-assign.html
- otterley 7y ago... and Microsoft's CLA is even less demanding; all they require is a copyright and patent license.
- otterley 7y ago> you have to assign microsoft your copyright No, you don't. You have to provide Microsoft (and anyone else, for that matter) a license to use your contribution per the CLA, but you still own your work. See section 5(a), https://opensource.microsoft.com/pdf/microsoft-contribution-license-agreement.pdf https://opensource.microsoft.com/pdf/microsoft-contribution-.... All open-source licenses effectively require this; otherwise, by default, nobody would have a right to copy or use your contribution. > give them a guarantee in case anyone sues microsoft over your work I don't see an indemnification clause in the CLA. Which language are you referring to? > (People sue without merit literally all the time and legal fees are bankruptcy material for any individual) If they had even a shred of plausible belief, the estate of Elvis Presley could sue you tomorrow for defecating on a sofa at Graceland and potentially bankrupt you, even if you've never visited. What's your point?
- voldacar 7y agoEw that's a lot of preprocessor usage.
- StephanTLavavej 7y agoWe really don’t like the preprocessor, but it is currently necessary for many things, especially supporting different architectures, compilers, and Standard version modes. We regularly purge our implementation of no-longer-necessary macros, even when it breaks (non-Standard) code, as we recently did with `_NOEXCEPT`, and we look forward to removing even more. Please file an issue if you encounter macros that don’t appear to be necessary.
- ridiculous_fish 7y agoThe implementation of std::regex appears to be NFA based [1] which is surprising because backreferences are part of the standard. How are backreferences implemented here? 1: https://github.com/microsoft/STL/blob/master/stl/inc/regex https://github.com/microsoft/STL/blob/master/stl/inc/regex
- asdfasgasdgasdg 7y agoI think you're thinking of DFAs, which don't support backreferences. NFAs do. Right?
- ridiculous_fish 7y agoMaybe? But in theory any NFA can be reduced to a DFA through powerset construction, so there must be something else going on.
- wahern 7y agoThat's only for regular languages. Backreferences aren't regular.
- ridiculous_fish 7y agoYes, hence my question about using NFAs for std::regex!
- deleted 7y ago[deleted]
- burntsushi 7y agoJeffrey Friedl's book on regexes unapologetically popularized the incorrect use of the terms "NFA" and "DFA" to characterize the different implementations of regex engines. Translating to something more sensible, "NFA" means "unbounded backtracking," where as "DFA" means "Thompson NFA simulation." In this vernacular, as far as I can tell, there is no word to describe an actual DFA. PCRE's docs continue this confusion. For example, they expose a DFA API... But it's not actually a DFA! One might say this is similar to how "regex" doesn't necessarily imply "regular," which is true. That's definitely a battle that has been lost long ago. But NFA and DFA are even more specific jargon terms, and the way in which they have been redefined by the Friedls of the world has led to exactly your confusion over and over again.
- md224 7y agoI'm not well-versed in C++, so I'm a bit confused about the difference between the C++ Standard Library and the Standard Template Library (STL). Wikipedia tells me that they're related but technically separate things, yet this GitHub page says: > This is the official repository for Microsoft's implementation of the C++ Standard Library (also known as the STL) and appears to use the two terms interchangeably. Is this the C++ Standard Library or the STL?
- pnako 7y agoIt's the standard library. People sometimes say STL to refer to the entire standard library because the names are similar and because the STL is a huge chunk of the standard library (and the non-STL parts of the standard library also tend to use templates anyway, to add to the whole confusion...) But if you look at the repo you see the C headers like cmath, etc. that have nothing to do with the STL and are just part of the standard library.
- nikbackm 7y agoNote that the C library (CRT) is not included here though, as that's now delivered with Windows itself as the Universal CRT. The cmath header here just forwards to math.h and has no real content of its own.
- pnako 7y agoAh. Maybe we'll get it when they open source the rest of the toolchain :D
- percentcer 7y agohttps://stackoverflow.com/questions/5205491/whats-the-difference-between-stl-and-c-standard-library https://stackoverflow.com/questions/5205491/whats-the-differ... this is a pretty solid answer to your question
- md224 7y agoDuh, I knew I should've googled first. That definitely clears it up, thanks!
- xvilka 7y agoThere is no reason to use MSVC when clang-cl[1] exists. Both Google and Mozilla build their browsers for Windows platform for more than a year without using MSVC. So it is a pretty solid platform and ready for production. [1] https://clang.llvm.org/docs/MSVCCompatibility.html https://clang.llvm.org/docs/MSVCCompatibility.html
- barchar 7y agoyep! Clang-cl uses this library btw (I think it's possible to get libc++ sorta working on windows, but it's not something that's officially supported).
- StephanTLavavej 7y agoAs barchar (my coworker on the STL team) mentioned, not only does Clang use MSVC’s STL on Windows, but also the support is from both Clang and Microsoft. We test MSVC’s STL with Clang as a first-class citizen, and have shipped features active for Clang before they were active for C1XX (MSVC’s compiler front-end), notably Class Template Argument Deduction. Clang is a great compiler! We think it’s extra great with our STL. We added Clang/LLVM to the VS installer to make using it easier.
- pjmlp 7y agoOther than using the multitude of Windows features and designer tooling not supported by clang-cl.
- 7y ago
- pranith 7y agoMicrosoft has come a long way lately when it comes to open source. Apple seems to be the only major company that is still not an enthusiastic participant.
- jeffnappi 7y agoPerhaps Apple's contributions aren't as visible, but just off the top of my head here's two major open source contributions from them: Swift[1] and FoundationDB[2] [1] https://github.com/apple/swift https://github.com/apple/swift [2] https://github.com/apple/foundationdb https://github.com/apple/foundationdb
- umvi 7y agoDo people really use swift on Linux?
- favorited 7y agoSome people write web services in Swift on Linux, though it's really just getting started.
- jeffnappi 7y agoApparently it is gaining traction. For example, the Tensorflow project is working on building a next generation library with Swift - https://github.com/tensorflow/swift https://github.com/tensorflow/swift You can read why here - https://github.com/tensorflow/swift/blob/master/docs/WhySwiftForTensorFlow.md https://github.com/tensorflow/swift/blob/master/docs/WhySwif...
- skissane 7y agoI wish they'd post the UCRT source on GitHub too. (Yes I know it can be found in the SDK, but having it as a repo on GitHub would just be so much more convenient.)
- self_awareness 7y agoI'm not sure you've noticed, but one of the core authors of this STL implementation -- Stephan T. Lavavej -- has exactly the initials of the project he's working on: STL. This means he's perfect for this job :)
- choppaface 7y agoAny color on why the choice of CMake for build? Versus bazel or open-sourcing Microsoft’s tool? Something like bazel remote builds is an absolute game changer for large C++ projects (especially versus CMake). (re "We're working on a CMake build system... Until that's done, we're keeping our legacy build system around in the stl/msbuild subdirectory. (We're keeping those files in this repo, even though they're unusable outside of Microsoft, because they need to be updated whenever source files are added/renamed/deleted. ")
- sebazzz 7y agoIf the Microsoft tool you are referring to is MSBuild, that one is already open source.
- pjc50 7y agoIs it? Finally an opportunity to understand how the damn thing works.
- ygra 7y agohttps://github.com/Microsoft/msbuild https://github.com/Microsoft/msbuild It's also fairly well documented: https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuil...
- kangulis 7y agoStandard library of Cpp uses templates extensively. So both terms are used interchangeably.
- TimTheTinker 7y agoThese kinds of announcements from Microsoft still boggle my mind a little. It seems only a little while ago that I heard stories of a friend’s high school programming teacher, who received threats from Microsoft’s legal department for emailing them a patch to fix a crash in Windows 95.
- yitchelle 7y agoThat it is license under Apache-2.0 WITH LLVM-exception is also refreshing and amazing.
- kanox 7y agoThe code is already 90% include headers and microsoft has supported walking through it for debug purposes for a very long time.
- de_watcher 7y agoMore than half of it is templates that you can't hide just because of the nature of templates. It's still the same Microsoft.
- pjmlp 7y agoI prefer the same old Microsoft as the FAANG.
- deleted 7y ago[deleted]
- mhd 7y agoDoes this still need #pragma warning(disable : 4786) ?
- billyoneal 7y agoWe are unaware of any such bugs requiring such a suppression; please create a self contained repro and file an issue.
- StephanTLavavej 7y agoThat’s the symbol truncation warning. IIRC, the suppression is no longer necessary because the compiler removed the warning completely.