Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Support building libffi as shared lib (dll) on windows (mingw) with llvm #942

@dcoutts

Description

@dcoutts

Currently libffi is supported on windows/mingw using gcc

It also happens to work on windows/mingw with llvm when building as a static library only. (This is the configuration that ghc currently uses on windows.)

It would be great to also support building libffi as a shared library (.dll) on windows with mingw and llvm. (This is needed to enable ghc to build and use shared libraries on windows).

The issue is that for some reason LLVM's lld linker does not support gnu style linker scripts on mingw.

https://github.com/mstorsjo/llvm-mingw#known-issues

LLD doesn't support linker script (in the COFF part of LLD).

It does however support the windows style .def files, used (amongst other things) to define the .dll exported symbols.

A solution therefore would be to do something like what the build system already does for solaris (which generates libffi.map-sun from libffi.map using a perl script), and generate a libffi.def file from the libffi.map. This can probably be done reasonably simply using a sed script. Or if not, perl again (though my perl skills are not up to the task).

If this seems like a reasonable approach, then one issue to look out for is that .def files ought to distinguish data exports from function exports (so that the import library is created correctly). I hope we can rely on the libffi naming convention that ffi_type_* symbols are all data symbols, and all other symbols are functions. The comments in the libffi.map suggest this is the case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions