Skip to content

Commit

Permalink
Fix Windows libc detection for MSYS2-ucrt build (#903)
Browse files Browse the repository at this point in the history
Take the same approach for detection as used in fiddle:
  https://github.com/ruby/ruby/blob/79717f81f8ba24960cca6c934d00c72db64139ed/test/fiddle/helper.rb#L55-L56

And use "_time" function on all Windows UCRT platforms.
  • Loading branch information
larskanis committed Jun 15, 2021
1 parent 036a1a3 commit 4924308
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bench/bench_time.rb
Expand Up @@ -4,7 +4,7 @@ module BenchTime
module Posix
extend FFI::Library
ffi_lib FFI::Library::LIBC
if RUBY_PLATFORM =~ /mswin/
if FFI::Library::LIBC =~ /ucrtbase/
attach_function :time, :_time64, [ :buffer_out ], :uint64, ignore_error: true
else
attach_function :time, [ :buffer_out ], :ulong, ignore_error: true
Expand Down
7 changes: 2 additions & 5 deletions lib/ffi/platform.rb
Expand Up @@ -132,11 +132,8 @@ def self.is_os(os)
end

LIBC = if IS_WINDOWS
if RbConfig::CONFIG['host_os'] =~ /mingw/i
RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll'
else
"ucrtbase.dll"
end
crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase'
"#{crtname}.dll"
elsif IS_GNU
GNU_LIBC
elsif OS == 'cygwin'
Expand Down

0 comments on commit 4924308

Please sign in to comment.