delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/11/15/22:36:34

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:reply-to:subject:cc:references:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=IE9y6JLdtTrln8Gg
LGAM13VYad2zgFDgDq8sMQsaztLPXupgwH23rib3LiTSQ0nYHmg/toGwNgzy4Uo3
VS8q55b/oVVjf7TKOMy/Jb0/dMdPqrj83XLUPgAhPsm5P3l3QpkvUDDOW0zNmWbx
2AkijrCQxbGm3tNpWE/OSpeKGOI=
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:reply-to:subject:cc:references:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=cZT9XZ58tuu83omogbidZE
fW64M=; b=J+XFptSrWy0ntiG4kkOlj8tBrvgqAygd5OosVWifHicsvpwCzelzlW
zRNCSOj4js+lo07juWXmW2nKe6/pCjSRTxnheBfpI93cVjDZitXvdCxkh4lE9NXH
lICiw7fOOJW0d3m/znWjvDtt11xMk0UzuI9+EPa2EGaUIGlFpwF/Y=
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=-2.9 required=5.0 tests=AWL,BAYES_00,MISSING_HEADERS,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.1 spammy=
X-HELO: smtp-out-so.shaw.ca
Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca
Subject: Re: linker fails with multiple definitions after inline thread_local var within class
Cc: cygwin AT cygwin DOT com
References: <alpine DOT WNT DOT 2 DOT 00 DOT 1911141816490 DOT 14912 AT panamint> <f5b26568-67dc-1dfe-a35b-248f1644aed9 AT SystematicSw DOT ab DOT ca> <alpine DOT WNT DOT 2 DOT 00 DOT 1911150742490 DOT 125704 AT panamint> <769583d7-b1d7-fbc3-15ec-d377163c9d7f AT SystematicSw DOT ab DOT ca> <alpine DOT WNT DOT 2 DOT 00 DOT 1911151945330 DOT 112204 AT panamint>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Openpgp: preference=signencrypt
Message-ID: <b2d8a9db-a736-4b5a-bd83-d131b24e094a@SystematicSw.ab.ca>
Date: Fri, 15 Nov 2019 20:35:39 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1
MIME-Version: 1.0
In-Reply-To: <alpine.WNT.2.00.1911151945330.112204@panamint>
X-IsSubscribed: yes

On 2019-11-15 15:25, Arthur Norman wrote:
>> I notice that you are not independently compiling your source files and have no
>> include guard in t.h.
>> Could I suggest that you add the include guard to t.h and retest.
>> If you still have an issue, try independently compiling your source files, then
>> linking them as a separate step, to see if that works.
>> You could also test reproducing the issue on another gcc platform, under a Unix
>> VM, or a WSL Linux distro.
> 
> I attach a versiuon of the test with an include guard and with t1.cpp and t2.cpp
> compiled in separate invocations of g++ - I still see the multiple definition.
> 
> ${1:-g++} -std=c++17 -I. -c t1.cpp
> ${1:-g++} -std=c++17 -I. -c t2.cpp
> ${1:-g++} -std=c++17 t1.o t2.o -o t
> /usr/lib/gcc/x86_64-pc-cygwin/8.3.0/../../../../x86_64-pc-cygwin/bin/ld:
> t2.o:t2.cpp:(.text+0x86): multiple definition of `TLS init function for
> Data::valref'; t1.o:t1.cpp:(.text+0x4a): first defined here
> collect2: error: ld returned 1 exit status
> ./t
> 
> As per my original posting before enquiring here I had tried on a 64-bit ubuntu
> machine, on a Macbook (where it is clang not g++, but I invoke the compiler as
> g++) and on a Raspberry pi.

Sorry missed that.

> The original code I had pain with was with include guards and all files compiled
> independently via make - the test casee I submitted had perhaps tried to hard to
> shorten and simplify.
> 
> I also tried both 32 and 64-bit mingw compilers under cygwin - making that
> easier is why the test script goes ${1:-g++} so I can override the compiler
> selection to be x86_64-w64-mingw32-g++ or the i686 variant. Those both show the
> multiple definition problem.

That points to a common problem with the loader generating Windows PEs: it is
possible that is a Windows limitation.
As ld is part of binutils, you might want to try searching and posting on that
mailing list, conveniently located just next door:

	https://sourceware.org/binutils/
	http://sourceware.org/ml/binutils/
	http://lists.gnu.org/archive/html/bug-binutils/

before looking further at gcc.

Please emphasize clearly that this works successfully with ELF executables on
Unix platforms, and list those; and ld fails only with Windows (PE) executables
using Cygwin and Mingw 32/64 tool chains, and list those; and include the test
code, commands and results on each platform, to clearly demonstrate the issue.
Use a specific subject to get appropriate attention and a relevant response e.g.
"ld fails only for Windows PE with multiple definition of TLS init function".

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

--
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