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

MSVC 2019 Fixes #779

Merged
merged 6 commits into from May 23, 2020
Merged

MSVC 2019 Fixes #779

merged 6 commits into from May 23, 2020

Commits on May 18, 2020

  1. Copy the full SHA
    481adbc View commit details
    Browse the repository at this point in the history
  2. MSVC defines long double to be just a double (see https://docs.micros…

    …oft.com/en-us/cpp/c-language/type-long-double?view=vs-2019). Thus libffi built with MSVC does not export it as a separate type. This workaround that issue.
    cfis committed May 18, 2020
    Copy the full SHA
    976f4b0 View commit details
    Browse the repository at this point in the history
  3. MSVC will not initialize static structure using non-constant values (…

    …GCC will do it but I think via an extension, its not part of the C language). Anyway, this fixes the compile error on MSVC.
    cfis committed May 18, 2020
    Copy the full SHA
    7f58fd3 View commit details
    Browse the repository at this point in the history
  4. If you build libffi with MSVC, the latest version gets installed as l…

    …ibffi-8.lib. This commit adds that name to the have_library search list. It also adds in have_library calls for libffi_convenience.lib and shlwapi.lib, both of which are required for MSVC to build the bindings.
    cfis committed May 18, 2020
    Copy the full SHA
    d9bd3f9 View commit details
    Browse the repository at this point in the history
  5. On windows, when using Ruby built with mingw64, FFI:LIBC returns msvc…

    …rt.dll. When using Ruby built with MSVC, FFI:LIBC returns vcruntime.dll
    
    Neither is correct. Starting in Visual Studio 2015, the C runtime library migrated to ucrtbase.dll. See https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2019 for more information. Or https://devblogs.microsoft.com/cppblog/introducing-the-universal-crt/.
    
    I assume this hasn't been reported as a bug since almost no one uses a MSVC Ruby build, and attach_function for functions like malloc does actually work using msvcrt.dll - but does not with vcruntime.dll
    
    This patch changes mingw64 and mswin to use ucrtbase.dll for the C library. Tested both with mswin and mingw64 Ruby builds.
    
    The one downside of this patch is that it would break for anyone running a version of Windows that hasn't been updated since Spring 2015 when Microsoft introduced this change (the dll ships with Windows 10 and was back ported to older windows versions via Windows update). So seems to me a very, very low risk.
    cfis committed May 18, 2020
    Copy the full SHA
    c674683 View commit details
    Browse the repository at this point in the history
  6. On MSCV, an unsigned long is 4 bytes (32 bits), not 8 bytes. Thus the…

    … alignment code using ~0x7UL truncates pointers resulting in crashes. Instead, use unsigned long long wich is 8 bytes.
    cfis committed May 18, 2020
    Copy the full SHA
    7bbbce2 View commit details
    Browse the repository at this point in the history