delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/11/12/17:31:24

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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; q=dns; s=default; b=M1coZW
oBMRUefV0pHfQTdhI6xmlYPeI3etTOp8kFrKyWAyU58Yndb0n14traTwwd4K36jo
jC4r35xO2lvOypj++78YaVs7R+31ZJx8Ir+H+/1AEzGuGPb62ZuVfF1gaM1x93UK
hfWOtFCkKtb+3I944hE3BcFpJB1G9lqBoFm94=
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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type; s=default; bh=tTRw6RZGUxWm
ZqsceGySHgWsz/0=; b=oxI2m+Nun0rqL6YvdTt7YzH6UxQEi4f9RosXmg4BrBgd
/0QXt3MlyPEhUOfcSdSwdpl2eMIS8TqNp+VFlfdEXF9myuX4DsA5AlM1owpAmgJ3
7Pv4mCqhFCnJRXs1YyORbAu/irmO4W56wsFkBjjXmCyGMWQE2FK9NeDU1cBeMhk=
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-Virus-Found: No
X-Spam-SWARE-Status: No, score=1.6 required=5.0 tests=BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2
X-HELO: mail-bk0-f41.google.com
X-Received: by 10.205.22.71 with SMTP id qv7mr27556755bkb.20.1384295439077; Tue, 12 Nov 2013 14:30:39 -0800 (PST)
Message-ID: <5282ABED.7040400@gmail.com>
Date: Wed, 13 Nov 2013 06:30:05 +0800
From: JonY <10walls AT gmail DOT com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: C++11 program link failure under GCC 4.8.2-1
References: <CAJygYd3KQEhdFBAYO4ONumf=FMvjH1fuiqa4b2F0XGLPBNv2Hw AT mail DOT gmail DOT com> <52815780 DOT 2010006 AT gmail DOT com> <528159F8 DOT 2070307 AT gmail DOT com> <CAJygYd2H7tyjE73=EK2hdo2ZPvWtziU8sUkbgbo5crBtP3JRHQ AT mail DOT gmail DOT com> <CAJygYd2UqXD3e-iguMUB1FUNDmCVmC5D7b1=zHqMVs1kJ8-+qw AT mail DOT gmail DOT com> <5281F8D4 DOT 4090809 AT gmail DOT com> <CAJygYd2TZkAnOFf67TEuQd0_V9Sgz8ZaZwVrVH6tusxRni-r3A AT mail DOT gmail DOT com>
In-Reply-To: <CAJygYd2TZkAnOFf67TEuQd0_V9Sgz8ZaZwVrVH6tusxRni-r3A@mail.gmail.com>
X-IsSubscribed: yes

--4lB90wNKBG5DLH26w8IH4WuO0fRqfbex8
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 11/13/2013 02:35, Yucong Sun wrote:
> Good new! I've found the link failure issue, it is caused by  "-rdynamic"
>=20
> sunyc AT sunyc-wks ~
> $ cat 2.cc
> #include <deque>
>=20
> struct tick_event {
>     int i;
> };
>=20
> int main() {
>     std::deque<tick_event *> list;
>=20
>     tick_event *a =3D new tick_event;
>     list.push_back(a);
>     return 0;
> }
>=20
> sunyc AT sunyc-wks ~
> $ g++ -c --std=3Dc++11 -O3 -flto 2.cc -o 2.o
>=20
> sunyc AT sunyc-wks ~
> $ g++ --std=3Dc++11 -flto -D_GNU_SOURCE -rdynamic -fno-omit-frame-pointer=
 -D_GNU_
> SOURCE -march=3Dnative  -O3 2.o -o a
> Cannot export _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_E=
EEvDpOT
> _: symbol wrong type (4 vs 3)
> collect2: error: ld returned 1 exit status
>=20
>=20
> sunyc AT sunyc-wks ~
> $ g++ --std=3Dc++11 -flto -D_GNU_SOURCE -fno-omit-frame-pointer -D_GNU_SO=
URCE -ma
> rch=3Dnative  -O3 2.o -o a
>=20
> sunyc AT sunyc-wks ~
> $
>=20
> Hope it would help you nail the problem.
>=20

