diff options
author | Lars Kanis <lars@greiz-reinsdorf.de> | 2021-06-15 16:27:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-15 16:27:22 +0200 |
commit | 4924308429dd5535cbd7795ff503315cdddad06a (patch) | |
tree | 42e95f89001d904f81701d7881d11b8f27016864 | |
parent | 036a1a350a4926b84d06f6f37f66e22992275971 (diff) | |
download | ffi-4924308429dd5535cbd7795ff503315cdddad06a.tar.gz |
Fix Windows libc detection for MSYS2-ucrt build (#903)
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.
-rw-r--r-- | bench/bench_time.rb | 2 | ||||
-rw-r--r-- | lib/ffi/platform.rb | 7 |
2 files changed, 3 insertions, 6 deletions
diff --git a/bench/bench_time.rb b/bench/bench_time.rb index aaec64f..099ec30 100644 --- a/bench/bench_time.rb +++ b/bench/bench_time.rb @@ -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 diff --git a/lib/ffi/platform.rb b/lib/ffi/platform.rb index 0f0639e..bf01a27 100644 --- a/lib/ffi/platform.rb +++ b/lib/ffi/platform.rb @@ -132,11 +132,8 @@ module FFI 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' |