From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin@cygwin.com
Subject: Re: Clang is using the wrong memory model
Date: Sat, 17 Aug 2019 09:48:00 -0000 [thread overview]
Message-ID: <20190817081605.GX11632@calimero.vinschen.de> (raw)
In-Reply-To: <6008d30a-cd6c-5449-2933-a041e804856c@agner.org>
[-- Attachment #1: Type: text/plain, Size: 1725 bytes --]
Oe Aug 17 07:31, Agner Fog wrote:
> > So errno was a bad example but you can try accessing e.g. __ctype_ptr__,
> > __progname, optarg, h_errno, or use FE_DFL_ENV from another DLL, just
> > for kicks.
> __ctype_ptr__ is a function
>
> h_errno works like errno with an imported function
>
> FE_DFL_ENV is a macro
>
> __progname and optarg are local variables to each exe or dll
That would contradict what, e.g., __progname is for. Here's a test:
$ cat > dll.c <<EOF
#include <stdio.h>
extern char *__progname;
void
printprog ()
{
printf ("progname: %s\n", __progname);
}
EOF
$ cat > main.c <<EOF
extern void printprog();
int
main ()
{
printprog ();
}
EOF
$ uname -a
CYGWIN_NT-10.0 vmbert10 3.1.0(0.340/5/3) 2019-08-16 14:36 x86_64 Cygwin
Lets try the medium model first:
$ gcc -g -shared -mcmodel=medium -o dll.dll dll.c
$ gcc -g -mcmodel=medium -o main main.c dll.dll
$ ./main
progname: main
Now let's try the small model:
$ gcc -g -shared -mcmodel=small -o dll.dll dll.c
$ gcc -g -mcmodel=small -o main main.c dll.dll
$ ./main
Cygwin runtime failure: /home/corinna/main.exe: Invalid relocation. Offset
0xfffffffd80348989 at address 0x40000103b doesn't fit into 32 bits
Now let's try without explicit mcmodel on the CLI:
$ gcc -g -shared -o dll.dll dll.c
$ gcc -g -o main main.c dll.dll
$ ./main
progname: main
> gcc is using the small memory model by default in Cygwin64, and it works.
No, it's not, see above.
> clang is using the small memory by default when cross-compiling for a Cygwin64 target from Linux, and it works.
...in *your* example code.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-08-17 8:16 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1436640898.268382790.1565602671940.JavaMail.root@zimbra54-e10.priv.proxad.net>
2019-08-12 9:45 ` Inefficient use of 64-bit addresses in Clang falk.tannhauser
2019-08-14 5:51 ` Agner Fog
2019-08-16 6:06 ` Clang is using the wrong memory model Agner Fog
2019-08-16 8:25 ` Mark Geisert
2019-08-16 8:26 ` Corinna Vinschen
2019-08-16 9:27 ` Agner Fog
2019-08-16 9:52 ` Agner Fog
2019-08-16 10:39 ` Corinna Vinschen
2019-08-16 10:50 ` Agner Fog
2019-08-16 11:25 ` Corinna Vinschen
2019-08-16 13:28 ` Kai Tietz
2019-08-17 6:59 ` Agner Fog
2019-08-17 9:48 ` Corinna Vinschen [this message]
2019-08-18 11:37 ` Agner Fog
2019-08-18 11:58 ` Corinna Vinschen
2019-08-18 18:14 ` Agner Fog
2019-08-19 8:58 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190817081605.GX11632@calimero.vinschen.de \
--to=corinna-cygwin@cygwin.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).