Skip to content

Commit

Permalink
Link MSVC runtime dynamically
Browse files Browse the repository at this point in the history
This is the way recommended for most uses and also a better default because the alternative breaks defaults when building any other library to link with (as evidenced by the simplification of the CI config).

But this will mean the built executables will have this DLL dependency.
  • Loading branch information
oprypin committed May 11, 2020
1 parent 35c1f41 commit 46a16ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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 @@ -72,7 +72,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 @@ -84,7 +84,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 @@ -96,7 +96,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: Gather libraries
if: steps.cache-libs.outputs.cache-hit != 'true'
Expand All @@ -112,7 +112,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 @@ -124,7 +124,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 @@ -146,10 +146,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.o
cl /MD /c src\llvm\ext\llvm_ext.cc -I llvm\include /Fosrc\llvm\ext\llvm_ext.o
- name: Link Crystal executable
run: |
Invoke-Expression "cl objs\crystal.o /Fecrystal-cross src\llvm\ext\llvm_ext.o $(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.o /Fecrystal-cross src\llvm\ext\llvm_ext.o $(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")]
{% end %}
lib LibC
alias Char = UInt8
Expand Down

0 comments on commit 46a16ae

Please sign in to comment.