-rdynamic shouldn't do anything on Windows, I guess using ELF specific
arguments can break things.
>=20
> And Here's the test case for snprintf & c++11
>=20
> $ gcc -v
> Using built-in specs.
> COLLECT_GCC=3Dgcc
> COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapper=
.exe
> Target: x86_64-pc-cygwin
> Configured with: /cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc-4=
.8.2/co
> nfigure --srcdir=3D/cygdrive/i/szsz/tmpp/cygwin64/gcc/gcc-4.8.2-1/src/gcc=
-4.8.2 --
> prefix=3D/usr --exec-prefix=3D/usr --bindir=3D/usr/bin --sbindir=3D/usr/s=
bin --libexecdi
> r=3D/usr/libexec --datadir=3D/usr/share --localstatedir=3D/var --sysconfd=
ir=3D/etc --lib
> dir=3D/usr/lib --datarootdir=3D/usr/share --docdir=3D/usr/share/doc/gcc -=
C --build=3Dx86
> _64-pc-cygwin --host=3Dx86_64-pc-cygwin --target=3Dx86_64-pc-cygwin --wit=
hout-libico
> nv-prefix --without-libintl-prefix --enable-shared --enable-shared-libgcc=
 --enab
> le-static --enable-version-specific-runtime-libs --enable-bootstrap --dis=
able-__
> cxa_atexit --with-dwarf2 --with-tune=3Dgeneric --enable-languages=3Dc,c++=
,fortran,lt
> o,objc,obj-c++ --enable-graphite --enable-threads=3Dposix --enable-libato=
mic --ena
> ble-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-su=
pport -
> -enable-libssp --enable-libgcj-sublibs --disable-java-awt --disable-symve=
rs --wi
> th-ecj-jar=3D/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as --with-c=
loog-incl
> ude=3D/usr/include/cloog-isl --without-libiconv-prefix --without-libintl-=
prefix --
> with-system-zlib
> Thread model: posix
> gcc version 4.8.2 (GCC)
>=20
>=20
> sunyc AT sunyc-wks ~
> $ cat 1.cc
> #include <stdio.h>
>=20
> int main() {
>  char out[255];
>  snprintf(out, sizeof(out), "%d", 1);
>  return 1;
> }
>=20
> sunyc AT sunyc-wks ~
> $ g++ --std=3Dc++11 1.cc
> 1.cc: In function =E2=80=98int main()=E2=80=99:
> 1.cc:5:36: error: =E2=80=98snprintf=E2=80=99 was not declared in this sco=
pe
>   snprintf(out, sizeof(out), "%d", 1);
>                                     ^
>=20
> sunyc AT sunyc-wks ~
> $ g++ --std=3Dgnu++0x 1.cc
>=20
> sunyc AT sunyc-wks ~
> $ ls -lah a.exe
> -rwxr-xr-x 1 sunyc None 62K Nov 12 10:21 a.exe
>=20
> Cheers.
>=20

Right now, it is guarded by:
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >=3D 199901L)

Which means non-strict mode and C99 mode, snprintf was not part of
C++03. I guess (__cplusplus >=3D 201103L) needs to be added to newlib.



--4lB90wNKBG5DLH26w8IH4WuO0fRqfbex8
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (MingW32)

iQIcBAEBAgAGBQJSgqv0AAoJEHE7X+KcFF1F/tAP/3AGmjcgcdIhj4doSmpibfXy
UYdCEfrdD9c9J/aS0rv5xKQPxD1NEDfX6xLyrxT59ttXJrPiPLmVNhZ0f7svYjrn
HMADcVi5aFuRKLdONlG24jODCgxf3sIKZDgkEa2G5+V7lRTnS63Ko/fywM5sWTP7
tQnTaPbQ+ns4lvsnqGMcrhW7iruQAdhrS5WKB0tXcAupacuiukfD/pxbqrJkYuRk
G2Am/q71KO44e4mabjGWxAENI7lpRIlYC8fZcM1EjxRCaeWUzjE5jQCUmPeAN566
hkThbhTy7ZM8w1gBwK6Jtn2QRmSGiee693wHaSsyYBBNEq6ejd4JXIfqL314xyjb
8OEzfLVq+1QwDh8LOfOCkVD0q4Dn6YMvX6wjplJ1dxLW/j4aEGfcz2loI2nKMhKK
YIzqPPv8JgEIK8tyDRcvb4MCGL2XZ6kxz9XlbKhTw3mG+VUW960rsTnO3bJ52opP
nU+VNhgd/5B3A+uLU74Bp/nAnIiAncQdo7iHipbaiH4Kd4hktCDaAG69W3eURCEC
Z0Gzt9Y1+pvVGHq2YiMxyRaI2aSN2GAvPb6MuO3SwmeB1fligBJzLoegZNK66Ugd
VDpkXKMwO2ByXc5w3EujBU4NhCvCswstogzeJPYaS7t7CE45c0vrN7gknR0FlXFU
zKF3tP1Fbg2WjNouBCNu
=PxtO
-----END PGP SIGNATURE-----

--4lB90wNKBG5DLH26w8IH4WuO0fRqfbex8--

- Raw text -


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