From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12900 invoked by alias); 12 Nov 2013 23:51:31 -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 12888 invoked by uid 89); 12 Nov 2013 23:51:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=2.8 required=5.0 tests=AWL,BAYES_99,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RDNS_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-ob0-f175.google.com Received: from Unknown (HELO mail-ob0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 12 Nov 2013 23:51:28 +0000 Received: by mail-ob0-f175.google.com with SMTP id va2so6881817obc.34 for ; Tue, 12 Nov 2013 15:51:21 -0800 (PST) X-Received: by 10.182.131.196 with SMTP id oo4mr12540876obb.50.1384300280923; Tue, 12 Nov 2013 15:51:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.64.17 with HTTP; Tue, 12 Nov 2013 15:51:00 -0800 (PST) In-Reply-To: <5282BBCF.9040703@cs.utoronto.ca> References: <52815780.2010006@gmail.com> <528159F8.2070307@gmail.com> <5281F8D4.4090809@gmail.com> <5282ABED.7040400@gmail.com> <5282BBCF.9040703@cs.utoronto.ca> From: Yucong Sun Date: Tue, 12 Nov 2013 23:51:00 -0000 Message-ID: Subject: Re: C++11 program link failure under GCC 4.8.2-1 To: cygwin Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00250.txt.bz2 That's what lead me to use gnu++0x instead. For -rdynamic, apparently it would work for some simple c++ program, just not those with new c++11 features. It would be nice to fix it. Cheers. On Tue, Nov 12, 2013 at 3:37 PM, Ryan Johnson wrote: > On 12/11/2013 5:30 PM, JonY wrote: >> >> On 11/13/2013 02:35, Yucong Sun wrote: >>> >>> Good new! I've found the link failure issue, it is caused by "-rdynami= c" >>> >>> sunyc@sunyc-wks ~ >>> $ cat 2.cc >>> #include >>> >>> struct tick_event { >>> int i; >>> }; >>> >>> int main() { >>> std::deque list; >>> >>> tick_event *a =3D new tick_event; >>> list.push_back(a); >>> return 0; >>> } >>> >>> sunyc@sunyc-wks ~ >>> $ g++ -c --std=3Dc++11 -O3 -flto 2.cc -o 2.o >>> >>> sunyc@sunyc-wks ~ >>> $ g++ --std=3Dc++11 -flto -D_GNU_SOURCE -rdynamic -fno-omit-frame-point= er >>> -D_GNU_ >>> SOURCE -march=3Dnative -O3 2.o -o a >>> Cannot export >>> _ZNSt5dequeIP10tick_eventSaIS1_EE16_M_push_back_auxIJRKS1_EEEvDpOT >>> _: symbol wrong type (4 vs 3) >>> collect2: error: ld returned 1 exit status >>> >>> >>> sunyc@sunyc-wks ~ >>> $ g++ --std=3Dc++11 -flto -D_GNU_SOURCE -fno-omit-frame-pointer >>> -D_GNU_SOURCE -ma >>> rch=3Dnative -O3 2.o -o a >>> >>> sunyc@sunyc-wks ~ >>> $ >>> >>> Hope it would help you nail the problem. >>> >> -rdynamic shouldn't do anything on Windows, I guess using ELF specific >> arguments can break things. >>> >>> And Here's the test case for snprintf & c++11 >>> >>> $ gcc -v >>> Using built-in specs. >>> COLLECT_GCC=3Dgcc >>> >>> COLLECT_LTO_WRAPPER=3D/usr/libexec/gcc/x86_64-pc-cygwin/4.8.2/lto-wrapp= er.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= /sbin >>> --libexecdi >>> r=3D/usr/libexec --datadir=3D/usr/share --localstatedir=3D/var >>> --sysconfdir=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 >>> --without-libico >>> nv-prefix --without-libintl-prefix --enable-shared --enable-shared-libg= cc >>> --enab >>> le-static --enable-version-specific-runtime-libs --enable-bootstrap >>> --disable-__ >>> cxa_atexit --with-dwarf2 --with-tune=3Dgeneric >>> --enable-languages=3Dc,c++,fortran,lt >>> o,objc,obj-c++ --enable-graphite --enable-threads=3Dposix >>> --enable-libatomic --ena >>> ble-libgomp --disable-libitm --enable-libquadmath >>> --enable-libquadmath-support - >>> -enable-libssp --enable-libgcj-sublibs --disable-java-awt >>> --disable-symvers --wi >>> th-ecj-jar=3D/usr/share/java/ecj.jar --with-gnu-ld --with-gnu-as >>> --with-cloog-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) >>> >>> >>> sunyc@sunyc-wks ~ >>> $ cat 1.cc >>> #include >>> >>> int main() { >>> char out[255]; >>> snprintf(out, sizeof(out), "%d", 1); >>> return 1; >>> } >>> >>> sunyc@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 s= cope >>> snprintf(out, sizeof(out), "%d", 1); >>> ^ >>> >>> sunyc@sunyc-wks ~ >>> $ g++ --std=3Dgnu++0x 1.cc >>> >>> sunyc@sunyc-wks ~ >>> $ ls -lah a.exe >>> -rwxr-xr-x 1 sunyc None 62K Nov 12 10:21 a.exe >>> >>> Cheers. >>> >> 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. > > Yes, this has come up before [1]. Several *printf variants are affected > IIRC. > > [1] http://cygwin.com/ml/cygwin/2012-04/msg00140.html > > Ryan > > > -- > 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