Bug 50077 - large model (-mcmodel=large) is broken on *86*-apple-darwin*
Summary: large model (-mcmodel=large) is broken on *86*-apple-darwin*
Status: RESOLVED DUPLICATE of bug 90698
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2011-08-13 15:37 UTC by Dominique d'Humieres
Modified: 2019-06-01 00:47 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-apple-darwin1*, i?86-apple-darwin9
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-02-02 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dominique d'Humieres 2011-08-13 15:37:02 UTC
On x86_64-apple-darwin10 gcc.target/i386/pr49866.c fails with

[macbook] f90/bug% gcc47 -O2 -mcmodel=large /opt/gcc/work/gcc/testsuite/gcc.target/i386/pr49866.c
/var/folders/LW/LW1oufkMGIqlLpjYn45fBU+++TI/-Tmp-//ccCXYFLc.s:10:junk `@PLTOFF' after expression
/var/folders/LW/LW1oufkMGIqlLpjYn45fBU+++TI/-Tmp-//ccCXYFLc.s:32:junk `@PLTOFF' after expression
/var/folders/LW/LW1oufkMGIqlLpjYn45fBU+++TI/-Tmp-//ccCXYFLc.s:34:junk `@PLTOFF' after expression
/var/folders/LW/LW1oufkMGIqlLpjYn45fBU+++TI/-Tmp-//ccCXYFLc.s:48:junk `@PLTOFF' after expression

The test has been introduced at revision 176842, but fails for all the gcc versions I have tried from 4.4.6 to trunk.
Comment 1 Dominique d'Humieres 2012-01-09 21:45:19 UTC
I have tested the  -mcmodel=large option on some simple C tests and I got the same kind of failures.
So -mcmodel=large seems broken on x86_64-apple-darwin10 (gcc 4.4.6, 4.5.3, and 4.6.2).

gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)

gives for

[macbook] f90/bug% cat sin.c
#include <stdio.h>
#include <math.h>

unsigned int ta;

main ()
{
  double result;
  for (ta = 1; ta <= 8000000; ta++)
    {
      result = sin(ta * 3.14159);
    }
  printf("result = \t%.13e\n", result);
}

sin.c:1: sorry, unimplemented: code model large not supported in PIC mode
sin.c:1: error: code model 'large' not supported in the 64 bit mode
Comment 2 Iain Sandoe 2012-02-02 11:40:03 UTC
Fails at m64 on i686-darwin9 too.

the code below is obviously incorrect for m64 x86 Darwin;  so, we just don't handle the large model.

        movabsq $_GLOBAL_OFFSET_TABLE_-L7, %r11
        pushq   %r15
LCFI0:
        movq    %rcx, %r15
        movabsq $_baz@PLTOFF, %rax
        pushq   %r14
LCFI1:
        movabsq $_fn2@PLTOFF, %r14
        pushq   %r13
LCFI2:
        movabsq $_fn@PLTOFF, %r13
        pushq   %r12

------

clang seems to support -mcmodel=large - at least at 3.1 - so any necessary ld64/dyld support is available.

This is not likely to get fixed in the short term (certainly not in stage 4) - so we'll have to decide between XFAIL/tolerate the noise in the error logs.
Comment 3 Dominique d'Humieres 2012-02-02 16:06:05 UTC
> clang seems to support -mcmodel=large - at least at 3.1 - so any necessary
> ld64/dyld support is available.

The test compiles (using -c) with

Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)

> This is not likely to get fixed in the short term (certainly not in stage 4) -
> so we'll have to decide between XFAIL/tolerate the noise in the error logs.

When XFAILed, this kind of bug disappears from the radar scopes and tends to rot forever (see pr10901) until it resurfaces in a nasty way. I'ld prefer to change the summary to something such as "large model is broken on *86*-apple-darwin*" to point to the real problem.
Comment 4 Dominique d'Humieres 2015-01-03 12:45:12 UTC
Also seen on x86_64-apple-darwin14.
Comment 5 Eric Gallager 2017-07-28 14:55:02 UTC
(In reply to Dominique d'Humieres from comment #3)
> > clang seems to support -mcmodel=large - at least at 3.1 - so any necessary
> > ld64/dyld support is available.
> 
> The test compiles (using -c) with
> 
> Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)
> 
> > This is not likely to get fixed in the short term (certainly not in stage 4) -
> > so we'll have to decide between XFAIL/tolerate the noise in the error logs.
> 
> When XFAILed, this kind of bug disappears from the radar scopes and tends to
> rot forever (see pr10901) until it resurfaces in a nasty way. I'ld prefer to
> change the summary to something such as "large model is broken on
> *86*-apple-darwin*" to point to the real problem.

OK, retitling.
Comment 6 Iain Sandoe 2018-07-31 12:57:09 UTC
(In reply to Iain Sandoe from comment #2)

> clang seems to support -mcmodel=large - at least at 3.1 - so any necessary
> ld64/dyld support is available.

That's an incorrect assumption on my part, although clang produces object files without error. (for -c) it seems that the static linker cannot consume them.

On Darwin16 (and Dominique reports similar on D17):
For -mcmodel=medium and -mcmodel=large we get relocation fails at link time.

So, it seems that we should;
(a) disable tests using -mcmodel={medium,large} for current darwin
(b) possibly modify the darwin-specific option parsing to warn that these are unsupported and reset the value to "small".
Comment 7 Iain Sandoe 2019-06-01 00:47:17 UTC
this is currently unimplemented for Darwin - posting an enhancement bug

*** This bug has been marked as a duplicate of bug 90698 ***