[llvm] 554e4df - [Support] Canonicalise ws2_32 casing, fix MinGW cross compilation

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 02:37:41 PST 2023


Author: Martin Storsjö
Date: 2023-12-14T12:37:15+02:00
New Revision: 554e4dfd37063df2b2941b07c9cf861af236c625

URL: https://github.com/llvm/llvm-project/commit/554e4dfd37063df2b2941b07c9cf861af236c625
DIFF: https://github.com/llvm/llvm-project/commit/554e4dfd37063df2b2941b07c9cf861af236c625.diff

LOG: [Support] Canonicalise ws2_32 casing, fix MinGW cross compilation

This originally used the spelling Ws2_32 when added in
a5ffabce98a4b2e9d69009fa3e60f2b154100860, but was changed to WS2_32
in 042a2e8932984e6c9f2017cbabb5bc66ad5419ce with the intent to
use the canonical spelling from WinSDK, in order to aid cross
compilation from case sensitive file systems with WinSDK.

However, the WinSDK itself is self-inconsistent with respect
to file name cases. Headers refer to each other with many different
casings, so the original, out of the box casing doesn't work
on case sensitive file systems. Import libraries like these
use a variety of casings (some use all lowercase, some use
CamelCase, some all uppercase, and the suffix is either .lib,
.Lib or .LIB).

In order to use the WinSDK on a case sensitive file system, these
case issues has to be worked around somehow. Either by lowercasing
all files (and the #includes within them, and potentially keeping
symlinks with their original casing), or by setting up a Clang
case insensitive VFS overlay. LLVM's llvm/cmake/platforms/WinMsvc.cmake
sets up such a VFS overlay. For the linker, it creates a directory
with lowercase symlinks.

Therefore, the canonical way of handling these casing issues on
case sensitive file systems is to consistently use lowercase. That
is also what MinGW toolchains use.

As an example, the same list of system_libs refers to advapi32,
even if the actual file on disk in WinSDK is AdvAPI32.Lib.

Likewise, other in-tree build systems that picked up this change
for ws2_32 made it all lowercase, in
b07aaf8d3bde911638b0370037204898c3c2deb7 and
d22dad9f768fef376546053952f0b49b23bebfde. This also matches other
existing references to ws2_32 in e.g.
lldb/source/Plugins/Process/Windows/Common/CMakeLists.txt and
lldb/source/Utility/CMakeLists.txt.

Added: 
    

Modified: 
    llvm/lib/Support/CMakeLists.txt
    llvm/test/tools/llvm-config/system-libs.windows.test

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index 5c8bf304509ce9..494b218fdadcc0 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -40,7 +40,7 @@ endif()
 if( MSVC OR MINGW )
   # libuuid required for FOLDERID_Profile usage in lib/Support/Windows/Path.inc.
   # advapi32 required for CryptAcquireContextW in lib/Support/Windows/Path.inc.
-  set(system_libs ${system_libs} psapi shell32 ole32 uuid advapi32 WS2_32)
+  set(system_libs ${system_libs} psapi shell32 ole32 uuid advapi32 ws2_32)
 elseif( CMAKE_HOST_UNIX )
   if( HAVE_LIBRT )
     set(system_libs ${system_libs} rt)

diff  --git a/llvm/test/tools/llvm-config/system-libs.windows.test b/llvm/test/tools/llvm-config/system-libs.windows.test
index d500be44e53c26..597e0a83c3e2e6 100644
--- a/llvm/test/tools/llvm-config/system-libs.windows.test
+++ b/llvm/test/tools/llvm-config/system-libs.windows.test
@@ -2,6 +2,6 @@ RUN: llvm-config --link-static --system-libs Support 2>&1 | FileCheck %s
 REQUIRES: static-libs
 REQUIRES: host={{.*-windows-msvc}}
 CHECK-NOT: -l
-CHECK: psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib WS2_32.lib
+CHECK: psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib ws2_32.lib
 CHECK-NOT: error
 CHECK-NOT: warning


        


More information about the llvm-commits mailing list