From a1218bc201b8ce25d61f43b496db63759f401b16 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 19 Aug 2021 21:33:05 +0300 Subject: [PATCH 01/22] Resolve #483 --- stl/inc/__msvc_system_error_abi.hpp | 3 +++ stl/inc/cstdint | 3 +++ stl/inc/cstdlib | 3 +++ stl/inc/type_traits | 3 +++ stl/inc/xfacet | 9 +++++---- stl/inc/xfilesystem_abi.h | 3 +++ stl/inc/yvals_core.h | 3 +++ stl/src/filesystem.cpp | 6 ++---- stl/src/format.cpp | 6 ++---- stl/src/import_library_modules.txt | 27 +++++++++++++++++++++++++++ stl/src/locale0.cpp | 6 ++---- stl/src/sharedmutex.cpp | 6 ++---- stl/src/syserror_import_lib.cpp | 6 ++---- stl/src/vector_algorithms.cpp | 6 ++---- stl/src/xonce2.cpp | 6 ++---- 15 files changed, 64 insertions(+), 32 deletions(-) create mode 100644 stl/src/import_library_modules.txt diff --git a/stl/inc/__msvc_system_error_abi.hpp b/stl/inc/__msvc_system_error_abi.hpp index d95b458cf55..c0905d03f34 100644 --- a/stl/inc/__msvc_system_error_abi.hpp +++ b/stl/inc/__msvc_system_error_abi.hpp @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef __MSVC_SYSTEM_ERROR_ABI_HPP #define __MSVC_SYSTEM_ERROR_ABI_HPP diff --git a/stl/inc/cstdint b/stl/inc/cstdint index c61aed7d7b5..ba3da17693c 100644 --- a/stl/inc/cstdint +++ b/stl/inc/cstdint @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _CSTDINT_ #define _CSTDINT_ diff --git a/stl/inc/cstdlib b/stl/inc/cstdlib index 7afdd58d8ba..16b4a997ced 100644 --- a/stl/inc/cstdlib +++ b/stl/inc/cstdlib @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _CSTDLIB_ #define _CSTDLIB_ diff --git a/stl/inc/type_traits b/stl/inc/type_traits index b6cbeedbded..4d0be6f831d 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _TYPE_TRAITS_ #define _TYPE_TRAITS_ diff --git a/stl/inc/xfacet b/stl/inc/xfacet index 86a985637e0..f2577b4e307 100644 --- a/stl/inc/xfacet +++ b/stl/inc/xfacet @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _XFACET_ #define _XFACET_ @@ -16,10 +19,8 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt _STD_BEGIN class _CRTIMP2_PURE_IMPORT _Facet_base { // code for reference counting a facet diff --git a/stl/inc/xfilesystem_abi.h b/stl/inc/xfilesystem_abi.h index 1122b14984f..fdc3a30619b 100644 --- a/stl/inc/xfilesystem_abi.h +++ b/stl/inc/xfilesystem_abi.h @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _XFILESYSTEM_ABI_H #define _XFILESYSTEM_ABI_H diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index a5185ddd62a..a56141f886c 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _YVALS_CORE_H_ #define _YVALS_CORE_H_ diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 97a404bde00..e43a3f31010 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -4,10 +4,8 @@ // filesystem.cpp -- C++17 implementation // (see filesys.cpp for implementation) -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt #include #include diff --git a/stl/src/format.cpp b/stl/src/format.cpp index 2970d9ecb44..e5b72ce8b94 100644 --- a/stl/src/format.cpp +++ b/stl/src/format.cpp @@ -3,10 +3,8 @@ // Implements a win32 API wrapper for -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt #include <__msvc_xlocinfo_types.hpp> #include diff --git a/stl/src/import_library_modules.txt b/stl/src/import_library_modules.txt new file mode 100644 index 00000000000..fd33f8e870e --- /dev/null +++ b/stl/src/import_library_modules.txt @@ -0,0 +1,27 @@ +Copyright (c) Microsoft Corporation. +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + + +Import library is a .lib file that has it symbols to be defined as imported from a DLL. + +Usually there is one .lib file for one .dll file, with the same name, +and import library only contains references to DLL symbols, and doesn't define anything on its own. + +The STL import library is called msvcprt.lib for release, msvcprtd.lib for debug, +and it links to corresponding msvcp140.dll and msvcp140d.dll DLLs. + +However, the STL import library defines some functions and variables on its own. +This allows to: + * Extend STL implementation without altering the DLL export surface; + * Efficiently and conveniently export variables and constants. + +The caveats of this technic are: + * Sort of defeat the purpose of /MD or /MDd options by making part of implementation + embedded into the resulting binaries, rather than stay in the STL DLL; + * Due to the duplication in each binary that links to the import library, + variables in the import library cannot represent a global state; + * Due to having just two flavors of import library (debug and release), + cannot use anything that depends on _CONTAINER_DEBUG_LEVEL or _ITERATOR_DEBUG_LEVEL value. + +For these reasons, especially the last one, there should be a strict control +of what is added to the import library. In particular, basic_string must not be there. diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index acd2fc944a2..665f5942610 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -7,10 +7,8 @@ #include #include -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt // This should probably go to a compiler section just after the locks - unfortunately we have per-appdomain // and per-process variables to initialize diff --git a/stl/src/sharedmutex.cpp b/stl/src/sharedmutex.cpp index d506db98edd..86a442533ad 100644 --- a/stl/src/sharedmutex.cpp +++ b/stl/src/sharedmutex.cpp @@ -3,10 +3,8 @@ #include -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt // these declarations must be in sync with those in xthreads.h diff --git a/stl/src/syserror_import_lib.cpp b/stl/src/syserror_import_lib.cpp index 8f8046d48c0..d6a602bc1d3 100644 --- a/stl/src/syserror_import_lib.cpp +++ b/stl/src/syserror_import_lib.cpp @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt #include <__msvc_system_error_abi.hpp> diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index e0de355b2a9..8683f46b768 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt #ifdef _M_CEE_PURE #error _M_CEE_PURE should not be defined when compiling vector_algorithms.cpp. diff --git a/stl/src/xonce2.cpp b/stl/src/xonce2.cpp index 77013f2316e..e612f2a8a7b 100644 --- a/stl/src/xonce2.cpp +++ b/stl/src/xonce2.cpp @@ -5,10 +5,8 @@ #include -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see import_library_modules.txt // Provides forwarders for InitOnceBeginInitialize and InitOnceComplete for // environments that can't use aliasobj, like /clr. From 926e14861502c505aa7920f0629db85fd7d9aea5 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 19 Aug 2021 21:44:28 +0300 Subject: [PATCH 02/22] -dup --- stl/inc/xfacet | 3 --- 1 file changed, 3 deletions(-) diff --git a/stl/inc/xfacet b/stl/inc/xfacet index f2577b4e307..962852fb5e7 100644 --- a/stl/inc/xfacet +++ b/stl/inc/xfacet @@ -19,9 +19,6 @@ _STL_DISABLE_CLANG_WARNINGS #pragma push_macro("new") #undef new -// This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt - _STD_BEGIN class _CRTIMP2_PURE_IMPORT _Facet_base { // code for reference counting a facet public: From b183e7d2597095420f1ec42e335fa2b927aefdea Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 19 Aug 2021 21:46:51 +0300 Subject: [PATCH 03/22] +headers --- stl/inc/cstddef | 3 +++ stl/inc/xtr1common | 3 +++ 2 files changed, 6 insertions(+) diff --git a/stl/inc/cstddef b/stl/inc/cstddef index 2e346ffc161..ca93e4f09a8 100644 --- a/stl/inc/cstddef +++ b/stl/inc/cstddef @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _CSTDDEF_ #define _CSTDDEF_ diff --git a/stl/inc/xtr1common b/stl/inc/xtr1common index 80e7615e30c..2082b983b0c 100644 --- a/stl/inc/xtr1common +++ b/stl/inc/xtr1common @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _XTR1COMMON_ #define _XTR1COMMON_ From e977abb4a83d68186de88721d5136b9c3b41084f Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 19 Aug 2021 22:24:28 +0300 Subject: [PATCH 04/22] +headers --- stl/inc/__msvc_xlocinfo_types.hpp | 3 +++ stl/inc/cstring | 3 +++ stl/inc/yvals.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/stl/inc/__msvc_xlocinfo_types.hpp b/stl/inc/__msvc_xlocinfo_types.hpp index f13f15c5450..3bc95538102 100644 --- a/stl/inc/__msvc_xlocinfo_types.hpp +++ b/stl/inc/__msvc_xlocinfo_types.hpp @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef __MSVC_XLOCINFO_TYPES_HPP #define __MSVC_XLOCINFO_TYPES_HPP diff --git a/stl/inc/cstring b/stl/inc/cstring index a0140aa307c..a49cecf0f11 100644 --- a/stl/inc/cstring +++ b/stl/inc/cstring @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _CSTRING_ #define _CSTRING_ diff --git a/stl/inc/yvals.h b/stl/inc/yvals.h index 86237cabba7..44904b5bda4 100644 --- a/stl/inc/yvals.h +++ b/stl/inc/yvals.h @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library_modules.txt + #pragma once #ifndef _YVALS #define _YVALS From 41c4bcae7dd09ad509348d3cd1bf692365c8af64 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 20 Aug 2021 10:54:20 +0300 Subject: [PATCH 05/22] Avoid confusion with C++20 modules --- stl/inc/__msvc_system_error_abi.hpp | 2 +- stl/inc/__msvc_xlocinfo_types.hpp | 2 +- stl/inc/cstddef | 2 +- stl/inc/cstdint | 2 +- stl/inc/cstdlib | 2 +- stl/inc/cstring | 2 +- stl/inc/type_traits | 2 +- stl/inc/xfacet | 2 +- stl/inc/xfilesystem_abi.h | 2 +- stl/inc/xtr1common | 2 +- stl/inc/yvals.h | 2 +- stl/inc/yvals_core.h | 2 +- stl/src/filesystem.cpp | 2 +- stl/src/format.cpp | 2 +- stl/src/{import_library_modules.txt => import_library.txt} | 0 stl/src/locale0.cpp | 2 +- stl/src/sharedmutex.cpp | 2 +- stl/src/syserror_import_lib.cpp | 2 +- stl/src/vector_algorithms.cpp | 2 +- stl/src/xonce2.cpp | 2 +- 20 files changed, 19 insertions(+), 19 deletions(-) rename stl/src/{import_library_modules.txt => import_library.txt} (100%) diff --git a/stl/inc/__msvc_system_error_abi.hpp b/stl/inc/__msvc_system_error_abi.hpp index c0905d03f34..83ae68fe2ff 100644 --- a/stl/inc/__msvc_system_error_abi.hpp +++ b/stl/inc/__msvc_system_error_abi.hpp @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef __MSVC_SYSTEM_ERROR_ABI_HPP diff --git a/stl/inc/__msvc_xlocinfo_types.hpp b/stl/inc/__msvc_xlocinfo_types.hpp index 3bc95538102..89d3714f582 100644 --- a/stl/inc/__msvc_xlocinfo_types.hpp +++ b/stl/inc/__msvc_xlocinfo_types.hpp @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef __MSVC_XLOCINFO_TYPES_HPP diff --git a/stl/inc/cstddef b/stl/inc/cstddef index ca93e4f09a8..66d12c85a66 100644 --- a/stl/inc/cstddef +++ b/stl/inc/cstddef @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _CSTDDEF_ diff --git a/stl/inc/cstdint b/stl/inc/cstdint index ba3da17693c..839daaff793 100644 --- a/stl/inc/cstdint +++ b/stl/inc/cstdint @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _CSTDINT_ diff --git a/stl/inc/cstdlib b/stl/inc/cstdlib index 16b4a997ced..28f660e71ac 100644 --- a/stl/inc/cstdlib +++ b/stl/inc/cstdlib @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _CSTDLIB_ diff --git a/stl/inc/cstring b/stl/inc/cstring index a49cecf0f11..5034411c098 100644 --- a/stl/inc/cstring +++ b/stl/inc/cstring @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _CSTRING_ diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 4d0be6f831d..800bdf096cf 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _TYPE_TRAITS_ diff --git a/stl/inc/xfacet b/stl/inc/xfacet index 962852fb5e7..8b4d4c4c21c 100644 --- a/stl/inc/xfacet +++ b/stl/inc/xfacet @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _XFACET_ diff --git a/stl/inc/xfilesystem_abi.h b/stl/inc/xfilesystem_abi.h index fdc3a30619b..31436b59c71 100644 --- a/stl/inc/xfilesystem_abi.h +++ b/stl/inc/xfilesystem_abi.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _XFILESYSTEM_ABI_H diff --git a/stl/inc/xtr1common b/stl/inc/xtr1common index 2082b983b0c..4b7a531d5fe 100644 --- a/stl/inc/xtr1common +++ b/stl/inc/xtr1common @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _XTR1COMMON_ diff --git a/stl/inc/yvals.h b/stl/inc/yvals.h index 44904b5bda4..ed42e57d0dd 100644 --- a/stl/inc/yvals.h +++ b/stl/inc/yvals.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _YVALS diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index a56141f886c..465293803c6 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library_modules.txt +// Limitations apply to what can be included here; see ../src/import_library.txt #pragma once #ifndef _YVALS_CORE_H_ diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index e43a3f31010..0939bcee3e7 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -5,7 +5,7 @@ // (see filesys.cpp for implementation) // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt +// Limitations apply to what can be included here; see import_library.txt #include #include diff --git a/stl/src/format.cpp b/stl/src/format.cpp index e5b72ce8b94..5bc59c29284 100644 --- a/stl/src/format.cpp +++ b/stl/src/format.cpp @@ -4,7 +4,7 @@ // Implements a win32 API wrapper for // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt +// Limitations apply to what can be included here; see import_library.txt #include <__msvc_xlocinfo_types.hpp> #include diff --git a/stl/src/import_library_modules.txt b/stl/src/import_library.txt similarity index 100% rename from stl/src/import_library_modules.txt rename to stl/src/import_library.txt diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index 665f5942610..12218a1200c 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -8,7 +8,7 @@ #include // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt +// Limitations apply to what can be included here; see import_library.txt // This should probably go to a compiler section just after the locks - unfortunately we have per-appdomain // and per-process variables to initialize diff --git a/stl/src/sharedmutex.cpp b/stl/src/sharedmutex.cpp index 86a442533ad..bbee0fa2b90 100644 --- a/stl/src/sharedmutex.cpp +++ b/stl/src/sharedmutex.cpp @@ -4,7 +4,7 @@ #include // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt +// Limitations apply to what can be included here; see import_library.txt // these declarations must be in sync with those in xthreads.h diff --git a/stl/src/syserror_import_lib.cpp b/stl/src/syserror_import_lib.cpp index d6a602bc1d3..aa96052d062 100644 --- a/stl/src/syserror_import_lib.cpp +++ b/stl/src/syserror_import_lib.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt +// Limitations apply to what can be included here; see import_library.txt #include <__msvc_system_error_abi.hpp> diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index 8683f46b768..1f2d1b6d9e1 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt +// Limitations apply to what can be included here; see import_library.txt #ifdef _M_CEE_PURE #error _M_CEE_PURE should not be defined when compiling vector_algorithms.cpp. diff --git a/stl/src/xonce2.cpp b/stl/src/xonce2.cpp index e612f2a8a7b..4a025268a2a 100644 --- a/stl/src/xonce2.cpp +++ b/stl/src/xonce2.cpp @@ -6,7 +6,7 @@ #include // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library_modules.txt +// Limitations apply to what can be included here; see import_library.txt // Provides forwarders for InitOnceBeginInitialize and InitOnceComplete for // environments that can't use aliasobj, like /clr. From d9022cfae14f6a59e2b83e0b963f835feacb2bef Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 20 Aug 2021 10:58:00 +0300 Subject: [PATCH 06/22] +headers --- stl/inc/clocale | 3 +++ stl/inc/initializer_list | 3 +++ stl/inc/xstddef | 3 +++ 3 files changed, 9 insertions(+) diff --git a/stl/inc/clocale b/stl/inc/clocale index bfc5a0aacff..cc2724bc967 100644 --- a/stl/inc/clocale +++ b/stl/inc/clocale @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library.txt + #pragma once #ifndef _CLOCALE_ #define _CLOCALE_ diff --git a/stl/inc/initializer_list b/stl/inc/initializer_list index 2714f3d3785..ad3c196c598 100644 --- a/stl/inc/initializer_list +++ b/stl/inc/initializer_list @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library.txt + #pragma once #ifndef _INITIALIZER_LIST_ #define _INITIALIZER_LIST_ diff --git a/stl/inc/xstddef b/stl/inc/xstddef index fb474793241..f64a6e4895e 100644 --- a/stl/inc/xstddef +++ b/stl/inc/xstddef @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../src/import_library.txt + #pragma once #ifndef _XSTDDEF_ #define _XSTDDEF_ From 495fa3f18c363763b21538ebed06550a8a28eda6 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 20 Aug 2021 11:03:42 +0300 Subject: [PATCH 07/22] added/used --- stl/src/import_library.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/src/import_library.txt b/stl/src/import_library.txt index fd33f8e870e..b9d9d598bc2 100644 --- a/stl/src/import_library.txt +++ b/stl/src/import_library.txt @@ -24,4 +24,4 @@ The caveats of this technic are: cannot use anything that depends on _CONTAINER_DEBUG_LEVEL or _ITERATOR_DEBUG_LEVEL value. For these reasons, especially the last one, there should be a strict control -of what is added to the import library. In particular, basic_string must not be there. +of what is used by the import library. In particular, basic_string must not be there. From be20a48617a88bdbf8c2a0fb1040de6107c76aa8 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 20 Aug 2021 11:07:51 +0300 Subject: [PATCH 08/22] the --- stl/src/import_library.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/src/import_library.txt b/stl/src/import_library.txt index b9d9d598bc2..0e740b0d253 100644 --- a/stl/src/import_library.txt +++ b/stl/src/import_library.txt @@ -2,7 +2,7 @@ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -Import library is a .lib file that has it symbols to be defined as imported from a DLL. +Import library is a .lib file that defines its symbols as imported from a DLL. Usually there is one .lib file for one .dll file, with the same name, and import library only contains references to DLL symbols, and doesn't define anything on its own. @@ -12,15 +12,15 @@ and it links to corresponding msvcp140.dll and msvcp140d.dll DLLs. However, the STL import library defines some functions and variables on its own. This allows to: - * Extend STL implementation without altering the DLL export surface; + * Extend the STL implementation without altering the DLL export surface; * Efficiently and conveniently export variables and constants. The caveats of this technic are: - * Sort of defeat the purpose of /MD or /MDd options by making part of implementation + * Sort of defeat the purpose of /MD or /MDd options by making part of the STL implementation embedded into the resulting binaries, rather than stay in the STL DLL; * Due to the duplication in each binary that links to the import library, variables in the import library cannot represent a global state; - * Due to having just two flavors of import library (debug and release), + * Due to having just two flavors of the import library (debug and release), cannot use anything that depends on _CONTAINER_DEBUG_LEVEL or _ITERATOR_DEBUG_LEVEL value. For these reasons, especially the last one, there should be a strict control From 02910f2653d9e6679c53517aff54628fb4f133bc Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Fri, 20 Aug 2021 11:20:23 +0300 Subject: [PATCH 09/22] -initializer_list --- stl/inc/initializer_list | 3 --- stl/inc/regex | 1 + stl/inc/utility | 1 + stl/inc/xstddef | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/stl/inc/initializer_list b/stl/inc/initializer_list index ad3c196c598..2714f3d3785 100644 --- a/stl/inc/initializer_list +++ b/stl/inc/initializer_list @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt - #pragma once #ifndef _INITIALIZER_LIST_ #define _INITIALIZER_LIST_ diff --git a/stl/inc/regex b/stl/inc/regex index 61d7a4d8681..e4aa6a91323 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/stl/inc/utility b/stl/inc/utility index ef3bd1a174a..7d1b3f1fbc3 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -8,6 +8,7 @@ #define _UTILITY_ #include #if _STL_COMPILER_PREPROCESSOR +#include #include #include diff --git a/stl/inc/xstddef b/stl/inc/xstddef index f64a6e4895e..203ab6ed1dd 100644 --- a/stl/inc/xstddef +++ b/stl/inc/xstddef @@ -13,7 +13,6 @@ #if _STL_COMPILER_PREPROCESSOR #include #include -#include #include #pragma pack(push, _CRT_PACKING) From b94b64946f892282c939a39886f0915cca6b6878 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 22 Aug 2021 20:02:02 +0300 Subject: [PATCH 10/22] move to docs --- {stl/src => docs}/import_library.txt | 0 stl/inc/__msvc_system_error_abi.hpp | 2 +- stl/inc/__msvc_xlocinfo_types.hpp | 2 +- stl/inc/clocale | 2 +- stl/inc/cstddef | 2 +- stl/inc/cstdint | 2 +- stl/inc/cstdlib | 2 +- stl/inc/cstring | 2 +- stl/inc/type_traits | 2 +- stl/inc/xfacet | 2 +- stl/inc/xfilesystem_abi.h | 2 +- stl/inc/xstddef | 2 +- stl/inc/xtr1common | 2 +- stl/inc/yvals.h | 2 +- stl/inc/yvals_core.h | 2 +- stl/src/filesystem.cpp | 2 +- stl/src/format.cpp | 2 +- stl/src/locale0.cpp | 2 +- stl/src/sharedmutex.cpp | 2 +- stl/src/syserror_import_lib.cpp | 2 +- stl/src/vector_algorithms.cpp | 2 +- stl/src/xonce2.cpp | 2 +- 22 files changed, 21 insertions(+), 21 deletions(-) rename {stl/src => docs}/import_library.txt (100%) diff --git a/stl/src/import_library.txt b/docs/import_library.txt similarity index 100% rename from stl/src/import_library.txt rename to docs/import_library.txt diff --git a/stl/inc/__msvc_system_error_abi.hpp b/stl/inc/__msvc_system_error_abi.hpp index 83ae68fe2ff..df5f172fc4d 100644 --- a/stl/inc/__msvc_system_error_abi.hpp +++ b/stl/inc/__msvc_system_error_abi.hpp @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef __MSVC_SYSTEM_ERROR_ABI_HPP diff --git a/stl/inc/__msvc_xlocinfo_types.hpp b/stl/inc/__msvc_xlocinfo_types.hpp index 89d3714f582..05e6dbcdde9 100644 --- a/stl/inc/__msvc_xlocinfo_types.hpp +++ b/stl/inc/__msvc_xlocinfo_types.hpp @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef __MSVC_XLOCINFO_TYPES_HPP diff --git a/stl/inc/clocale b/stl/inc/clocale index cc2724bc967..ce0160219c0 100644 --- a/stl/inc/clocale +++ b/stl/inc/clocale @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _CLOCALE_ diff --git a/stl/inc/cstddef b/stl/inc/cstddef index 66d12c85a66..4675c04ae5c 100644 --- a/stl/inc/cstddef +++ b/stl/inc/cstddef @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _CSTDDEF_ diff --git a/stl/inc/cstdint b/stl/inc/cstdint index 839daaff793..efb708db1df 100644 --- a/stl/inc/cstdint +++ b/stl/inc/cstdint @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _CSTDINT_ diff --git a/stl/inc/cstdlib b/stl/inc/cstdlib index 28f660e71ac..b46cb07acd9 100644 --- a/stl/inc/cstdlib +++ b/stl/inc/cstdlib @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _CSTDLIB_ diff --git a/stl/inc/cstring b/stl/inc/cstring index 5034411c098..9e690f3962d 100644 --- a/stl/inc/cstring +++ b/stl/inc/cstring @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _CSTRING_ diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 800bdf096cf..8e5e16d8d17 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _TYPE_TRAITS_ diff --git a/stl/inc/xfacet b/stl/inc/xfacet index 8b4d4c4c21c..7ceb896bfa0 100644 --- a/stl/inc/xfacet +++ b/stl/inc/xfacet @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _XFACET_ diff --git a/stl/inc/xfilesystem_abi.h b/stl/inc/xfilesystem_abi.h index 31436b59c71..368eb6254e6 100644 --- a/stl/inc/xfilesystem_abi.h +++ b/stl/inc/xfilesystem_abi.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _XFILESYSTEM_ABI_H diff --git a/stl/inc/xstddef b/stl/inc/xstddef index 203ab6ed1dd..2fabae93949 100644 --- a/stl/inc/xstddef +++ b/stl/inc/xstddef @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _XSTDDEF_ diff --git a/stl/inc/xtr1common b/stl/inc/xtr1common index 4b7a531d5fe..e1f7db47b55 100644 --- a/stl/inc/xtr1common +++ b/stl/inc/xtr1common @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _XTR1COMMON_ diff --git a/stl/inc/yvals.h b/stl/inc/yvals.h index ed42e57d0dd..9bc15a2bc7f 100644 --- a/stl/inc/yvals.h +++ b/stl/inc/yvals.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _YVALS diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 465293803c6..c408db39b5f 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../src/import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #pragma once #ifndef _YVALS_CORE_H_ diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 0939bcee3e7..74f07c88e9a 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -5,7 +5,7 @@ // (see filesys.cpp for implementation) // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include #include diff --git a/stl/src/format.cpp b/stl/src/format.cpp index 5bc59c29284..4d815234d34 100644 --- a/stl/src/format.cpp +++ b/stl/src/format.cpp @@ -4,7 +4,7 @@ // Implements a win32 API wrapper for // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include <__msvc_xlocinfo_types.hpp> #include diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index 12218a1200c..2bdb69516d4 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -8,7 +8,7 @@ #include // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt // This should probably go to a compiler section just after the locks - unfortunately we have per-appdomain // and per-process variables to initialize diff --git a/stl/src/sharedmutex.cpp b/stl/src/sharedmutex.cpp index bbee0fa2b90..179cf15ce90 100644 --- a/stl/src/sharedmutex.cpp +++ b/stl/src/sharedmutex.cpp @@ -4,7 +4,7 @@ #include // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt // these declarations must be in sync with those in xthreads.h diff --git a/stl/src/syserror_import_lib.cpp b/stl/src/syserror_import_lib.cpp index aa96052d062..1c0baf73542 100644 --- a/stl/src/syserror_import_lib.cpp +++ b/stl/src/syserror_import_lib.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include <__msvc_system_error_abi.hpp> diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index 1f2d1b6d9e1..d252e206328 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt #ifdef _M_CEE_PURE #error _M_CEE_PURE should not be defined when compiling vector_algorithms.cpp. diff --git a/stl/src/xonce2.cpp b/stl/src/xonce2.cpp index 4a025268a2a..7137c4a5d45 100644 --- a/stl/src/xonce2.cpp +++ b/stl/src/xonce2.cpp @@ -6,7 +6,7 @@ #include // This file is compiled into import library. -// Limitations apply to what can be included here; see import_library.txt +// Limitations apply to what can be included here; see ../../docs/import_library.txt // Provides forwarders for InitOnceBeginInitialize and InitOnceComplete for // environments that can't use aliasobj, like /clr. From 4094b725d9b61b823bdf1bf9fffbe0290fdfba98 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Sun, 22 Aug 2021 20:06:10 +0300 Subject: [PATCH 11/22] consistent location --- stl/src/locale0.cpp | 6 +++--- stl/src/sharedmutex.cpp | 4 ++-- stl/src/xonce2.cpp | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index 2bdb69516d4..42b30dc2318 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -3,13 +3,13 @@ // class locale basic member functions +// This file is compiled into import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt + #include #include #include -// This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt - // This should probably go to a compiler section just after the locks - unfortunately we have per-appdomain // and per-process variables to initialize #pragma warning(disable : 4073) diff --git a/stl/src/sharedmutex.cpp b/stl/src/sharedmutex.cpp index 179cf15ce90..7180ecebbc4 100644 --- a/stl/src/sharedmutex.cpp +++ b/stl/src/sharedmutex.cpp @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include - // This file is compiled into import library. // Limitations apply to what can be included here; see ../../docs/import_library.txt +#include + // these declarations must be in sync with those in xthreads.h using _Smtx_t = void*; diff --git a/stl/src/xonce2.cpp b/stl/src/xonce2.cpp index 7137c4a5d45..55406d6f8e9 100644 --- a/stl/src/xonce2.cpp +++ b/stl/src/xonce2.cpp @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This file is compiled into import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt + #include #include -// This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt - // Provides forwarders for InitOnceBeginInitialize and InitOnceComplete for // environments that can't use aliasobj, like /clr. From fadb90a88ffd83438a2a5edca2240b83f748cc7e Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Tue, 5 Oct 2021 17:25:49 +0300 Subject: [PATCH 12/22] technique --- docs/import_library.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/import_library.txt b/docs/import_library.txt index 0e740b0d253..16ebde35afc 100644 --- a/docs/import_library.txt +++ b/docs/import_library.txt @@ -15,7 +15,7 @@ This allows to: * Extend the STL implementation without altering the DLL export surface; * Efficiently and conveniently export variables and constants. -The caveats of this technic are: +The caveats of this technique are: * Sort of defeat the purpose of /MD or /MDd options by making part of the STL implementation embedded into the resulting binaries, rather than stay in the STL DLL; * Due to the duplication in each binary that links to the import library, From d1bc05921be72ebb90fb99d67d46069c811e2b7f Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Mon, 20 Jun 2022 12:56:58 +0300 Subject: [PATCH 13/22] update stacktrace --- stl/src/stacktrace.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/stl/src/stacktrace.cpp b/stl/src/stacktrace.cpp index 84da66adc9a..076c47e257b 100644 --- a/stl/src/stacktrace.cpp +++ b/stl/src/stacktrace.cpp @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include From 2bc734c133073113e51b4040752463dd162eab78 Mon Sep 17 00:00:00 2001 From: Alex Guteniev Date: Thu, 21 Jul 2022 15:14:43 +0300 Subject: [PATCH 14/22] +charconv tables --- stl/inc/xcharconv_tables.h | 3 +++ stl/src/charconv.cpp | 6 ++---- stl/src/xcharconv_ryu_tables.cpp | 6 ++---- stl/src/xcharconv_tables_double.cpp | 6 ++---- stl/src/xcharconv_tables_float.cpp | 6 ++---- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/stl/inc/xcharconv_tables.h b/stl/inc/xcharconv_tables.h index 77a6f040e9b..9bcfcc6430b 100644 --- a/stl/inc/xcharconv_tables.h +++ b/stl/inc/xcharconv_tables.h @@ -3,6 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// This header is used to compile import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt + #pragma once #ifndef _XCHARCONV_TABLES_H #define _XCHARCONV_TABLES_H diff --git a/stl/src/charconv.cpp b/stl/src/charconv.cpp index f400a440854..a796bdb3366 100644 --- a/stl/src/charconv.cpp +++ b/stl/src/charconv.cpp @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include diff --git a/stl/src/xcharconv_ryu_tables.cpp b/stl/src/xcharconv_ryu_tables.cpp index f116ddbe111..ea68a3bd7ed 100644 --- a/stl/src/xcharconv_ryu_tables.cpp +++ b/stl/src/xcharconv_ryu_tables.cpp @@ -30,10 +30,8 @@ // DEALINGS IN THE SOFTWARE. -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include diff --git a/stl/src/xcharconv_tables_double.cpp b/stl/src/xcharconv_tables_double.cpp index 00f53c5bc8a..d92511077ca 100644 --- a/stl/src/xcharconv_tables_double.cpp +++ b/stl/src/xcharconv_tables_double.cpp @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include diff --git a/stl/src/xcharconv_tables_float.cpp b/stl/src/xcharconv_tables_float.cpp index 1992bcde52b..8f6bc37ae4e 100644 --- a/stl/src/xcharconv_tables_float.cpp +++ b/stl/src/xcharconv_tables_float.cpp @@ -1,10 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. +// This file is compiled into import library. +// Limitations apply to what can be included here; see ../../docs/import_library.txt #include From 089a32a05874a981646c86bac4e8fc23eb0052c1 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 19:18:54 -0700 Subject: [PATCH 15/22] Drop `` restructuring. --- stl/inc/regex | 1 - stl/inc/utility | 1 - stl/inc/xstddef | 1 + 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/stl/inc/regex b/stl/inc/regex index 8568e2fffd1..05cb7465d3b 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/stl/inc/utility b/stl/inc/utility index 649a5b9f726..7bd0866585c 100644 --- a/stl/inc/utility +++ b/stl/inc/utility @@ -8,7 +8,6 @@ #define _UTILITY_ #include #if _STL_COMPILER_PREPROCESSOR -#include #include #include diff --git a/stl/inc/xstddef b/stl/inc/xstddef index d0b85263600..5e67d8dc29f 100644 --- a/stl/inc/xstddef +++ b/stl/inc/xstddef @@ -13,6 +13,7 @@ #if _STL_COMPILER_PREPROCESSOR #include #include +#include #include #pragma pack(push, _CRT_PACKING) From b958628ff9b5ab61636d60e9da61ad270a235a64 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 19:25:07 -0700 Subject: [PATCH 16/22] Rename to import_library.md. --- docs/{import_library.txt => import_library.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{import_library.txt => import_library.md} (100%) diff --git a/docs/import_library.txt b/docs/import_library.md similarity index 100% rename from docs/import_library.txt rename to docs/import_library.md From 0e8ecea55ac1620b5b46beee2570653bf101b6a2 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 19:26:34 -0700 Subject: [PATCH 17/22] Cite `/docs/import_library.md` with an absolute path. --- stl/inc/__msvc_system_error_abi.hpp | 2 +- stl/inc/__msvc_xlocinfo_types.hpp | 2 +- stl/inc/clocale | 2 +- stl/inc/cstddef | 2 +- stl/inc/cstdint | 2 +- stl/inc/cstdlib | 2 +- stl/inc/cstring | 2 +- stl/inc/type_traits | 2 +- stl/inc/xcharconv_tables.h | 2 +- stl/inc/xfacet | 2 +- stl/inc/xfilesystem_abi.h | 2 +- stl/inc/xstddef | 2 +- stl/inc/xtr1common | 2 +- stl/inc/yvals.h | 2 +- stl/inc/yvals_core.h | 2 +- stl/src/charconv.cpp | 2 +- stl/src/filesystem.cpp | 2 +- stl/src/format.cpp | 2 +- stl/src/locale0.cpp | 2 +- stl/src/sharedmutex.cpp | 2 +- stl/src/stacktrace.cpp | 2 +- stl/src/syserror_import_lib.cpp | 2 +- stl/src/vector_algorithms.cpp | 2 +- stl/src/xcharconv_ryu_tables.cpp | 2 +- stl/src/xcharconv_tables_double.cpp | 2 +- stl/src/xcharconv_tables_float.cpp | 2 +- stl/src/xonce2.cpp | 2 +- 27 files changed, 27 insertions(+), 27 deletions(-) diff --git a/stl/inc/__msvc_system_error_abi.hpp b/stl/inc/__msvc_system_error_abi.hpp index df5f172fc4d..ec71f083fd8 100644 --- a/stl/inc/__msvc_system_error_abi.hpp +++ b/stl/inc/__msvc_system_error_abi.hpp @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef __MSVC_SYSTEM_ERROR_ABI_HPP diff --git a/stl/inc/__msvc_xlocinfo_types.hpp b/stl/inc/__msvc_xlocinfo_types.hpp index 05e6dbcdde9..3cf7140dcbd 100644 --- a/stl/inc/__msvc_xlocinfo_types.hpp +++ b/stl/inc/__msvc_xlocinfo_types.hpp @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef __MSVC_XLOCINFO_TYPES_HPP diff --git a/stl/inc/clocale b/stl/inc/clocale index 0bd2d6dfde9..7a29364b684 100644 --- a/stl/inc/clocale +++ b/stl/inc/clocale @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _CLOCALE_ diff --git a/stl/inc/cstddef b/stl/inc/cstddef index 26d7b0274f8..0e929872132 100644 --- a/stl/inc/cstddef +++ b/stl/inc/cstddef @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _CSTDDEF_ diff --git a/stl/inc/cstdint b/stl/inc/cstdint index c2b17eba573..6bb3160de91 100644 --- a/stl/inc/cstdint +++ b/stl/inc/cstdint @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _CSTDINT_ diff --git a/stl/inc/cstdlib b/stl/inc/cstdlib index ed69b472e76..a7f8bbff52b 100644 --- a/stl/inc/cstdlib +++ b/stl/inc/cstdlib @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _CSTDLIB_ diff --git a/stl/inc/cstring b/stl/inc/cstring index a20462b1282..a77e89c83b3 100644 --- a/stl/inc/cstring +++ b/stl/inc/cstring @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _CSTRING_ diff --git a/stl/inc/type_traits b/stl/inc/type_traits index f4fc6d759c9..d6935400663 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _TYPE_TRAITS_ diff --git a/stl/inc/xcharconv_tables.h b/stl/inc/xcharconv_tables.h index 1cd36d115d8..5416cc20ea3 100644 --- a/stl/inc/xcharconv_tables.h +++ b/stl/inc/xcharconv_tables.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _XCHARCONV_TABLES_H diff --git a/stl/inc/xfacet b/stl/inc/xfacet index 08feff1dde6..8f0bfc39ff2 100644 --- a/stl/inc/xfacet +++ b/stl/inc/xfacet @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _XFACET_ diff --git a/stl/inc/xfilesystem_abi.h b/stl/inc/xfilesystem_abi.h index 31395440ddc..fa64bae4c78 100644 --- a/stl/inc/xfilesystem_abi.h +++ b/stl/inc/xfilesystem_abi.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _XFILESYSTEM_ABI_H diff --git a/stl/inc/xstddef b/stl/inc/xstddef index 5e67d8dc29f..78dd0c2c9fc 100644 --- a/stl/inc/xstddef +++ b/stl/inc/xstddef @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _XSTDDEF_ diff --git a/stl/inc/xtr1common b/stl/inc/xtr1common index 9357ab321a4..b97f70fbc74 100644 --- a/stl/inc/xtr1common +++ b/stl/inc/xtr1common @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _XTR1COMMON_ diff --git a/stl/inc/yvals.h b/stl/inc/yvals.h index 11c95c210aa..0556a2c5ff2 100644 --- a/stl/inc/yvals.h +++ b/stl/inc/yvals.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _YVALS diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 3fc583f5b91..c770e3650e8 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This header is used to compile import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #pragma once #ifndef _YVALS_CORE_H_ diff --git a/stl/src/charconv.cpp b/stl/src/charconv.cpp index a796bdb3366..c2c75124a42 100644 --- a/stl/src/charconv.cpp +++ b/stl/src/charconv.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 348b38a2416..167806e1961 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -5,7 +5,7 @@ // (see filesys.cpp for implementation) // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include #include diff --git a/stl/src/format.cpp b/stl/src/format.cpp index 2ecf29cde2c..08f9f4d6ee2 100644 --- a/stl/src/format.cpp +++ b/stl/src/format.cpp @@ -4,7 +4,7 @@ // Implements a win32 API wrapper for // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include <__msvc_xlocinfo_types.hpp> #include diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index f703be70931..86662d22b6c 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -4,7 +4,7 @@ // class locale basic member functions // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include #include diff --git a/stl/src/sharedmutex.cpp b/stl/src/sharedmutex.cpp index 7180ecebbc4..8417fa01035 100644 --- a/stl/src/sharedmutex.cpp +++ b/stl/src/sharedmutex.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include diff --git a/stl/src/stacktrace.cpp b/stl/src/stacktrace.cpp index a556a7ababc..2f8ecd5b592 100644 --- a/stl/src/stacktrace.cpp +++ b/stl/src/stacktrace.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include #include diff --git a/stl/src/syserror_import_lib.cpp b/stl/src/syserror_import_lib.cpp index 78094070310..e5bea6b6704 100644 --- a/stl/src/syserror_import_lib.cpp +++ b/stl/src/syserror_import_lib.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include <__msvc_system_error_abi.hpp> diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index d2ae1d8cf39..b458a5e4fce 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #ifdef _M_CEE_PURE #error _M_CEE_PURE should not be defined when compiling vector_algorithms.cpp. diff --git a/stl/src/xcharconv_ryu_tables.cpp b/stl/src/xcharconv_ryu_tables.cpp index ea68a3bd7ed..a63a3db470e 100644 --- a/stl/src/xcharconv_ryu_tables.cpp +++ b/stl/src/xcharconv_ryu_tables.cpp @@ -31,7 +31,7 @@ // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include diff --git a/stl/src/xcharconv_tables_double.cpp b/stl/src/xcharconv_tables_double.cpp index d92511077ca..c6ac0caf762 100644 --- a/stl/src/xcharconv_tables_double.cpp +++ b/stl/src/xcharconv_tables_double.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include diff --git a/stl/src/xcharconv_tables_float.cpp b/stl/src/xcharconv_tables_float.cpp index 78723e9556b..c36313471f8 100644 --- a/stl/src/xcharconv_tables_float.cpp +++ b/stl/src/xcharconv_tables_float.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include diff --git a/stl/src/xonce2.cpp b/stl/src/xonce2.cpp index fd603145db1..bdc62d74524 100644 --- a/stl/src/xonce2.cpp +++ b/stl/src/xonce2.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // This file is compiled into import library. -// Limitations apply to what can be included here; see ../../docs/import_library.txt +// Limitations apply to what can be included here; see /docs/import_library.md #include From 43b72c625dd7c6e8fb32b12dc0aa5aa409ab3946 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 19:58:06 -0700 Subject: [PATCH 18/22] Formally upgrade xcharconv_tables.h to be a core header, and test it. --- stl/inc/xcharconv_tables.h | 2 +- tests/std/tests/GH_001411_core_headers/test.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/stl/inc/xcharconv_tables.h b/stl/inc/xcharconv_tables.h index 5416cc20ea3..af8689843e4 100644 --- a/stl/inc/xcharconv_tables.h +++ b/stl/inc/xcharconv_tables.h @@ -1,4 +1,4 @@ -// xcharconv_tables.h internal header +// xcharconv_tables.h internal header (core) // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception diff --git a/tests/std/tests/GH_001411_core_headers/test.cpp b/tests/std/tests/GH_001411_core_headers/test.cpp index f2004ac7b63..0d5907989c5 100644 --- a/tests/std/tests/GH_001411_core_headers/test.cpp +++ b/tests/std/tests/GH_001411_core_headers/test.cpp @@ -15,6 +15,7 @@ #include #if _HAS_CXX17 +#include #include #endif // _HAS_CXX17 From ce99d087773042142865683197b35fe39f16f640 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 19:52:44 -0700 Subject: [PATCH 19/22] Drop comments in core headers. --- stl/inc/__msvc_system_error_abi.hpp | 3 --- stl/inc/__msvc_xlocinfo_types.hpp | 3 --- stl/inc/clocale | 3 --- stl/inc/cstddef | 3 --- stl/inc/cstdint | 3 --- stl/inc/cstdlib | 3 --- stl/inc/cstring | 3 --- stl/inc/type_traits | 3 --- stl/inc/xcharconv_tables.h | 3 --- stl/inc/xfilesystem_abi.h | 3 --- stl/inc/xstddef | 3 --- stl/inc/xtr1common | 3 --- stl/inc/yvals_core.h | 3 --- 13 files changed, 39 deletions(-) diff --git a/stl/inc/__msvc_system_error_abi.hpp b/stl/inc/__msvc_system_error_abi.hpp index ec71f083fd8..d95b458cf55 100644 --- a/stl/inc/__msvc_system_error_abi.hpp +++ b/stl/inc/__msvc_system_error_abi.hpp @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef __MSVC_SYSTEM_ERROR_ABI_HPP #define __MSVC_SYSTEM_ERROR_ABI_HPP diff --git a/stl/inc/__msvc_xlocinfo_types.hpp b/stl/inc/__msvc_xlocinfo_types.hpp index 3cf7140dcbd..f13f15c5450 100644 --- a/stl/inc/__msvc_xlocinfo_types.hpp +++ b/stl/inc/__msvc_xlocinfo_types.hpp @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef __MSVC_XLOCINFO_TYPES_HPP #define __MSVC_XLOCINFO_TYPES_HPP diff --git a/stl/inc/clocale b/stl/inc/clocale index 7a29364b684..09844d7ddbb 100644 --- a/stl/inc/clocale +++ b/stl/inc/clocale @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _CLOCALE_ #define _CLOCALE_ diff --git a/stl/inc/cstddef b/stl/inc/cstddef index 0e929872132..91aa2802024 100644 --- a/stl/inc/cstddef +++ b/stl/inc/cstddef @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _CSTDDEF_ #define _CSTDDEF_ diff --git a/stl/inc/cstdint b/stl/inc/cstdint index 6bb3160de91..63ad4c4bfb7 100644 --- a/stl/inc/cstdint +++ b/stl/inc/cstdint @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _CSTDINT_ #define _CSTDINT_ diff --git a/stl/inc/cstdlib b/stl/inc/cstdlib index a7f8bbff52b..91941aa2826 100644 --- a/stl/inc/cstdlib +++ b/stl/inc/cstdlib @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _CSTDLIB_ #define _CSTDLIB_ diff --git a/stl/inc/cstring b/stl/inc/cstring index a77e89c83b3..c82b78638d4 100644 --- a/stl/inc/cstring +++ b/stl/inc/cstring @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _CSTRING_ #define _CSTRING_ diff --git a/stl/inc/type_traits b/stl/inc/type_traits index d6935400663..679c42f7a18 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _TYPE_TRAITS_ #define _TYPE_TRAITS_ diff --git a/stl/inc/xcharconv_tables.h b/stl/inc/xcharconv_tables.h index af8689843e4..1ffb2ae7624 100644 --- a/stl/inc/xcharconv_tables.h +++ b/stl/inc/xcharconv_tables.h @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _XCHARCONV_TABLES_H #define _XCHARCONV_TABLES_H diff --git a/stl/inc/xfilesystem_abi.h b/stl/inc/xfilesystem_abi.h index fa64bae4c78..97434fe4f88 100644 --- a/stl/inc/xfilesystem_abi.h +++ b/stl/inc/xfilesystem_abi.h @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _XFILESYSTEM_ABI_H #define _XFILESYSTEM_ABI_H diff --git a/stl/inc/xstddef b/stl/inc/xstddef index 78dd0c2c9fc..12ef3fb7126 100644 --- a/stl/inc/xstddef +++ b/stl/inc/xstddef @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _XSTDDEF_ #define _XSTDDEF_ diff --git a/stl/inc/xtr1common b/stl/inc/xtr1common index b97f70fbc74..f646d9625da 100644 --- a/stl/inc/xtr1common +++ b/stl/inc/xtr1common @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _XTR1COMMON_ #define _XTR1COMMON_ diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index c770e3650e8..893f73b9d08 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -3,9 +3,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #pragma once #ifndef _YVALS_CORE_H_ #define _YVALS_CORE_H_ From 8f75eee7e03fedfa4e01a2a35a67715e995106ba Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 20:11:00 -0700 Subject: [PATCH 20/22] Drop comments in implib sources. --- stl/src/charconv.cpp | 3 --- stl/src/filesystem.cpp | 3 --- stl/src/format.cpp | 3 --- stl/src/print.cpp | 5 ----- stl/src/sharedmutex.cpp | 3 --- stl/src/stacktrace.cpp | 3 --- stl/src/syserror_import_lib.cpp | 3 --- stl/src/vector_algorithms.cpp | 3 --- stl/src/xcharconv_ryu_tables.cpp | 3 --- stl/src/xcharconv_tables_double.cpp | 3 --- stl/src/xcharconv_tables_float.cpp | 3 --- stl/src/xonce2.cpp | 3 --- 12 files changed, 38 deletions(-) diff --git a/stl/src/charconv.cpp b/stl/src/charconv.cpp index c2c75124a42..cae8561b4ba 100644 --- a/stl/src/charconv.cpp +++ b/stl/src/charconv.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include // Generated by /tools/scripts/charconv_generate.cpp diff --git a/stl/src/filesystem.cpp b/stl/src/filesystem.cpp index 167806e1961..959f40be8fd 100644 --- a/stl/src/filesystem.cpp +++ b/stl/src/filesystem.cpp @@ -4,9 +4,6 @@ // filesystem.cpp -- C++17 implementation // (see filesys.cpp for implementation) -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include #include #include diff --git a/stl/src/format.cpp b/stl/src/format.cpp index 08f9f4d6ee2..67a91356a9d 100644 --- a/stl/src/format.cpp +++ b/stl/src/format.cpp @@ -3,9 +3,6 @@ // Implements a win32 API wrapper for -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include <__msvc_xlocinfo_types.hpp> #include diff --git a/stl/src/print.cpp b/stl/src/print.cpp index 02ae5d6fa41..74819b8f3b5 100644 --- a/stl/src/print.cpp +++ b/stl/src/print.cpp @@ -3,11 +3,6 @@ // print.cpp -- C++23 implementation -// This must be as small as possible, because its contents are -// injected into the msvcprt.lib and msvcprtd.lib import libraries. -// Do not include or define anything else here. -// In particular, basic_string must not be included here. - #include <__msvc_print.hpp> #include #include diff --git a/stl/src/sharedmutex.cpp b/stl/src/sharedmutex.cpp index 8417fa01035..b678cf8c724 100644 --- a/stl/src/sharedmutex.cpp +++ b/stl/src/sharedmutex.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include // these declarations must be in sync with those in xthreads.h diff --git a/stl/src/stacktrace.cpp b/stl/src/stacktrace.cpp index 2f8ecd5b592..7dfae0d0b5d 100644 --- a/stl/src/stacktrace.cpp +++ b/stl/src/stacktrace.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include #include diff --git a/stl/src/syserror_import_lib.cpp b/stl/src/syserror_import_lib.cpp index e5bea6b6704..7ffc78d7288 100644 --- a/stl/src/syserror_import_lib.cpp +++ b/stl/src/syserror_import_lib.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include <__msvc_system_error_abi.hpp> #include diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index b458a5e4fce..71313054d46 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #ifdef _M_CEE_PURE #error _M_CEE_PURE should not be defined when compiling vector_algorithms.cpp. #endif diff --git a/stl/src/xcharconv_ryu_tables.cpp b/stl/src/xcharconv_ryu_tables.cpp index a63a3db470e..e8a7dd260d5 100644 --- a/stl/src/xcharconv_ryu_tables.cpp +++ b/stl/src/xcharconv_ryu_tables.cpp @@ -30,9 +30,6 @@ // DEALINGS IN THE SOFTWARE. -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include namespace std { diff --git a/stl/src/xcharconv_tables_double.cpp b/stl/src/xcharconv_tables_double.cpp index c6ac0caf762..a9f348ab5ab 100644 --- a/stl/src/xcharconv_tables_double.cpp +++ b/stl/src/xcharconv_tables_double.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include namespace std { diff --git a/stl/src/xcharconv_tables_float.cpp b/stl/src/xcharconv_tables_float.cpp index c36313471f8..c68de40447d 100644 --- a/stl/src/xcharconv_tables_float.cpp +++ b/stl/src/xcharconv_tables_float.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include namespace std { diff --git a/stl/src/xonce2.cpp b/stl/src/xonce2.cpp index bdc62d74524..e90c6236025 100644 --- a/stl/src/xonce2.cpp +++ b/stl/src/xonce2.cpp @@ -1,9 +1,6 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md - #include #include From 5d69a93f7db7353aa16a25db8e8aedbb659b5460 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 20:30:22 -0700 Subject: [PATCH 21/22] Make the comments in locale0.cpp, xfacet, and yvals.h scarier, add details about the inclusion chain. --- stl/inc/xfacet | 5 +++-- stl/inc/yvals.h | 5 +++-- stl/src/locale0.cpp | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/stl/inc/xfacet b/stl/inc/xfacet index 8f0bfc39ff2..6a0807d4abf 100644 --- a/stl/inc/xfacet +++ b/stl/inc/xfacet @@ -3,8 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md +// This header is used to compile the import library (via locale0_implib.cpp => locale0.cpp => xfacet). +// MAJOR LIMITATIONS apply to what can be included here! +// Before editing this file, read: /docs/import_library.md #pragma once #ifndef _XFACET_ diff --git a/stl/inc/yvals.h b/stl/inc/yvals.h index 0556a2c5ff2..59107cf8135 100644 --- a/stl/inc/yvals.h +++ b/stl/inc/yvals.h @@ -3,8 +3,9 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This header is used to compile import library. -// Limitations apply to what can be included here; see /docs/import_library.md +// This header is used to compile the import library (via locale0_implib.cpp => locale0.cpp => xfacet => yvals.h). +// MAJOR LIMITATIONS apply to what can be included here! +// Before editing this file, read: /docs/import_library.md #pragma once #ifndef _YVALS diff --git a/stl/src/locale0.cpp b/stl/src/locale0.cpp index 86662d22b6c..62d0fc647fb 100644 --- a/stl/src/locale0.cpp +++ b/stl/src/locale0.cpp @@ -3,8 +3,9 @@ // class locale basic member functions -// This file is compiled into import library. -// Limitations apply to what can be included here; see /docs/import_library.md +// This file is compiled into the import library (via locale0_implib.cpp => locale0.cpp). +// MAJOR LIMITATIONS apply to what can be included here! +// Before editing this file, read: /docs/import_library.md #include #include From 1d963632a2a475e117cf728520ab2bce585c8345 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 3 Apr 2023 20:39:44 -0700 Subject: [PATCH 22/22] Revise import_library.md. Notably, avoid saying that it "exports" anything. --- docs/import_library.md | 65 +++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/docs/import_library.md b/docs/import_library.md index 16ebde35afc..124b8f3016c 100644 --- a/docs/import_library.md +++ b/docs/import_library.md @@ -1,27 +1,52 @@ -Copyright (c) Microsoft Corporation. -SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + + +# Filenames -Import library is a .lib file that defines its symbols as imported from a DLL. +Mode | Import Library | DLL (VS) | DLL (GitHub) | +--------|----------------|-----------------|---------------------| +Release | `msvcprt.lib` | `msvcp140.dll` | `msvcp140_oss.dll` | +Debug | `msvcprtd.lib` | `msvcp140d.dll` | `msvcp140d_oss.dll` | -Usually there is one .lib file for one .dll file, with the same name, -and import library only contains references to DLL symbols, and doesn't define anything on its own. +# Import Libraries -The STL import library is called msvcprt.lib for release, msvcprtd.lib for debug, -and it links to corresponding msvcp140.dll and msvcp140d.dll DLLs. +An import library is a `.lib` file that defines its symbols as imported from a DLL. -However, the STL import library defines some functions and variables on its own. -This allows to: - * Extend the STL implementation without altering the DLL export surface; - * Efficiently and conveniently export variables and constants. +Usually there is one `.lib` file for one `.dll` file, with the same name. +The names are different for MSVC because it started encoding its ABI version into the DLL's filename, +but there was no reason to change the import library's filename. + +Also, an import library usually only contains references to DLL symbols and doesn't define anything on its own. +However, this is purely a convention - nothing technically stops an import library +from containing object files that are effectively statically linked. + +## Advantages of Injecting Additional Code + +This is what the STL's import library does - it defines some functions and variables on its own. +This allows us to: + +* Extend the STL implementation without altering the DLL export surface. + + This has been critical in allowing us to implement C++17 `` and much more. +* Separately compile functions and constant data for improved throughput. + + ``'s lookup tables are a notable example. + +## Limitations The caveats of this technique are: - * Sort of defeat the purpose of /MD or /MDd options by making part of the STL implementation - embedded into the resulting binaries, rather than stay in the STL DLL; - * Due to the duplication in each binary that links to the import library, - variables in the import library cannot represent a global state; - * Due to having just two flavors of the import library (debug and release), - cannot use anything that depends on _CONTAINER_DEBUG_LEVEL or _ITERATOR_DEBUG_LEVEL value. - -For these reasons, especially the last one, there should be a strict control -of what is used by the import library. In particular, basic_string must not be there. + +* It effectively defeats the purpose of the `/MD` and `/MDd` options by embedding part of + the STL implementation into the resulting user binaries, rather than staying in the STL's DLL. +* Due to the duplication in each user binary that links to the import library, + variables in the import library **cannot represent shared global state**. + + This limitation is subtle (not readily apparent from the source code) and critical. + If shared global state is necessary, our only option while preserving bincompat is adding a satellite DLL. +* Due to having just two flavors of the import library (debug and release), + we cannot use anything that depends on `_CONTAINER_DEBUG_LEVEL` or `_ITERATOR_DEBUG_LEVEL`. + +For these reasons, especially the last one, we need to strictly control what is used by the import library. +In particular, `basic_string` must not be used there. + +## Core Headers + +Restricting the import library to including core headers only is an effective way to avoid problems. +`locale0.cpp`'s inclusion of `` is currently a special case and should be treated with extreme caution.