From owner-freebsd-toolchain@freebsd.org Sun Jan 12 09:57:53 2020 Return-Path: Delivered-To: freebsd-toolchain@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2B1F222AABC for ; Sun, 12 Jan 2020 09:57:53 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic307-54.consmr.mail.gq1.yahoo.com (sonic307-54.consmr.mail.gq1.yahoo.com [98.137.64.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47wXG80ZyJz4DKd for ; Sun, 12 Jan 2020 09:57:51 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: INd3Bu4VM1l_OD_m1XBFf.BrxQAaN.poayBgIZq4vcLE4puh4AUBp6S25QmF98s VqPiFzJM6YA7LS9R5hq5erY0neudgnLRo9mEkfc20Ta.Rp0BovT.xzlAA9qx8l1rc3gemleq1D8G 6IdZ3XU3mZkrF8tVF6x7CLwP9gARzdoTqSNRsvXD9cHiFrb_Z4R3QuNMyNzHbd3YXj68iFhXvehg bYX6NoYuSB27dOBTnG2ksTR7lJ_tw0fX9cOgmMwsgbp.HLgE.WexP8twX8DUttoZNLuUTtQb6PeD 2_hdzneVahhBUtfDiV7Zz5xF_mrJUB8Ko4dIsAWO2HXG_BM_IfL2SE0CGIhO95FzBw8OCGAggeb6 Qe.uWBkkb.mE96vvOYX7Pc0Xri.21Bb6udlS8ZFbo8NVd6LtgdNoGxwu8YrFuZ3N9XtU29C8zh3. s1r2AhHhbtw2mJjhNyHowvS1FdGG_eBf5ebDmgJBfY.mgFB4SB5F7O1dt.ex_CJwzlGI9JqQP6.F 0Oz0zKrUC_9qPvANUH76ox8eX9bTOQpwQh0ofAoPXOTDhw4uOKbj6ZeosJh3juZRrZ1tBHu5MhWK I5KFI_l_Z8nIZIpumdXjRHa7BuawtuVID07Yr4ih_5sI93c67CJrrA06rweIsQsJsaMklFFk8m9y eLtPRLUvmAwr7_zyTMES93tPudtFv03QbOOe_Hxpt22eL8iHMJVBZ31nGRswWxnOOP3Hjl94hGlg w5T_ngHT4gdFTxNznbrfsDC5.bLu2_aAbbfS7QA9cYOg.4JNeoHo5I.k98RwIaQFfNd9KCE7VGfE VfkKp33v6ltwaR5Lu8hIc79SBx.oficPthhykMfeEhRv85nohirZLHQS0zg_hU3Ss9kCVfwygA7d YvrEqIu.P17bPFyX4OKGHsq0js7TXGQNoRtins8MlCwzQ2dhSesO8DSCj_Ymv3wgDewSBB6ZW8A. 7A5ue9xU3Lp0cMYU_rrot9CK0pSvmEDzCVytty7rLBbbiY6YhrVuM7hMZ0_UuzF.n_D4AoGK6aNt .xg3FzskAPQZZa_6bCvvRwzIrTyjE7Yg1Ee22JZTI2aYXvqClnskqVfmzqETPT45fRHSx2Sta5iu N2Tkh9nrjzSWn8w74RqigAMV2KOgzj.wjzURfZ8LpJVq7seeVv34qZ78iL.l8j93vBRPreG2ObU9 BoVkASKjr1rQqT9IPWe8z6arjJI2mSIAbBFBIgTX5IUkna6gb6OXnHrZPS8hVTaT0rxektooR8u7 3lYJ4I7mSOc6JYzuuCh32XaXVNRaa207YnAdUfey_XzljbJhwYWXTei8MIcXQDcRigTYDI79.TBE BjH6TPEdL6LRWKVVyZuKm0kPnGyoZDpSGKC3fwpCOprUG5YVnc1N.0l6HDyth93syPs0ZBQOUq22 D_5Iqzc3vET9hdR0EnSVOFp_ZT5_MLq92hW2etES.dA-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.gq1.yahoo.com with HTTP; Sun, 12 Jan 2020 09:57:50 +0000 Received: by smtp415.mail.bf1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID a5ff110a9f589fe90bc109766d231de1; Sun, 12 Jan 2020 09:57:46 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) Subject: head -r356426 for 32-bit powerpc vs. powerpc-unknown-freebsd13.0-g++9 and g++9: not (fully) clang++-ABI compatible (using system-headers and libraries, not gcc's) Message-Id: <84164DA6-247F-4C13-B146-AFC6949766E0@yahoo.com> Date: Sun, 12 Jan 2020 01:57:44 -0800 Cc: John Baldwin , Piotr Kubaj To: Justin Hibbits , "bdragon@freebsd.org" , FreeBSD PowerPC ML , FreeBSD Toolchain X-Mailer: Apple Mail (2.3608.40.2.2.4) References: <84164DA6-247F-4C13-B146-AFC6949766E0.ref@yahoo.com> X-Rspamd-Queue-Id: 47wXG80ZyJz4DKd X-Spamd-Bar: - X-Spamd-Result: default: False [-1.49 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[yahoo.com]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; RCPT_COUNT_FIVE(0.00)[6]; DKIM_TRACE(0.00)[yahoo.com:+]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36647, ipnet:98.137.64.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.34)[-0.343,0]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-0.64)[-0.645,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(0.00)[ip: (7.02), ipnet: 98.137.64.0/21(0.87), asn: 36647(0.70), country: US(-0.05)]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[30.64.137.98.list.dnswl.org : 127.0.5.0]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jan 2020 09:57:53 -0000 [So far I have not checked if there is a somewhat analogous C (not C++) issue or not for gcc9 . For C++, when registers are used vs. when stack space is used does not always match system-clang++ for g++9 targeting 32-bit powerpc.] Building on a head -r356426 32-bit powerpc the following program: # more just_now.cpp=20 #include #include int main(void) { auto now0{std::chrono::steady_clock::now()}; auto now1{std::chrono::steady_clock::now()}; volatile std::vector ta{ {now0,now1} }; return 0; } via: # g++9 -std=3Dc++17 -nostdinc++ -I/usr/include/c++/v1 \ -pedantic -g -O2 -nodefaultlibs -lc++ -lc -lgcc_s \ just_now.cpp produces an a.out that SIGSEGV's. Note: lack of -O? still fails, the code is just shorter for my presentation purposes when I use something like -O2 . # ldd a.out a.out: libc++.so.1 =3D> /usr/lib/libc++.so.1 (0x41861000) libcxxrt.so.1 =3D> /lib/libcxxrt.so.1 (0x4193d000) libc.so.7 =3D> /lib/libc.so.7 (0x41969000) libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x41b74000) The same is true for powerpc-unknown-freebsd13.0-g++9 , including when used via just: # /usr/local/bin/powerpc-unknown-freebsd13.0-g++9 \ -std=3Dc++17 -pedantic -g -O2 just_now.cpp # ldd a.out a.out: libc++.so.1 =3D> /usr/lib/libc++.so.1 (0x41861000) libcxxrt.so.1 =3D> /lib/libcxxrt.so.1 (0x4193d000) libm.so.5 =3D> /lib/libm.so.5 (0x41969000) libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x419a4000) libc.so.7 =3D> /lib/libc.so.7 (0x419cc000) ( The two g++9 variants use /usr/local/bin/ld vs. /usr/local/bin/powerpc-unknown-freebsd13.0-ld . ) Here is the beginning of main's code from the g++9 variants: Dump of assembler code for function main(): 0x01800530 <+0>: stwu r1,-48(r1) 0x01800534 <+4>: mflr r0 0x01800538 <+8>: stw r0,52(r1) 0x0180053c <+12>: stw r30,40(r1) 0x01800540 <+16>: stw r31,44(r1) 0x01800544 <+20>: bl 0x1810d3c = <_ZNSt3__16chrono12steady_clock3nowEv@got.plt> 0x01800548 <+24>: mr r30,r3 0x0180054c <+28>: mr r31,r4 0x01800550 <+32>: bl 0x1810d3c = <_ZNSt3__16chrono12steady_clock3nowEv@got.plt> . . . Note the last 2 mr instructions: the code is expecting now()'s time_point to be returned in registers, not in stack space provided by main. It is not expecting now() to require an address for the time_point (in r3). (That does not match the system-libraries implementation: that code will try to use r3 as pointing to where to put the time_point.) By contrast, via system clang: # c++ -std=3Dc++17 -nostdinc++ -I/usr/include/c++/v1 \ -pedantic -g -O2 -nodefaultlibs -lc++ -lc -lgcc_s \ just_now.cpp # ldd a.out a.out: libc++.so.1 =3D> /usr/lib/libc++.so.1 (0x41861000) libcxxrt.so.1 =3D> /lib/libcxxrt.so.1 (0x4193d000) libc.so.7 =3D> /lib/libc.so.7 (0x41969000) libgcc_s.so.1 =3D> /lib/libgcc_s.so.1 (0x41b74000) Dump of assembler code for function main(): 0x01800768 <+0>: mflr r0 0x0180076c <+4>: stw r0,4(r1) 0x01800770 <+8>: stwu r1,-32(r1) 0x01800774 <+12>: addi r3,r1,24 0x01800778 <+16>: bl 0x1810aa0 = <_ZNSt3__16chrono12steady_clock3nowEv@got.plt> 0x0180077c <+20>: addi r3,r1,16 0x01800780 <+24>: bl 0x1810aa0 = <_ZNSt3__16chrono12steady_clock3nowEv@got.plt> . . . clang++ creates stack space and passes the address of that stack space, with distinct values for each call. It does not expect to get the time_point from a now() from registers after the calls. (That does match the system-libraries implementation: that code will try to use r3 as pointing to where to put the time_point.) This may mean that building gcc9 without the full bootstrap vs. with the full bootstrap would have consequences for the gcc library code and if it matched the FreeBSD system or not: when built by clang++ the code would have clang++'s code generation ABI properties. But even without a full bootstrap, use of g++9 variants (as they are) may be problematical for building ports and other code. For reference: # g++9 -v Using built-in specs. COLLECT_GCC=3Dg++9 = COLLECT_LTO_WRAPPER=3D/usr/local/libexec/gcc9/gcc/powerpc-portbld-freebsd1= 3.0/9.2.0/lto-wrapper Target: powerpc-portbld-freebsd13.0 Configured with: /wrkdirs/usr/ports/lang/gcc9/work/gcc-9.2.0/configure = --disable-multilib --disable-plugin --disable-bootstrap --disable-nls = --enable-gnu-indirect-function --libdir=3D/usr/local/lib/gcc9 = --libexecdir=3D/usr/local/libexec/gcc9 --program-suffix=3D9 = --with-as=3D/usr/local/bin/as --with-gmp=3D/usr/local = --with-gxx-include-dir=3D/usr/local/lib/gcc9/include/c++/ = --with-ld=3D/usr/local/bin/ld --with-pkgversion=3D'FreeBSD Ports = Collection' --with-system-zlib --enable-languages=3Dc,c++,objc,fortran = --prefix=3D/usr/local --localstatedir=3D/var --mandir=3D/usr/local/man = --infodir=3D/usr/local/share/info/gcc9 = --build=3Dpowerpc-portbld-freebsd13.0 Thread model: posix gcc version 9.2.0 (FreeBSD Ports Collection)=20 # powerpc-unknown-freebsd13.0-g++9 -v Using built-in specs. COLLECT_GCC=3Dpowerpc-unknown-freebsd13.0-g++9 = COLLECT_LTO_WRAPPER=3D/usr/local/libexec/gcc/powerpc-unknown-freebsd13.0/9= .2.0/lto-wrapper Target: powerpc-unknown-freebsd13.0 Configured with: = /wrkdirs/usr/ports/devel/freebsd-gcc9/work-powerpc/gcc-9.2.0/configure = --target=3Dpowerpc-unknown-freebsd13.0 --disable-nls = --enable-languages=3Dc,c++ --enable-gnu-indirect-function = --enable-initfini-array --program-prefix=3Dpowerpc-unknown-freebsd13.0- = --program-suffix=3D9 --without-headers --with-gmp=3D/usr/local = --with-pkgversion=3D'FreeBSD Ports Collection for powerpc' = --with-system-zlib --with-gxx-include-dir=3D/usr/include/c++/v1/ = --with-sysroot=3D/ = --with-as=3D/usr/local/bin/powerpc-unknown-freebsd13.0-as = --with-ld=3D/usr/local/bin/powerpc-unknown-freebsd13.0-ld = --prefix=3D/usr/local --localstatedir=3D/var --mandir=3D/usr/local/man = --infodir=3D/usr/local/share/info/ --build=3Dpowerpc-unknown-freebsd13.0 Thread model: posix gcc version 9.2.0 (FreeBSD Ports Collection for powerpc)=20 # c++ -v FreeBSD clang version 9.0.1 (git@github.com:llvm/llvm-project.git = c1a0a213378a458fbea1a5c77b315c7dce08fd05) (based on LLVM 9.0.1) Target: powerpc-unknown-freebsd13.0 Thread model: posix InstalledDir: /usr/bin =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)