Skip to content

Commit

Permalink
-mcrtdll not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Nov 7, 2024
1 parent 41cafad commit 0198498
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mingw-w64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
shell: msys2 {0}
run: |
mkdir bin
cc crystal.obj -o bin/crystal.exe -mcrtdll=ucrt -municode \
cc crystal.obj -o bin/crystal.exe -municode \
$(pkg-config bdw-gc libpcre2-8 iconv zlib libffi --libs) \
$(llvm-config --libs --system-libs --ldflags) \
-lDbgHelp -lole32 -lWS2_32 -Wl,--stack,0x800000
Expand Down
6 changes: 6 additions & 0 deletions src/compiler/crystal/loader/mingw.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ require "crystal/system/win32/library_archive"
# The core implementation is derived from the MSVC loader. Main deviations are:
#
# - `.parse` follows GNU `ld`'s style, rather than MSVC `link`'s;
# - `.parse` automatically inserts a C runtime library if `-mcrtdll` isn't
# supplied;
# - `#library_filename` follows the usual naming of the MinGW linker: `.dll.a`
# for DLL import libraries, `.a` for other libraries;
# - `.default_search_paths` relies solely on `.cc_each_library_path`.
Expand All @@ -27,6 +29,10 @@ class Crystal::Loader
libnames = [] of String
file_paths = [] of String
extra_search_paths = [] of String

# note that `msvcrt` is a default runtime chosen at MinGW-w64 build time,
# `ucrt` is always UCRT (even in a MINGW64 environment), and
# `msvcrt-os` is always MSVCRT (even in a UCRT64 environment)
crt_dll = "msvcrt"

OptionParser.parse(args.dup) do |parser|
Expand Down
2 changes: 0 additions & 2 deletions src/lib_c.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% if flag?(:msvc) %}
@[Link({{ flag?(:static) ? "libucrt" : "ucrt" }})]
{% elsif flag?(:win32) && flag?(:gnu) %}
@[Link(ldflags: "-mcrtdll=ucrt")]
{% end %}
lib LibC
alias Char = UInt8
Expand Down

0 comments on commit 0198498

Please sign in to comment.