delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/08/16/02:07:43

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=a86oVSfq7dPxGEcT
1Xr8QKtVc4zYimDyaEtd/AwcudPm58a7arTtKu9y4Ng6QxdwvKvd7QP/Lw1X8h5L
4CA4kT/+frSfacf3TmMtKFU/9XyDcVjJXUwxq8IZPh5EWte7Y2r84HJI3pE7jU5T
7xyLShzBl9YDd+4BkhS4OzlLKqw=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=BG2151wQgyJtq+NRg6IANm
kkndU=; b=YnDBOaOQY+MXQvFq/I35O7MvskIsKS4URii9WZI5gbuwnd+ZriixsW
oRt8EaktJThulXWkUM0divCNjU3hhwBDWA/90/pic8swck2YM0X/HlX8jvoZnTyo
NQ7lPfW421w3ahHaFCkBBXwEaGOqNf5DG5mF2XhdQ/aH9z82lVUdc=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=problemshtml, problems.html, docshtml, UD:docs.html
X-HELO: gateway24.websitewelcome.com
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=agner.org; s=default; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version :Date:Message-ID:From:References:To:Subject:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=A9NGhLQcZhL4cws40gMWG/D5A78Oww+8pC88ot6+10o=; b=cqvGgS2qI/CaGUGr+BxPzboCsQ PkD8iwetUytYarXGj9Q1UQfxEhjnCM1AIR5R9fOoLE8HT/KIXK6UXyogxDKTtYV+amzKlbCjF4D6h O0uxrTmz/VLKBEHNPHK+j03Qd58WhR5nkZczUinnzNURI/paUhvxOdI7mp5wOuh8gIbwKuEqqsm7Z LOny6GCkt+9tlKzCcRFK8YnDjIyEdMlmSItgAC6h7594T6xMNIEsUTMZ2i4xeemyW50AFBC+iPnCi XcTh8T//JGXUnEsUdspzFpC2DwryecbzHCaxFK0AjBWkfnwH4HoVgciYE3U4j66T6qigOfdFJWXVf DDrlq5Mw==;
Subject: Clang is using the wrong memory model
To: cygwin AT cygwin DOT com
References: <732305300 DOT 268416262 DOT 1565603129541 DOT JavaMail DOT root AT zimbra54-e10 DOT priv DOT proxad DOT net> <024ce5b5-6024-b371-e382-5eef5d1d4a90 AT agner DOT org>
From: Agner Fog <agner AT agner DOT org>
Message-ID: <075477ca-e031-39ea-3dfe-bc8bc2fc8fa6@agner.org>
Date: Fri, 16 Aug 2019 08:06:44 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0
MIME-Version: 1.0
In-Reply-To: <024ce5b5-6024-b371-e382-5eef5d1d4a90@agner.org>
X-IsSubscribed: yes
Note-from-DJ: This may be spam

Cygwin Clang is using -mcmodel=medium as default for Win64, according to 
my tests, while the right model is -mcmodel=small

Linux Clang with --target=x86_64-pc-cygwin gives the small memory model.

I took this to the LLVM Bugzilla as you asked me to: 
https://bugs.llvm.org/show_bug.cgi?id=42983

This gave the following conclusion:

-mcmodel=small does something different when the target is Windows. This 
difference appears to be undocumented. The small memory model with a 
Linux target puts everything below the 2GB limit so that 32-bit absolute 
addresses can be used. The small memory model with a Windows target is 
using 32-bit relative addresses instead, which is the correct thing to 
do in Windows.

I told the LLVM guy that this difference needs to be documented so that 
you can rely on it, but this request has so far been ignored.

He says that you must have modified the source code to change the 
default memory model.

The medium memory model gives inefficient code because it uses an extra 
instruction to load a 64-bit absolute address into a register before 
every access to static data.

I cannot blame you Cygwin people for not using the small memory model as 
long as it is undocumented.

I will ask you to please join the discussion at 
https://bugs.llvm.org/show_bug.cgi?id=42983 so that we can clarify how 
to solve this problem.


On 14/08/2019 07.51, Agner Fog wrote:
> It's a difference in memory model.
>
> clang 6.0.0 under ubuntu with --target=x86_64-pc-cygwin gives relative 
> addresses, unless you specify -mcmodel=large.
>
> Cygwin clang with -mcmodel=small does the right thing: use relative 
> addresses.
>
> The -mcmodel=small option appears to work differently for Linux and 
> for Windows targets. I cannot find any documentation of this 
> difference. See:
>
> https://bugs.llvm.org/show_bug.cgi?id=42983
>
>
> On 12/08/2019 11.45, falk DOT tannhauser AT free DOT fr wrote:
>> References: <578eb489-9391-9009-82ad-676eeb4c1c92 AT agner DOT org>
>> In-Reply-To: <578eb489-9391-9009-82ad-676eeb4c1c92 AT agner DOT org>
>>
>> Could the different behaviour between Cygwin and Linux simply be due 
>> to different Clang versions?
>> The current version under Cygwin is 5.0.1, while the latest version 
>> available under Linux
>> appears to be 8.0.1 .
>>
>> Falk
>>
>> -- 
>> Problem reports:       http://cygwin.com/problems.html
>> FAQ:                   http://cygwin.com/faq/
>> Documentation:         http://cygwin.com/docs.html
>> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>>
>>
>
> -- 
> Problem reports:       http://cygwin.com/problems.html
> FAQ:                   http://cygwin.com/faq/
> Documentation:         http://cygwin.com/docs.html
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>
>

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019