Skip to content

Set Support system_libs if WIN32, not just MSVC or MINGW #95505

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

Conversation

z2oh
Copy link
Contributor

@z2oh z2oh commented Jun 14, 2024

The previous check was false when compiling with clang++, which prevented ntdll from being specified as a link library, causing an undefined symbol error when trying to resolve RtlGetLastNtStatus. Since we always want to link these libraries on Windows, the check can be simplified to just if( WIN32 ).

The previous check was false when compiling with clang++, which prevented ntdll from being specified as a link library, causing an undefined symbol error when trying to resolve RtlGetLastNtStatus. Since we always want these libs on Windows, the check can be simplified to just if(WIN32).
@llvmbot
Copy link
Member

llvmbot commented Jun 14, 2024

@llvm/pr-subscribers-llvm-support

Author: Jeremy Day (z2oh)

Changes

The previous check was false when compiling with clang++, which prevented ntdll from being specified as a link library, causing an undefined symbol error when trying to resolve RtlGetLastNtStatus. Since we always want to link these libraries on Windows, the check can be simplified to just if( WIN32 ).

I added the reference to RtlGetLastNtStatus in #90655.

I tried building with clang++ without this change, saw the undefined symbol error, then tried building again with if( WIN32 ) here and was able to build successfully.

Thanks @mstorsjo for suggesting this straightforward fix.


Full diff: https://github.com/llvm/llvm-project/pull/95505.diff

1 Files Affected:

  • (modified) llvm/lib/Support/CMakeLists.txt (+2-2)
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index c7f8ac325a97a..4d8ce329029d0 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -37,7 +37,7 @@ if(LLVM_ENABLE_ZSTD)
   list(APPEND imported_libs ${zstd_target})
 endif()
 
-if( MSVC OR MINGW )
+if( WIN32 )
   # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
   # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
   # ntdll required for RtlGetLastNtStatus in lib/Support/ErrorHandling.cpp.
@@ -72,7 +72,7 @@ elseif( CMAKE_HOST_UNIX )
     add_compile_definitions(_BSD_SOURCE)
     set(system_libs ${system_libs} bsd network)
   endif()
-endif( MSVC OR MINGW )
+endif( WIN32 )
 
 # Delay load shell32.dll if possible to speed up process startup.
 set (delayload_flags)

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Note that the PR description (the first post) is what ends up as the actual commit message, when merged with "squash and merge" (although it's possible to edit it when merging). So it can be worthwhile to polish it up and split out parts that aren't intended as the final commit message (e.g. the references to me) ;-)

@z2oh
Copy link
Contributor Author

z2oh commented Jun 14, 2024

Ah I didn't know that! I assumed it took the commit's message. I've removed the extra comments from the first post, and pasted them below for posterity:

I added the reference to RtlGetLastNtStatus in #90655.

I tried building with clang++ without this change, saw the undefined symbol error, then tried building again with if( WIN32 ) here and was able to build successfully.

Thanks @mstorsjo for suggesting this straightforward fix.

@mstorsjo mstorsjo merged commit cc7a18c into llvm:main Jun 14, 2024
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants