Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio 2022 lld-link: warning/error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib #56285

Closed
FrancescElies opened this issue Jun 29, 2022 · 12 comments · Fixed by llvm/llvm-project-release-prs#73

Comments

@FrancescElies
Copy link

FrancescElies commented Jun 29, 2022

Related to actions/runner-images#5813

Problem

We started seeing lld-link: warning/error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib with newer windows-sdks in visual studio 2022 (this does not happen with vs2019)

Is the following a problem in windows-sdks with vs2022 or in lld-link?

example.c

int main(int argc, char **argv) {
  return 0;
}
Invoke-CmdScript (click me)

# https://stackoverflow.com/questions/41399692/running-a-build-script-after-calling-vcvarsall-bat-from-powershell
function Invoke-CmdScript {
  param(
    [String] $scriptName
  )
  $cmdLine = """$scriptName"" $args && set"
  & $Env:SystemRoot\system32\cmd.exe /c $cmdLine |
  select-string '^([^=]*)=(.*)$' | foreach-object {
    $varName = $_.Matches[0].Groups[1].Value
    $varValue = $_.Matches[0].Groups[2].Value
    set-item Env:$varName $varValue
  }
}

With a previous win-sdk version: 10.0.19041.0

Invoke-CmdScript "c:/Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 10.0.19041.0
clang -std=c99 --target=x86_64-pc-windows-msvc -fuse-ld=lld -O1 -g "-Wl,/WX,/errorlimit:5" example.c

# No link warnings or errors

With newer win-sdk version (WX made warnings errors)

Invoke-CmdScript "c:/Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 10.0.22621.0
clang -std=c99 --target=x86_64-pc-windows-msvc -fuse-ld=lld -O1 -g "-Wl,/WX,/errorlimit:5" example.c

lld-link: error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib(initialization.obj)
lld-link: error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib(argv_data.obj)
lld-link: error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib(ncommode.obj)
lld-link: error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib(matherr.obj)
lld-link: error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib(matherr.obj)
lld-link: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)```

llvm version

❯ clang -v
clang version 14.0.6
Target: x86_64-pc-windows-msvc
Thread model: posix
@llvmbot
Copy link
Collaborator

llvmbot commented Jun 29, 2022

@llvm/issue-subscribers-lld-coff

@rnk
Copy link
Collaborator

rnk commented Jun 29, 2022

This suggests that Microsoft has added additional subsection kinds:
https://github.com/microsoft/microsoft-pdb/blob/master/include/cvinfo.h#L4579
The warning exists to detect if and when this happens, so it's working as intended. Ideally, we should try to loop in someone from Microsoft to advise on what to do with the new subsection.

+various others @zmodem @ZequanWu @alanzhao1

@aganea
Copy link
Member

aganea commented Jun 29, 2022

Can @StephanTLavavej @gratianlup help here?

@FrancescElies FrancescElies changed the title lld-link Visual Studio 2022 (lld-link: warning/error): ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib) Visual Studio 2022 lld-link: warning/error: ignoring unknown debug$S subsection kind 0xFF in file libucrt.lib Jul 1, 2022
@StephanTLavavej
Copy link
Member

@aganea I'm very unfamiliar with this area (as I work on the STL), but @rnk's link helped me find the latest enumerators in the internal repo. DEBUG_S_XFGHASH_TYPE is the 0xFF and it's followed by DEBUG_S_XFGHASH_VIRTUAL with the next value 0x100. This was added by internal MSVC-PR-354509 (obviously this link is of no use to you, but it might save an MSVC back-end dev from having to look it up).

I know less about XFG than I do about quantum mechanics, so that's all the info I can provide - but I'll mail the backend devs and ask if someone can comment here. Hope this helps!

@rnk
Copy link
Collaborator

rnk commented Jul 6, 2022

Thanks! XFG appears to be for Xtended Flow Guard, so another security hardening technology similar to Control Flow Guard (CFG), which LLD does not yet implement. I think we should:

  • add these enums
  • add them to the switch
  • ignore them until there is interest in XFG

It would be nice if LLD had a warning suppression infrastructure to allow users to suppress individual warnings if this comes up again in the future, but to date the whole idea has been that it's a linker, it shouldn't have warnings, only errors, so there is no infrastructure to leverage for that purpose.

In the absence of such functionality, I'm glad we have the warning, so I'd like to keep it so we find out about future debug subsection additions.

@tru
Copy link
Collaborator

tru commented Jul 8, 2022

Posted a diff here: https://reviews.llvm.org/D129378

I know it needs a test as well - but I couldn't find where other flags that are ignored was tested, so any pointers on how to test it similar to other things that are ignored it would be great.

@tru tru closed this as completed in 576375a Aug 8, 2022
@tru tru added this to the LLVM 15.0.0 Release milestone Aug 8, 2022
@tru
Copy link
Collaborator

tru commented Aug 8, 2022

/cherry-pick 576375a

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 8, 2022

/branch llvm/llvm-project-release-prs/issue56285

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 8, 2022

/pull-request llvm/llvm-project-release-prs#73

tstellar pushed a commit that referenced this issue Aug 8, 2022
These are new debug types that ships with the latest
Windows SDK and would warn and finally fail lld-link.

The symbols seems to be related to Microsoft's XFG
which is their version of CFG. We can't handle any of
this yet, so for now we can just ignore these types
so that lld doesn't fail with a new version of Windows
SDK.

Fixes: #56285

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D129378

(cherry picked from commit 576375a)
manxorist added a commit to OpenMPT/openmpt that referenced this issue Aug 10, 2022
….visualstudio.com/t/lots-of-lld-link-warnings-about-PDB-with/1667797> is no longer needed, but now we are hitting <llvm/llvm-project#56285> which requires the exact same work-around. Progress, I guess /o\.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@17700 56274372-70c3-4bfc-bfc3-4c3a0b034d27
@kuzminrobin
Copy link

I got an impression that linker (lld-link) warnings result in non-zero error code returned by the linker console application. This breaks some of our CI builds.
If that's the case then consider returning zero in case of warnings (as opposed to errors).

@rnk
Copy link
Collaborator

rnk commented Sep 27, 2022

@kuzminrobin The user has control of whether warnings should be errors via the /WX flag, which should do what you need.

@kuzminrobin
Copy link

Looks like I was wrong. The exit code of lld-link corresponds to my expectations.
The exit code of lld-link is 0 in case of warnings (including with the flag /WX:no and without any flag).
The exit code of lld-link is 1 in case of errors (the warnings treated as errors with the /WX flag).
Sorry for troubling.


Looks like the problem with our CI build is related to the output to the stderr. If there is any output to stderr in lld-link (including warnings) then the CI build script treats that as failure. Investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

8 participants