root icon indicating copy to clipboard operation
root copied to clipboard

[MSVC] ROOT_x86 failed due to libCling.exp : error LNK2001: unresolved external symbol "char const * __cdecl __std_find_trivial<char const ,char>(char const *,char const *,char)

Open SyahmieS opened this issue 10 months ago • 2 comments

Check duplicate issues.

  • [x] Checked for duplicates

Description

Hi all,

[MSVC] ROOT_x86 failed due to failed due to libCling.exp : error LNK2001: unresolved external symbol "char const * __cdecl __std_find_trivial<char const ,char>(char const *,char const *,char). It can be reproduced on this commit 1f86c24 Could you please help look at this issue? Thanks in advance!

Reproducer

Steps to reproduce the behavior:

  1. https://github.com/root-project/root C:\gitP\root-project/root
  2. Open a VS2022 x86 cmd
  3. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=x86 -arch=x86 & set CL= /Bcapture_repro C:\a_work_temp\rwc_project_logs\ROOT\preprocessed_repro_build & set LINK= /onfailrepro:C:\a_work_temp\rwc_project_logs\ROOT\link_repro_build
  4. cd /d C:\gitP\root-project\root\build_x86
  5. msbuild /m /p:Platform=Win32 /p:Configuration=Release ALL_BUILD.vcxproj /t:Rebuild 2>&1

Error Message: After updating the hash commit, ROOT_amd64 passed but ROOT_X86 failed with the following error: libCling.exp : error LNK2001: unresolved external symbol "char const * __cdecl __std_find_trivial<char const ,char>(char const *,char const *,char)"

What is the expected behaviour? Project Pass

Operating System Windows

What versions of the operating systems? VS 2022 + Windows Server 2022 Datacenter

Architectures 86-bit

Stacktrace No response

Plug-in formats (if applicable) No response

Plug-in host applications (DAWs) (if applicable) No response

Testing on the develop branch The bug is present on the develop branch.

ROOT version

N/A

Installation method

N/A

Operating system

Windows

Additional context

No response

SyahmieS avatar Apr 25 '24 08:04 SyahmieS

@SyahmieS it is maybe related to https://github.com/root-project/root/issues/15321 and https://github.com/root-project/root/issues/9445 I'm pretty sure that building ROOT without the following environment variables will work:

& set CL= /Bcapture_repro C:\a_work_temp\rwc_project_logs\ROOT\preprocessed_repro_build & set LINK= /onfailrepro:C:\a_work_temp\rwc_project_logs\ROOT\link_repro_build

bellenot avatar Apr 25 '24 11:04 bellenot

I just tried with ROOT master and it works with the following commands:

set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat" -host_arch=x86 -arch=x86 & set CL= /Bcapture_repro C:\a_work_temp\rwc_project_logs\ROOT\preprocessed_repro_build & set LINK= /onfailrepro:C:\a_work_temp\rwc_project_logs\ROOT\link_repro_build
cmake -G "Visual Studio 17 2022" -A Win32 -Dtesting=ON -Droottest=ON -Droofit=off ..\..\..\git\master
msbuild /m /p:Platform=Win32 /p:Configuration=Release ALL_BUILD.vcxproj /t:Rebuild

bellenot avatar Apr 25 '24 13:04 bellenot

In absence of an answer and the ability to reproduce, I am closing. Please feel free to re-open if I misunderstand the status of this issue.

dpiparo avatar May 24 '24 18:05 dpiparo

Hi @dpiparo, @bellenot,

It appears this issue is closed, but wasn't yet added to a project. Please add upcoming versions that will include the fix, or 'not applicable' otherwise.

Sincerely, :robot:

github-actions[bot] avatar May 27 '24 06:05 github-actions[bot]

Hi @bellenot @dpiparo , thank you for your reply. Yes, we tried to build with VS2022 17.9.6 Release and there was indeed no such issue.

However, we are actually testing an unreleased version of VS with an open source project, which means an unreleased MSVC. But this problem still exists. And we got some information from the MSVC team as follows.

Failing (latest prod/be): ??$__std_find_trivial@$$CBDD@std@@YAPBDQBD0D@Z (char const * __cdecl std::__std_find_trivial<char const ,char>(char const * const,char const * const,char))

