microsoft / microsoft/STL

<format>: Investigate objsize test

Open
#1,827 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

format throughput
Dominant language
C++
Stars
11.2k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

The MSVC compiler has an internal test (src\qa\VC\FE\compiler\tests\cxx\comp\regress\objsize\objsize.cpp) that includes STL headers without doing anything else, and verifies that the resulting object file is minimally small. <charconv> fails this test (because of its digit table), and <format> (which will be included by <chrono>, and includes <charconv>) causes more failures (due to strings used for exceptions, and possibly more). Here is the test:

C:\Temp>type objsize.cpp
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#define _SILENCE_CXX17_STRSTREAM_DEPRECATION_WARNING
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS

#include <algorithm>
#include <any>
#include <array>
#include <atomic>
#include <barrier>
#include <bit>
#include <bitset>
// #include <charconv>
#include <chrono>
#include <codecvt>
#include <compare>
#include <complex>
#include <concepts>
#include <condition_variable>
#include <coroutine>
#include <deque>
#include <exception>
#include <execution>
#include <filesystem>
#include <format>
#include <forward_list>
#include <fstream>
#include <functional>
#include <future>
#include <hash_map>
#include <hash_set>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <latch>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <memory_resource>
#include <mutex>
#include <new>
#include <numbers>
#include <numeric>
#include <optional>
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <semaphore>
#include <set>
#include <shared_mutex>
#include <source_location>
#include <span>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <stop_token>
#include <streambuf>
#include <string>
#include <string_view>
#include <strstream>
#include <syncstream>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <variant>
#include <vector>
#include <version>

#include <cassert>
#include <ccomplex>
#include <cctype>
#include <cerrno>
// #include <cfenv>
#include <cfloat>
#include <cinttypes>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdalign>
#include <cstdarg>
#include <cstdbool>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctgmath>
#include <ctime>
#include <cuchar>
#include <cwchar>
#include <cwctype>

#include <experimental/deque>
#include <experimental/filesystem>
#include <experimental/forward_list>
#include <experimental/list>
#include <experimental/map>
#include <experimental/set>
#include <experimental/string>
#include <experimental/unordered_map>
#include <experimental/unordered_set>
#include <experimental/vector>

#include <assert.h>
#include <complex.h>
#include <conio.h>
#include <crtdbg.h>
#include <ctype.h>
#include <direct.h>
#include <dos.h>
#include <errno.h>
#include <excpt.h>
#include <fcntl.h>
// #include <fenv.h>
#include <float.h>
#include <fpieee.h>
#include <intrin.h>
#include <inttypes.h>
#include <io.h>
#include <iso646.h>
#include <limits.h>
#include <locale.h>
#include <malloc.h>
#include <math.h>
#include <mbctype.h>
#include <mbstring.h>
#include <memory.h>
#include <minmax.h>
#include <new.h>
#include <process.h>
#include <safeint.h>
#include <sal.h>
#include <search.h>
#include <setjmp.h>
#include <share.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/locking.h>
#include <sys/stat.h>
#include <sys/timeb.h>
#include <sys/types.h>
#include <sys/utime.h>
#include <tchar.h>
#include <time.h>
#include <uchar.h>
#include <wchar.h>
#include <wctype.h>
C:\Temp>cl /EHsc /nologo /std:c++latest /c objsize.cpp
objsize.cpp

C:\Temp>(dumpbin /headers objsize.obj|findstr /C:" name"|findstr /V /C:".drectve"|findstr /V /C:".debug"|findstr /V /C:"chks64") && echo TEST FAILED || echo TEST PASSED
  .rdata name
   .data name
.text$mn name
   .data name
  .rdata name
.text$mn name
.text$di name
.text$di name
    .bss name
    .bss name
.CRT$XCU name
.CRT$XCU name
TEST FAILED

Note that if it's built in C++17 mode, it passes (the C++20-only headers emit informational messages as expected):

C:\Temp>cl /EHsc /nologo /std:c++17 /c objsize.cpp
objsize.cpp
The contents of <barrier> are available only with C++20 or later.
The contents of <bit> are available only with C++20 or later.
The contents of <compare> are available only with C++20 or later.
The contents of <concepts> are available only with C++20 concepts support.
The contents of <coroutine> are available only with C++20 or later or /await:strict.
The contents of <format> are available only with C++20 concepts support.
The contents of <latch> are available only with C++20 or later.
The contents of <numbers> are available only with C++20 or later.
The contents of <ranges> are available only with C++20 concepts support.
The contents of <semaphore> are available only with C++20 or later.
The contents of <source_location> are available only with C++20 consteval support.
The contents of <span> are available only with C++20 or later.
The contents of <stop_token> are available only with C++20 or later.
The contents of <syncstream> are available only with C++20 or later.

C:\Temp>(dumpbin /headers objsize.obj|findstr /C:" name"|findstr /V /C:".drectve"|findstr /V /C:".debug"|findstr /V /C:"chks64") && echo TEST FAILED || echo TEST PASSED
TEST PASSED
  • We should see if we can get <charconv> and <format> to pass this test.
  • Investigate whether /Zc:inline affects this.
  • We should consider adding an improved version of this test (using <__msvc_all_public_headers.hpp>) to the STL.
  • We should re-enable /std:c++latest coverage in this test - to unblock the <format> checkin, I'm going to change the compiler's test to cover /std:c++17 only.
  • We should consider having coverage for /std:c++14, /std:c++17, /std:c++20, and /std:c++latest modes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the objsize test at src\qa\VC\FE\compiler\tests\cxx\comp\regress\objsize\objsize.cpp with /std:c++latest, then compare the C++17 result and investigate /Zc:inline. Review whether an improved test using <__msvc_all_public_headers.hpp> should cover the listed standard modes; done means the and coverage and the intended test matrix are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.