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

Link MSVC runtime dynamically #9278

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./bdwgc
run: |
cmake . -DBUILD_SHARED_LIBS=OFF -Denable_large_config=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake . -DBUILD_SHARED_LIBS=OFF -Denable_large_config=ON
cmake --build . --config Release
- name: Download libpcre
if: steps.cache-libs.outputs.cache-hit != 'true'
Expand All @@ -73,7 +73,7 @@ jobs:
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./pcre
run: |
cmake . -DBUILD_SHARED_LIBS=OFF -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_SUPPORT_JIT=ON -DPCRE_STATIC_RUNTIME=ON
cmake . -DBUILD_SHARED_LIBS=OFF -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_SUPPORT_JIT=ON
cmake --build . --config Release
- name: Download zlib
if: steps.cache-libs.outputs.cache-hit != 'true'
Expand All @@ -85,7 +85,7 @@ jobs:
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./zlib
run: |
cmake . -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake .
cmake --build . --config Release
- name: Download libyaml
if: steps.cache-libs.outputs.cache-hit != 'true'
Expand All @@ -97,7 +97,7 @@ jobs:
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./libyaml
run: |
cmake . -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake .
cmake --build . --config Release
- name: Download libxml2
if: steps.cache-libs.outputs.cache-hit != 'true'
Expand All @@ -110,7 +110,7 @@ jobs:
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./libxml2
run: |
cmake . -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_HTTP=OFF -DLIBXML2_WITH_FTP=OFF -DLIBXML2_WITH_TESTS=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake . -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_HTTP=OFF -DLIBXML2_WITH_FTP=OFF -DLIBXML2_WITH_TESTS=OFF
cmake --build . --config Release
- name: Gather libraries
if: steps.cache-libs.outputs.cache-hit != 'true'
Expand All @@ -127,7 +127,7 @@ jobs:
uses: actions/cache@v1
with:
path: llvm
key: llvm-libs-10.0.0
key: llvm-libs-10.0.0-v2
- name: Download LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
Expand All @@ -139,7 +139,7 @@ jobs:
if: steps.cache-llvm.outputs.cache-hit != 'true'
working-directory: ./llvm-src
run: |
cmake . -Thost=x64 -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_USE_CRT_RELEASE=MT -DBUILD_SHARED_LIBS=OFF
cmake . -Thost=x64 -DLLVM_TARGETS_TO_BUILD="X86" -DBUILD_SHARED_LIBS=OFF
cmake --build . --config Release
- name: Gather LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
Expand All @@ -161,10 +161,10 @@ jobs:
name: objs
- name: Build LLVM extensions
run: |
cl /MT /c src\llvm\ext\llvm_ext.cc -I llvm\include /Fosrc\llvm\ext\llvm_ext.obj
cl /MD /c src\llvm\ext\llvm_ext.cc -I llvm\include /Fosrc\llvm\ext\llvm_ext.obj
- name: Link Crystal executable
run: |
Invoke-Expression "cl objs\crystal.obj /Fecrystal-cross src\llvm\ext\llvm_ext.obj $(llvm\bin\llvm-config.exe --libs) libs\pcre.lib libs\gc.lib advapi32.lib libcmt.lib legacy_stdio_definitions.lib /F10000000"
Invoke-Expression "cl objs\crystal.obj /Fecrystal-cross src\llvm\ext\llvm_ext.obj $(llvm\bin\llvm-config.exe --libs) libs\pcre.lib libs\gc.lib advapi32.lib msvcrt.lib legacy_stdio_definitions.lib /F10000000"

- name: Re-build Crystal
run: |
Expand Down
2 changes: 1 addition & 1 deletion src/lib_c.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% if flag?(:win32) %}
@[Link("libcmt")]
@[Link("msvcrt")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there should be a -Dwin_MT to link libcmt for those that want to use /MT builds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably. But not sure I like that exact name and approach to choosing this option.

But it is true that this is different from --static.
(Wait, does that one even apply to Windows? It's *.lib either way? And I think we've been linking statically without --static)

{% end %}
lib LibC
alias Char = UInt8
Expand Down