Passing (17.9.6): ??$__std_find_trivial@$$CBDD@@YAPBDPBD0D@Z (char const * __cdecl __std_find_trivial<char const ,char>(char const *,char const *,char))

It looks like ROOT manually adds exports in their cmake build steps: root/core/metacling/src/CMakeLists.txt at master · root-project/root · GitHub

    ??$__std_find_trivial@$$CBDD@@YAPBDPBD0D@Z
    ??$__std_find_trivial@DD@@YAPADPAD0D@Z
    ??$__std_find_trivial@HH@@YAPAHPAH0H@Z
    ??$__std_find_trivial@IH@@YAPAIPAI0H@Z

I think the first four lines need to get updated with the new undecorated names, but I'm not sure what exactly they need or why those specific implementations are being exported right now.

Actual Result: Creating library .\libCling.lib and object .\libCling.exp libCling.exp : error LNK2001: unresolved external symbol "char const * __cdecl __std_find_trivial<char const ,char>(char const *,char const *,char)" (??$__std_find_trivial@$$CBDD@@YAPBDPBD0D@Z) libCling.exp : error LNK2001: unresolved external symbol "char * __cdecl __std_find_trivial<char,char>(char *,char *,char)" (??$__std_find_trivial@DD@@YAPADPAD0D@Z) libCling.exp : error LNK2001: unresolved external symbol "int * __cdecl __std_find_trivial<int,int>(int *,int *,int)" (??$__std_find_trivial@HH@@YAPAHPAH0H@Z) libCling.exp : error LNK2001: unresolved external symbol "unsigned int * __cdecl __std_find_trivial<unsigned int,int>(unsigned int *,unsigned int *,int)" (??$__std_find_trivial@IH@@YAPAIPAI0H@Z) .\libCling.dll : fatal error LNK1120: 4 unresolved externals

spacelg avatar Jun 07 '24 06:06 spacelg

Can you tell us what exact version of Visual Studio you are using? I tried ROOT master with the v17.11.0-pre.1.1 without problem. I will not be able to fix the issue until I can reproduce it... And the correct MSVC_VERSION will be needed too

bellenot avatar Jun 07 '24 07:06 bellenot

Thank you for your quick response, @bellenot.

The version of VS we use is not important, we just need to test the compiler MSVC inside VS, the compiler version is the latest, not release or preview. it's development version. And the correct MSVC_VERSION as below.

Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34007.96 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

spacelg avatar Jun 07 '24 07:06 spacelg

@spacelg then there is nothing we can do for the time being. We'll have to wait until the compiler is available for testing. Please ping us when it is available, so we can fix the issue before the public release.

bellenot avatar Jun 07 '24 07:06 bellenot

@spacelg Let me try something... I'll keep you updated

bellenot avatar Jun 07 '24 07:06 bellenot

@bellenot , thank you very much for your reply and information, if there is any workaround info, we will try it.

spacelg avatar Jun 07 '24 07:06 spacelg

So you can try to filer out the symbols using the CMake variable CMAKE_CXX_COMPILER_VERSION. For example (core/metacling/src/CMakeLists.txt, lines 196-208):

    if(MSVC_VERSION GREATER_EQUAL 1938 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "19.41.34007.96")
      set(cling_exports ${cling_exports}
        ??$__std_find_trivial@$$CBDD@@YAPBDPBD0D@Z
        ??$__std_find_trivial@DD@@YAPADPAD0D@Z
        ??$__std_find_trivial@HH@@YAPAHPAH0H@Z
        ??$__std_find_trivial@IH@@YAPAIPAI0H@Z
        ___std_find_trivial_1@12
        ___std_find_trivial_2@12
        ___std_find_trivial_4@12
        ___std_find_trivial_8@16
      )
    endif()

bellenot avatar Jun 07 '24 08:06 bellenot

Hi @bellenot , thank you very much for the workaround you provided, after testing, it works for us.

spacelg avatar Jun 11 '24 02:06 spacelg

You're very welcome! And thanks for the feedback!

bellenot avatar Jun 11 '24 06:06 bellenot