chuyu-team / vc-ltl5 Goto Github PK
View Code? Open in Web Editor NEWShared to msvcrt.dll or ucrtbase.dll and optimize the C/C++ application file size.
License: Eclipse Public License 2.0
Shared to msvcrt.dll or ucrtbase.dll and optimize the C/C++ application file size.
License: Eclipse Public License 2.0
https://ci.appveyor.com/project/myfreeer/7z-build-nsis/builds/42916311/job/rxnk9orv02fsqujr
https://github.com/myfreeer/7z-build-nsis/tree/vc-ltl-5
VC-LTL: 5.0.4
C:\projects\7z-build-nsis\VC-LTL\TargetPlatform\header\corecrt.h(67) : warning RC4011: identifier truncated to '_LTL_ucrt_module_type_from_msvcrte_", "", "2")_impl_(1,2))Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))ref)).h'
C:\projects\7z-build-nsis\VC-LTL\TargetPlatform\header\corecrt.h(67) : warning RC4011: identifier truncated to '_LTL_ucrt_module_type_from_msvcrte_", "", "2")_impl_(1,2))Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))ime.h'
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um\winnt.h(253) : error RC2188: C:\projects\7z-build-nsis\VC-LTL\TargetPlatform\header\corecrt.h(67) : warning RC4011: identifier truncated to '_LTL_ucrt_module_type_from_msvcrte_", "", "2")_impl_(1,2))Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))clude\..\include\vcruntime.h'
C:\projects\7z-build-nsis\VC-LTL\TargetPlatform\header\corecrt.h(67) : warning RC4011: identifier truncated to '_LTL_ucrt_module_type_from_msvcrte_", "", "2")_impl_(1,2))Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))ime.h'
C:\projects\7z-build-nsis\VC-LTL\TargetPlatform\header\corecrt.h(67) : warning RC4011: identifier truncated to '_LTL_ucrt_module_type_from_msvcrte_", "", "2")_impl_(1,2))Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))ime.h'
C:\projects\7z-build-nsis\VC-LTL\TargetPlatform\header\corecrt.h(67) : warning RC4011: identifier truncated to '_LTL_ucrt_module_type_from_msvcrte_", "", "2")_impl_(1,2))Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))ime.h'
C:\projects\7z-build-nsis\VC-LTL\TargetPlatform\header\corecrt.h(67) : warning RC4011: identifier truncated to '_LTL_ucrt_module_type_from_msvcrte_", "", "2")_impl_(1,2))Pre_valid_impl_ _Deref_pre1_impl_(__readaccess_impl_notref))ime.h'
C:\projects\7z-build-nsis\C\Util\7zipInstall\x64\RCa03368(48) : fatal error RC1116: RC terminating after preprocessor errors
fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x64\rc.EXE"' : return code '0x2'
Stop.
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.10
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
#######################################################################
# #
# * * * * * * * * * * * #
# * * * * * * #
# * * * * * * * * * * * #
# * * * * * * #
# * * * * * * * * * * * * #
# #
#######################################################################
VC-LTL Path : C:\projects\7z-build-nsis\VC-LTL\
VC Tools Version : 14.29.30133
WindowsTargetPlatformMinVersion : 6.0.6000.0
Platform : x64
----------------
When I build a project using vc-LTL5 with target version 5 or 6 there are still some leftover strings in the rdata-section of the binary pointing to some system dlls:
api-ms-win-core-datetime-l1-1-1
api-ms-win-core-fibers-l1-1-1
api-ms-win-core-file-l1-2-2
api-ms-win-core-localization-l1-2-1
api-ms-win-core-localization-obsolete-l1-2-0
api-ms-win-core-processthreads-l1-1-2
api-ms-win-core-string-l1-1-0
api-ms-win-core-synch-l1-2-0
api-ms-win-core-sysinfo-l1-2-1
api-ms-win-core-winrt-l1-1-0
api-ms-win-core-xstate-l2-1-0
api-ms-win-rtcore-ntuser-window-l1-1-0
api-ms-win-security-systemfunctions-l1-1-0
ext-ms-win-ntuser-dialogbox-l1-1-0
ext-ms-win-ntuser-windowstation-l1-1-0
api-ms-win-appmodel-runtime-l1-1-2
These are no direct dependencies, they are only utf16 strings in the data section occupying more than 1KB.
Using target version 10 with a dependency to ucrt, there are no such strings.
Is there a possibility to build a binary with target version 5 or 6 without these leftover strings?
开发环境: VS2017 15.9.11
VC-LTL5版本: 5.0.4beta1
编译过程:1.下载vc-ltl binary,解压缩后执行instal.cmd
2.下载qt 5.12.12 代码,修改qtbase/mkspecs/common/msvc-desktop.conf
-QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MD
-QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MD
-QMAKE_CFLAGS_DEBUG = -Zi -MDd
+QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MT
+QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MT
+QMAKE_CFLAGS_DEBUG = -Zi -MTd
3. 打开vc2017 x64命令行
** Visual Studio 2017 Developer Command Prompt v15.9.11
** Copyright (c) 2017 Microsoft Corporation
[vcvarsall.bat] Environment initialized for: 'x64'
4. 执行VC-LTL helper for nmake.cmd
#######################################################################
#######################################################################
VC-LTL Path : c:\Users\SunAC\Downloads\vc-ltl
VC Tools Version : 14.16.27023
WindowsTargetPlatformMinVersion : 6.0.6000.0
Platform : x64
5. 进入qt代码目录,配置编译
configure -confirm-license -opensource -prefix C:\QtSDK\qt-5.12.12-x64-vc2017 -release -force-debug-info -separate-debug-info -qml-debug -platform win32-msvc -mp -opengl dynamic -qt-zlib -qt-libpng -qt-libjpeg -plugin-sql-odbc -plugin-sql-mysql -plugin-sql-oci -plugin-sql-psql -no-compile-examples -nomake tests -no-icu -webengine-proprietary-codecs
报错:
link /OUT:..\bin\qmake.exe project.obj main.obj ioutils.obj proitems.obj qmakevfs.obj ........
libvcruntime.lib(frame.obj) : error LNK2019: 无法解析的外部符号 __dyn_tls_on_demand_init,该符号在函数 "public: static void * __cdecl __FrameHandler4::CxxCallCatchBlock(struct _EXCEPTION_RECORD *)" (?CxxCallCatchBlock@__FrameHandler4@@SAPEAXPEAU_EXCEPTION_RECORD@@@z) 中被引用
libvcruntime.lib(frame.obj) : error LNK2001: 无法解析的外部符号 __tls_guard
..\bin\qmake.exe : fatal error LNK1120: 2 个无法解析的外部命令
NMAKE : fatal error U1077: “"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\link.EXE"”: 返回代码“0x460”
Stop.
#define _CRT_STDIO_ISO_WIDE_SPECIFIERS
#include <stdio.h>
int __cdecl wmain(int argc, WCHAR* argv[])
{
return 0;
}
CMake Error:
VC-LTL not load, because CMAKE_SYSTEM_NAME is not defined!!!
Call Stack (most recent call first):
VC-LTL helper for cmake.cmake:87 (include)
CMakeLists.txt:19 (include)
完成基于Windows Vista的模式兼容(vcruntime x86 + x64)
完成基于Windows Vista的模式兼容(ucrtbase x86 + x64)
完成基于Windows RT arm的模式兼容(vcruntime)
完成基于Windows RT arm的模式兼容(ucrtbase)
完成基于Windows 8的模式兼容(vcruntime x86 + x64)
完成基于Windows 8的模式兼容(ucrtbase x86 + x64)
完成基于Windows XP的模式兼容(vcruntime x86 + x64)
完成基于Windows XP的模式兼容(ucrtbase x86 + x64)
当将VC-LTL编译32位的单元测试DLL启动时,会发现_CxxThrowException@8
被导入,而CRT其实是_CxxThrowException
。
跟踪发现vcruntime.msvcrt里的LibMaker 的CopyLibType长度解析错误。
需要更新LibMaker 工具解决。
Chuyu-Team/LibMaker@1a71e74
When I build a project (simple printf("Hello World")) using VC-LTL.5.0.6-Beta5 with target version 5 or 6 I get a lot of "unresolved external symbol" errors (see attached log).
Could be introduced be fixing this issue:
System-Dlls strings
VSCMD_ARG_TGT_ARCH结果没有存储到LTLPlatform
1>libvcruntime.lib(frame.obj) : error LNK2001: 无法解析的外部符号 __dyn_tls_on_demand_init
1>libvcruntime.lib(frame.obj) : error LNK2001: 无法解析的外部符号 __tls_guard
便于在PowerShell 中使用VC-LTL启动CL/Link编译链接。
和鸭子探讨解决 #7 的时候,虽然 Debug 版 NanaZip 在对应场景下不再崩溃,但 Release 版依旧在对应场景存在崩溃问题,经调查,在嵌套 try catch 的场景下 x64 版本的 VC-LTL 无法正确抓取异常。
毛利
如题
Perhaps we can find a way to run ,NET but natively compiled down version. Because if Rust can be dealt with, why not .NET, or even Golang?
VC-LTL v5.0.10-Beta2版本开始已经兼容了.NET Native AOT
!
net8.0-windows
,这样默认就是兼容Windows 7 RTM
的
<SupportedOSPlatformVersion>5.1</SupportedOSPlatformVersion>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<!--如果不支持XP这一行不需要添加SupportedOSPlatformVersion-->
<SupportedOSPlatformVersion>5.1</SupportedOSPlatformVersion>
<!--...-->
</PropertyGroup>
<!--...-->
</Project>
开发环境: VS2019 16.11.5 (cl 14.29.30133)
VC-LTL5版本: 5.0.4beta1
编译过程:1.下载vc-ltl binary,解压缩后执行instal.cmd
2.下载Qt 5.12.12,打补丁,使用/MT编译
3.打开vc2019 x64命令行
vcvarsall.bat x64 10.0.19041.0 -vcvars_ver=14.29
4.设置Gnu工具路径
set PATH=%PATH%;C:\QtSDK\GnuTools\Perl\bin;C:\QtSDK\GnuTools\Python27;C:\QtSDK\GnuTools\Ruby21\bin
5.执行VC-LTL helper for nmake.cmd
#######################################################################
#######################################################################
VC-LTL Path : C:\QtSDK\vc-ltl
VC Tools Version : 14.29.30133
WindowsTargetPlatformMinVersion : 6.0.6000.0
Platform : x64
6.配置Qt编译选项
configure -confirm-license -opensource -prefix C:\QtSDK\qt-5.12.12-x64-vc2019 -release -force-debug-info -separate-debug-info -qml-debug -platform win32-msvc -mp -opengl dynamic -qt-zlib -qt-libpng -qt-libjpeg -no-compile-examples -nomake tests -no-icu
7.jom执行编译
报错
[1681/22547] cmd /c C:\QtSDK\GnuTools\Python27\python.exe ../../3rdparty/chromium/build/toolchain/win/tool_wrapper.py delete-file ./brotli.exe.pdb && C:\QtSDK\GnuTools\Python27\python.exe ../../3rdparty/chromium/build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./brotli.exe /PDB:./brotli.exe.pdb @./brotli.exe.rsp
FAILED: brotli.exe brotli.exe.pdb
cmd /c C:\QtSDK\GnuTools\Python27\python.exe ../../3rdparty/chromium/build/toolchain/win/tool_wrapper.py delete-file ./brotli.exe.pdb && C:\QtSDK\GnuTools\Python27\python.exe ../../3rdparty/chromium/build/toolchain/win/tool_wrapper.py link-wrapper environment.x64 False link.exe /nologo /OUT:./brotli.exe /PDB:./brotli.exe.pdb @./brotli.exe.rsp
libucrt.lib(setlocal_thunks.obj) : error LNK2001: 无法解析的外部符号 __imp__amsg_exit
.\brotli.exe : fatal error LNK1120: 1 个无法解析的外部命令
奇怪
libucrt.lib会链接到cdecl调用的函数么?
附补丁:
diff -ur a/qtbase/mkspecs/common/msvc-desktop.conf b/qtbase/mkspecs/common/msvc-desktop.conf
--- a/qtbase/mkspecs/common/msvc-desktop.conf 2017-06-19 13:36:58 +0800
+++ b/qtbase/mkspecs/common/msvc-desktop.conf 2017-06-20 09:58:33 +0800
@@ -30,8 +30,8 @@
QMAKE_CFLAGS = -nologo -Zc:wchar_t
QMAKE_CFLAGS_WARN_ON = -W3
QMAKE_CFLAGS_WARN_OFF = -W0
-QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MD
-QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MD
-QMAKE_CFLAGS_DEBUG = -Zi -MDd
+QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MT
+QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MT
+QMAKE_CFLAGS_DEBUG = -Zi -MTd
QMAKE_CFLAGS_YACC =
QMAKE_CFLAGS_LTCG = -GL
diff -ur a/qtwebengine/src/3rdparty/chromium/third_party/angle/src/common/mathutil.cpp b/qtwebengine/src/3rdparty/chromium/third_party/angle/src/common/mathutil.cpp
--- a/qtwebengine/src/3rdparty/chromium/third_party/angle/src/common/mathutil.cpp 2019-03-07 17:23:57 +0800
+++ b/qtwebengine/src/3rdparty/chromium/third_party/angle/src/common/mathutil.cpp 2019-03-07 17:23:57 +0800
@@ -72,9 +72,9 @@
{
const RGB9E5Data inputData = reinterpret_cast<const RGB9E5Data>(&input);
} // namespace gl
diff -ur a/qtwebengine/src/3rdparty/chromium/build/config/BUILDCONFIG.gn b/qtwebengine/src/3rdparty/chromium/build/config/BUILDCONFIG.gn
--- a/qtwebengine/src/3rdparty/chromium/build/config/BUILDCONFIG.gn 2019-03-07 17:23:57 +0800
+++ b/qtwebengine/src/3rdparty/chromium/build/config/BUILDCONFIG.gn 2019-03-27 14:05:29 +0800
@@ -545,7 +545,7 @@
if (is_win) {
default_compiler_configs += [
}
if (use_custom_libcxx) {
diff -ur a/qtwebengine/src/3rdparty/chromium/third_party/breakpad/breakpad/src/build/common.gypi b/qtwebengine/src/3rdparty/chromium/third_party/breakpad/breakpad/src/build/common.gypi
--- a/qtwebengine/src/3rdparty/chromium/third_party/breakpad/breakpad/src/build/common.gypi 2019-03-07 17:23:57 +0800
+++ b/qtwebengine/src/3rdparty/chromium/third_party/breakpad/breakpad/src/build/common.gypi 2019-03-27 16:27:47 +0800
@@ -323,7 +323,7 @@
'_CRT_NONSTDC_NO_WARNINGS',
'_CRT_NONSTDC_NO_DEPRECATE',
# This is required for ATL to use XP-safe versions of its functions.
'_USING_V110_SDK71_',
# '_USING_V110_SDK71_',
],
'msvs_disabled_warnings': [4800],
'msvs_settings': {
diff -ur a/qtwebengine/src/3rdparty/chromium/third_party/brotli/BUILD.gn b/qtwebengine/src/3rdparty/chromium/third_party/brotli/BUILD.gn
--- a/qtwebengine/src/3rdparty/chromium/third_party/brotli/BUILD.gn 2019-03-07 17:23:57 +0800
+++ b/qtwebengine/src/3rdparty/chromium/third_party/brotli/BUILD.gn 2019-03-27 14:07:15 +0800
@@ -170,7 +170,9 @@
if (is_win && visual_studio_version == "2015") {
# Disabling "result of 32-bit shift implicitly converted to 64 bits",
# caused by code like: foo |= (1 << i); // warning 4334
cflags = [ "/wd4334" ]
cflags = [ "/wd4334", "/MT" ]
} else {
cflags = [ "/MT" ]
}
diff -ur a/qtwebengine/src/3rdparty/chromium/third_party/yasm/BUILD.gn b/qtwebengine/src/3rdparty/chromium/third_party/yasm/BUILD.gn
--- a/qtwebengine/src/3rdparty/chromium/third_party/yasm/BUILD.gn 2019-03-07 17:23:57 +0800
+++ b/qtwebengine/src/3rdparty/chromium/third_party/yasm/BUILD.gn 2019-03-27 16:20:45 +0800
@@ -49,8 +49,8 @@
if (is_win) {
# This switches to using the release CRT. On debug component builds of
# highbd_sad4d_sse2.asm on Windows this saves about 15 s.
}
}
diff -ur a/qtwebengine/src/3rdparty/ninja/configure.py b/qtwebengine/src/3rdparty/ninja/configure.py
--- a/qtwebengine/src/3rdparty/ninja/configure.py 2019-03-07 17:23:57 +0800
+++ b/qtwebengine/src/3rdparty/ninja/configure.py 2019-03-27 14:04:40 +0800
@@ -305,7 +305,7 @@
'/nologo', # Don't print startup banner.
'/Zi', # Create pdb with debug info.
'/W4', # Highest warning level.
'/WX', # Warnings as errors.
+# '/WX', # Warnings as errors.
'/wd4530', '/wd4100', '/wd4706', '/wd4244',
'/wd4512', '/wd4800', '/wd4702', '/wd4819',
# Disable warnings about constant conditional expressions.
@@ -320,6 +320,8 @@
'/wd4267',
'/DNOMINMAX', '/D_CRT_SECURE_NO_WARNINGS',
'/D_HAS_EXCEPTIONS=0',
'/MT',
'/D_DISABLE_DEPRECATE_LTL_MESSAGE',
'/DNINJA_PYTHON="%s"' % options.with_python]
/guard:ehcont
选项介绍:https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-eh-continuation-metadata?view=msvc-170
前段日子,有人为 NanaZip 贡献了 CET 和 CFG 的支持,在验证的时候发现 VC-LTL 的 UCRT 实现未适配 /guard:ehcont
编译器选项支持
毛利
早期VC-LTL需要根据CMAKE_BUILD_TYPE识别当前是Debug还是Release,multi-config中这个似乎出现了问题。
我们正在寻找一种解决方案
https://ci.appveyor.com/project/myfreeer/7z-build-nsis/build/job/mwp0gf6gnbmopsp4#L6790
https://github.com/myfreeer/7z-build-nsis/tree/vc-ltl-5
VC-LTL: v5.0.5-Beta1
Ppmd7.c
Ppmd7Dec.c
LIBCMT.lib(exe_winmain.obj) : error LNK2001: unresolved external symbol _WinMain@16
x86\7zDec.exe : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.EXE"' : return code '0x460'
Stop.
Microsoft (R) Program Maintenance Utility Version 14.29.30140.0
Copyright (C) Microsoft Corporation. All rights reserved.
7zipInstall.c
7zAlloc.c
7zArcIn.c
7zBuf.c
7zBuf2.c
7zCrc.c
7zCrcOpt.c
7zFile.c
7zDec.c
7zStream.c
Bcj2.c
CpuArch.c
DllSecur.c
LzmaDec.c
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation. All rights reserved.
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\um\winnt.h(253) : error RC2188: C:\projects\7z-build-nsis\C\Util\7zipInstall\x86\RCa06616(48) : fatal error RC1116: RC terminating after preprocessor errors
: fatal error U1077: '"C:\Program Files (x86)\Windows Kits\10\bin\10.0.22000.0\x86\rc.EXE"' : return code '0x2'
Stop.
Microsoft (R) Program Maintenance Utility Version 14.29.30140.0
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.10
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86'
#######################################################################
# #
# * * * * * * * * * * * #
# * * * * * * #
# * * * * * * * * * * * #
# * * * * * * #
# * * * * * * * * * * * * #
# #
#######################################################################
VC-LTL Path : C:\projects\7z-build-nsis\VC-LTL\
VC Tools Version : 14.29.30133
WindowsTargetPlatformMinVersion : 5.1.2600.0
Platform : Win32
_beginthread
,改用_beginthreadex
// x64编译,并且维持默认FH4开启状态
int main()
{
_beginthread([](void*)
{
try
{
throw "123";
}
catch(...)
{
}
}, 0, nullptr);
for (;;)
Sleep(10);
return 0;
}
因为_beginthread中它正确的初始化了 ptd->handle字段。它不在是 -1,或者0,导致判断出错,具体请参考源代码:
__forceinline __acrt_ptd* __cdecl __acrt_getptd_noexit(void)
{
__acrt_ptd* ptd = (__acrt_ptd*)(((unsigned char*)_errno()) - FIELD_OFFSET(__acrt_ptd, _terrno));
/*
当 _thandle = -1,这表明此线程的ptd通过msvcrt.dll begin_thread 或者 __getptd_noexit 创建。
当 _thandle = 0,这表明此线程的ptd通过msvcrt.dll的DllMain创建。
当 _thandle = 其他,这表明msvcrt.dll内部内存已经申请失败。
*/
return (ptd->_thandle == (uintptr_t)-1/*Current Thread Handle*/ || ptd->_thandle == 0) ? ptd : (__acrt_ptd*)NULL;
}
这里的判断主要其实是为了判断内存是否申请失败。因为ptd申请失败时,_errno 会返回msvcrt模块中全局变量的地址。
因此特意判断。因此我们可以通过判断返回的地址是否属于模块 msvcrt,也可以判断内存是否申请失败。伪代码如下:
// _errno 的变量地址其实在ptd上,它内部通过调用 `__getptd_noexit`,获取ptd,然后返回 `&ptd->_terrno` 。
// 注意:如果ptd 为空指针(内存申请失败),那么_errno 会返回一个全局变量的地址。
//
auto _p_errno_value = (uintptr_t )_errno();
if(_uMsvcrtModuleBaseAddress <= _p_errno_value && _p_errno_value < _uMsvcrtModuleEndAddress )
{
// _errno 内部 ptd 的内存申请失败,现在返回了全局变量的地址。
return nullptr;
}
// 成功,开始根据偏移找到 ptd
return (__acrt_ptd*)(((unsigned char*)_p_errno_value) - FIELD_OFFSET(__acrt_ptd, _terrno));
此外,同时附带单元测试,验证ptd能否顺利获取,目前能想到需要做这几种场景:
Could you please add ARM64EC support
auto loc = std::locale(".utf8");
使用vc-ltl编译,运行报错,不使用就不会报错
I tried to use my self built vc-ltl5 binaries to compile and link this simple code:
#include <stdio.h>
void main() {
printf("Hello World\n");
}
But I get a lot of link errors:
...
libucrt.lib(_file.obj) : error LNK2019: unresolved external symbol __imp__lock referenced in function _lock_file [d:\projects\test3\_projects\test\test.vcxproj]
libucrt.lib(setlocal_thunks.obj) : error LNK2001: unresolved external symbol __imp__lock [d:\projects\test3\_projects\test\test.vcxproj]
libucrt.lib(_file.obj) : error LNK2019: unresolved external symbol __imp__unlock referenced in function _unlock_file [d:\projects\test3\_projects\test\test.vcxproj]
libucrt.lib(setlocal_thunks.obj) : error LNK2001: unresolved external symbol __imp__unlock [d:\projects\test3\_projects\test\test.vcxproj]
libucrt.lib(_file.obj) : error LNK2019: unresolved external symbol __imp__iob referenced in function __acrt_iob_func [d:\projects\test3\_projects\test\test.vcxproj]
libucrt.lib(fputwc_thunks.obj) : error LNK2001: unresolved external symbol __imp__iob [d:\projects\test3\_projects\test\test.vcxproj]
libucrt.lib(sftbuf_thunks.obj) : error LNK2001: unresolved external symbol __imp__iob [d:\projects\test3\_projects\test\test.vcxproj]
...
I built vc-ltl5 like this:
The build succeeded with no errors and all binaries including "*.lib" files can be found in the "TargetPlatform" folder. But when I use these libraries to compile I get the above errors.
When I use the binaries from the Github page from the file "VC-LTL-5.0.5-Binary.7z". I can compile and link my simple test code without any issue.
What could be the problem with my self built binaries?
微软有一份wincorlib(WIndows 8.1或者更高版本提供)
为了减轻VC-LTL的分发负担,vccorlib将在链接时,直接在客户机器中生成。
VC-LTL 5.0本身只提供 动态lib部分
###################################################################################################
# #
# * * * * * * * * * * * #
# * * * * * * #
# * * * * * * * * * * * #
# * * * * * * #
# * * * * * * * * * * * * #
# #
###################################################################################################
VC-LTL Path : C:\Users\mouri\.nuget\packages\vc-ltl\5.0.4-beta1\build\native\
VC Tools Version : 14.30.30705
WindowsTargetPlatformMinVersion : 6.2.9200.0
Platform : ARM
至少包含 VC-LTL 的 msvcrt 模式的 ARM32 目标的 Debug 和 Release 配置(虽然只测试了静态链接运行库版本,但是动态链接运行库版本也建议进行检查)
毛利
10.0.10240.0
以及10.0.19041.0
,充分优化体积。Windows XP模式
且使用到 _wputenv_s
的代码将受到影响,其他模式不受到影响。临时改用_wputenv
,同时新版本5.0.7
将修复此问题。
// 在老版本VC-LTL中 不要使用_wputenv_s,下面是等效的替换。
// _wputenv_s(L"Name", L"");
_wputenv(L"Name=");
int main()
{
// 可观察到 返回值为 22,而非预期的 0。
// 崩溃它不一定发生,除非开启ASAN。
_wputenv_s(L"123", L"");
return 0;
}
_wputenv内部为字符串分配缓冲区时,没有正确的 * sizeof(wchar_t)
,导致实际分配的缓冲区长度小于预期。从而发生越界访问。
具体代码点:https://github.com/Chuyu-Team/VC-LTL5/blob/v5.0.6/ucrtbase.msvcrt/putenv.cpp#L43
修正缓冲区长度,重新确认所有 * sizeof
位点有无异常。静态代码分析???
程序编译成64位,VC-LTL选择5.2.3790.0,msvcrt.dll缺少一些函数,导致程序运行不起来。
目前测试发现的有tanhf,_ftime32,_gmtime32,_localtime32,文件在这里。
https://github.com/zhangshuangjun/raw_files/blob/master/msvcrt_w2003_sp2_x64.zip
ASAN 即 Address Sanitizer,详细介绍可参阅 https://docs.microsoft.com/en-us/cpp/sanitizers/asan
这个功能对于一些用户来说还是很有用的,该问题由友人 @FASTSHIFT 发现在使用了 VC-LTL 的 LVGL Windows 仿真器项目无法使用 ASAN 后,我进行粗略分析后做出的反馈
注:由于 Release 模式下可以正常使用 ASAN,于是猜测和 VC-LTL 的 Debug Heap 实现有关
附报错截图一份
复现参考环境
毛利
为了更舒服的升级到 Windows 11 于是我前段日子开发了 NanaZip 并上架到了商店。
当然 NanaZip 1.0 Preview 1 和 Preview 2 都有在根目录下右键时 100% 导致程序崩溃的问题
(也有用户提到了 https://github.com/M2Team/NanaZip/issues/12)
经过排查,发现是 VC-LTL FH4 处理方面的 Bug 导致的(当然 19041 模式的 VC-LTL 因为直接使用 ucrtbase 的 FH4 实现于是没有问题)
毛利
WinXP x86可以复现
__filter_x86_sse2_floating_point_exception
反馈者:星期四
1>qtvars_plugin_import.cpp
1>libvcruntimed.lib(CxxFrameHandler_WinXP.obj) : warning LNK4075: 忽略“/EDITANDCONTINUE”(由于“/SAFESEH”规范)
1>libvcruntimed.lib(chandler4.obj) : error LNK2019: 无法解析的外部符号 __filter_x86_sse2_floating_point_exception,该符号在函数 __except_handler4 中被引用
1>D:\Project\DriverSchoolV2\DriverSchoolClient\Debug\DriverSchoolClient.exe : fatal error LNK1120: 1 个无法解析的外部命令
感谢开发这套非常优秀的框架!在使用说明中编译项目是采用了MT和MTd的方式。
请问对于使用MFC框架的和不使用MFC框架的项目,能不能支持使用了MD或是MDd方式编译和发布呢?
我看到VC-LTL发布版本中虽然没有MFC的库文件,但是Redist包中包含了MFC的140版本的DLL。
这是不是意味着是可以动态引入MFC呢?
mfc140.dll or mfc140u.dll in redist can't run at Windows XP at ver 5.0.9.
It got a error :
Unable to locate the program input point GetTickCount64 on the dynamic link library KERNEL32.DLL
实际使用下来,我发现链接到msvcrt的好处在编写短小的命令行程序的时候很有效,这时候因为软件的体积本身就比较小,静态链接msvc运行库增加的体积就特别明显。
但是一旦使用到比较庞大的软件上,而且不带一堆第三方动态库,而是全部静态链接到一起,体积也只能减少200到300KB,软件自身的体量就占大头了。
所以我认为VC-LTL适用的场景应该是:
thanks
warning LTL2003: VC-LTL不兼容 Intel C++ Compiler 2022 工具集,请切换到 Visual Studio 2015/2017/2019/2022 然后继续。
环境: VS2017 x64
编译: openssl 1.0.2u
命令:
perl Configure VC-WIN64A --prefix=C:\QtSDK\openssl-1.0.2u-x64
call ms\do_win64a
nmake -f ms\ntdll.mak
报错:
libucrt.lib(wcrtomb.obj) : error LNK2001: unresolved external symbol __GSHandlerCheck_EH4
out32dll\constant_time_test.exe : fatal error LNK1120: 1 unresolved externals
备注:VS2017 x86 ,VS 2019 x64/x86 均能正常编译通过。
xmake: https://xmake.io/#/
#include <exception>
#include <string>
class c_exception : public std::exception
{
public:
c_exception(const char* err) {
m_str = err;
}
const char* what() const override {
return m_str.c_str();
}
private:
std::string m_str;
};
void throw_e() {
throw c_exception("error");
}
int main(int argc, char* argv[]) {
try {
throw_e();
}
catch (std::exception& e) {
printf("%s", e.what());
}
}
示例代码如上,编译环境:
1> VC Tools Version : 14.30.30705
1> WindowsTargetPlatformMinVersion : 5.1.2600.0
1> Platform : Win32
vcpkg 构建动态库的时候如果能用到这个项目就好了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.