From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120413 invoked by alias); 16 Aug 2019 06:06:51 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 120406 invoked by uid 89); 16 Aug 2019 06:06:51 -0000 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 Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.51.35) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 16 Aug 2019 06:06:49 +0000 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 60D674B46D0 for ; Fri, 16 Aug 2019 01:06:47 -0500 (CDT) Received: from gator4009.hostgator.com ([192.185.4.20]) by cmsmtp with SMTP id yVNvhT2KB3Qi0yVNvhAYmX; Fri, 16 Aug 2019 01:06:47 -0500 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==; Received: from 0190101441.0.fullrate.ninja ([2.110.93.203]:55559 helo=[192.168.1.49]) by gator4009.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1hyVNu-002M1O-V2 for cygwin@cygwin.com; Fri, 16 Aug 2019 01:06:47 -0500 Subject: Clang is using the wrong memory model To: cygwin@cygwin.com References: <732305300.268416262.1565603129541.JavaMail.root@zimbra54-e10.priv.proxad.net> <024ce5b5-6024-b371-e382-5eef5d1d4a90@agner.org> From: Agner Fog Message-ID: <075477ca-e031-39ea-3dfe-bc8bc2fc8fa6@agner.org> Date: Fri, 16 Aug 2019 06:06:00 -0000 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> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00209.txt.bz2 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.tannhauser@free.fr wrote: >> References: <578eb489-9391-9009-82ad-676eeb4c1c92@agner.org> >> In-Reply-To: <578eb489-9391-9009-82ad-676eeb4c1c92@agner.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