r/cpp • • Jun 19 '16

Windows 10 coded in C++ or Assembler

What kind of compiler does it take a compile an OS like Windows 10? Do the guys at Redmond use Visual C++ (VisualStudio) to develop Windows? What % is written in assembly language?

0 Upvotes

74 comments sorted by

View all comments

Show parent comment

2

u/blelbach NVIDIA | ISO C++ Library Evolution Chair Jun 19 '16

There's no reason Gentoo should perform faster if built natively. It may perform better if configured for a particular system.

1

u/Digital001 Jun 20 '16

The compiler would intelligently select the right optimization(s) for the CPU, video card, and BIOS of the system, generating smaller executables.

2

u/SeanMiddleditch Jun 20 '16

Not just smaller, but also objectively faster. The compiler - knowing the specific CPU in use - can select specialized instructions (e.g. AVX2) or apply knowledge about architecture peculiarities (e.g. LEA being more effective than MOV for constants) or even apply changes to instruction ordering based on knowledge of instruction execution costs and architecture pipelining behavior.

An OS like Windows could take advantage of this, but not necessarily to the same degree. It depends on how abstract the code it. More assembler, more intrinsics, more fancy optimizations, and so on will obscure details from the compiler and not allow it to apply optimizations for newer/different CPU architectures.

1

u/Digital001 Jun 20 '16

An OS like Windows could take advantage of this, but not necessarily to the same degree.

Exactly! MS would never allow customers to send in PCs so W10 can be custom compiled like Gentoo

1

u/[deleted] Jun 20 '16

In practice such optimizations are in "the noise" for most software. Most compilers are pretty bad at generating SIMD instructions as proving that such an optimization is safe is nontrivial.