Clang is using the wrong memory model

Corinna Vinschen corinna-cygwin@cygwin.com
Sun Aug 18 11:58:00 GMT 2019


On Aug 18 08:04, Agner Fog wrote:
> Thanks a lot for your help in clarifying this.
> 
> When I complained here about the wasteful 64-bit addresses you said that it
> was an LLVM issue.

I never said anything like that.  The issue is that your clang
linux->cygwin cross compiler uses the wrong model, that's all.  That's
a bug in clang or whatever it's using under the hood.  Clang should
follow what GCC does for years, using the medium model on Cygwin.

> When I complained to LLVM they said it was a Cygwin
> issue, and that you were using the wrong memory model.
> 
> All this confusion is due to a terrible lack of documentation of everything.
> I had to do a lot of reverse engineering to figure out what is happening.
> What I have found out so far is listed below. Much of this is undocumented.
> Obviously, I would like to know if any or this is wrong or if specific
> documentation is available other than the SysV ABI and Windows ABI:
> 
> * Cygwin is using its own loader which is different from the Windows loader.

Nope, Cygwin uses the Windows loader.

> * The Cygwin loader emulates the behavior of Linux shared objects. This
> includes the ability to directly access a variable inside a DLL

See above.

> * Access to a variable in a different DLL requires a 64-bit address. This is
> obtained by using the medium memory model with a gcc or Clang compiler.

ACK

[...]

To me, the only interesting thing is that clang continues to use the
medium memory model *by default*.  It doesn't make sense if package
maintainers and devs building something on Cygwin have to care for
memory models all of a sudden.  The default should just work.

If you want to use the small model in your own projects, great, if it
works for you.  If the medium model is wasteful in clang, that's a clang
optimization problem, not a Cygwin problem.


Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190818/79bdf26e/attachment.sig>


More information about the Cygwin mailing list