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

Corrects Windows lib lookup in case-sensitive OSes #15362

Merged

Conversation

luislavena
Copy link
Contributor

@luislavena luislavena commented Jan 21, 2025

Downcase name of Windows import libraries to avoid duplicates references (Eg. kernel32 and Kernel32) but to correctly find the libraries on case-sensitive filesystems, like when cross-compiling from Linux.

While on Windows Kernel32 and kernel32 result in the correct library found for linking, it does not work the same way when cross-compiling.

This also applies to Winsock2 (ws2_32) usage.

The change normalizes on the usage of downcased names for these libraries (which will have no impact when compiling natively on Windows).

Prior to this change:

$ crystal build --cross-compile --target x86_64-windows-gnu 1.cr
cc 1.obj -o 1  -Wl,--stack,0x800000 -L/usr/local/bin/../lib/crystal -lgc -lpthread \
  -ldl -municode -lntdll -liconv -ladvapi32 -lshell32 \
  -lole32 -lWS2_32 -lkernel32 -lKernel32

After:

$ crystal build --cross-compile --target x86_64-windows-gnu 1.cr
cc 1.obj -o 1  -Wl,--stack,0x800000 -L/usr/local/bin/../lib/crystal -lgc -lpthread \
  -ldl -municode -lntdll -liconv -ladvapi32 -lshell32 \
  -lole32 -lws2_32 -lkernel32

Downcase name of Windows import libraries to avoid duplicates references
(Eg. kernel32 and Kernel32) but to correctly find the libraries on
case-sensitive filesystems, like when cross-compiling from Linux.

While on Windows `Kernel32` and `kernel32` result in the correct library
found for linking, it does not work the same way when cross-compiling.

This also applies to Winsock2 (ws2_32) usage.

The change normalizes on the usage of downcased names for these
libraries (which will have no impact when compiling natively on
Windows).
@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:windows-gnu Windows support based on the MinGW-w64 toolchain + MSYS2 labels Jan 21, 2025
@ysbaddaden ysbaddaden added this to the 1.16.0 milestone Jan 21, 2025
@straight-shoota straight-shoota merged commit 35ecb7d into crystal-lang:master Jan 23, 2025
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:windows-gnu Windows support based on the MinGW-w64 toolchain + MSYS2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants