From owner-freebsd-toolchain@freebsd.org Mon Jan 13 16:02:26 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 10DCF1E1317; Mon, 13 Jan 2020 16:02:26 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: from mail-yw1-xc43.google.com (mail-yw1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47xJJK0WxKz3D2v; Mon, 13 Jan 2020 16:02:24 +0000 (UTC) (envelope-from chmeeedalf@gmail.com) Received: by mail-yw1-xc43.google.com with SMTP id l14so6396703ywj.9; Mon, 13 Jan 2020 08:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HW+E0crqyOKf4O7tpILWKWbm8OIjfqUGx1w1tI5XAu0=; b=nMiWiTN9Zpb9VWPF8jYOj40cxXgcasr0/Mknw1aWJaF9CFmmFZkWLzRUyWG7VUOapL Brkv9HAb7/kVx9i6ln/Y19uqii3YYQ4YOW2w7L+8HqHP7CR8dHq90WNu1/ZoRAoXQSGZ uixMJoEK0vkYIjzPE5b1LCv4EmxpSDtVJkczBoP42uyIOhLUeYhsIf5nB8ctTjqixOo9 Wbr07RiZt/OeKARsLodBFutMV1QaEbgg0c5mrhOWGWKUu9w5Pq8z/q3+zDf3UwxYsvhd 2qTlnncp3MBNBtiS//24hRkCczhJEgmxVA8H28/E9CmKFriBTjPDI3m/BsaDyEC9sFMm Q/0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HW+E0crqyOKf4O7tpILWKWbm8OIjfqUGx1w1tI5XAu0=; b=ckbZK0e7LYuXMoXVxeNuJU1A7nzc3RAh4MomLpCoavXByiIdJCvOyVuZ6t24PaJqX+ 08el36nNrFoYb8aP2UcHE1lxK7ecOIs0YvPH1rGcKZmOrHY+udjJtDH6rsR5YhMXadXc D+9N/1tmcKxj8mqjFwNrJqsN7H4QPS3Af06rfTCmY6g6GCVFkNvY/E4g60XqIqER9fkB uj07s7nd1rrOhPwczbkZXhZBN8+4CN2fh3S8iH8IKi913UuHRA9RidFasPe+VmGP2jP7 A+CS/5bsNLBxQUGx++tPutNkh/Qs1qXf4mawbqraOqoE49Sh3vAlYlmUWFJlQ9K+cRpy VYVA== X-Gm-Message-State: APjAAAX9Bk7y1DtBXmlMZsbfsSgPw81hmibEWlXWd7Grt+p1R1svobL6 igltfd33ywz3FAOrMDey2LA= X-Google-Smtp-Source: APXvYqy5DfbGJcXoxfN5mE2gEC1R8aEVEssbklmL3ZLlzjRbarOwzaTl2EDINt/3YTldDSyt+B83xA== X-Received: by 2002:a81:50c3:: with SMTP id e186mr13592613ywb.160.1578931343677; Mon, 13 Jan 2020 08:02:23 -0800 (PST) Received: from titan.knownspace (173-19-125-130.client.mchsi.com. [173.19.125.130]) by smtp.gmail.com with ESMTPSA id p62sm5251089ywc.44.2020.01.13.08.02.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2020 08:02:23 -0800 (PST) Date: Mon, 13 Jan 2020 10:02:19 -0600 From: Justin Hibbits To: Mark Millard Cc: "bdragon@freebsd.org" , FreeBSD PowerPC ML , FreeBSD Toolchain , John Baldwin , Piotr Kubaj Subject: Re: 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: <20200113100219.7d5f19b6@titan.knownspace> In-Reply-To: <84164DA6-247F-4C13-B146-AFC6949766E0@yahoo.com> References: <84164DA6-247F-4C13-B146-AFC6949766E0.ref@yahoo.com> <84164DA6-247F-4C13-B146-AFC6949766E0@yahoo.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; powerpc64-portbld-freebsd13.0) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 47xJJK0WxKz3D2v X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=nMiWiTN9; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of chmeeedalf@gmail.com designates 2607:f8b0:4864:20::c43 as permitted sender) smtp.mailfrom=chmeeedalf@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; TO_DN_EQ_ADDR_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; FREEMAIL_TO(0.00)[yahoo.com]; RECEIVED_SPAMHAUS_PBL(0.00)[130.125.19.173.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; IP_SCORE(0.00)[ip: (1.87), ipnet: 2607:f8b0::/32(-2.10), asn: 15169(-1.84), country: US(-0.05)]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[3.4.c.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; RCVD_TLS_ALL(0.00)[] 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: Mon, 13 Jan 2020 16:02:26 -0000 On Sun, 12 Jan 2020 01:57:44 -0800 Mark Millard wrote: > [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 > #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=c++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 => /usr/lib/libc++.so.1 (0x41861000) > libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x4193d000) > libc.so.7 => /lib/libc.so.7 (0x41969000) > libgcc_s.so.1 => /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=c++17 -pedantic -g -O2 just_now.cpp > > # ldd a.out > a.out: > libc++.so.1 => /usr/lib/libc++.so.1 (0x41861000) > libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x4193d000) > libm.so.5 => /lib/libm.so.5 (0x41969000) > libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x419a4000) > libc.so.7 => /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=c++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 => /usr/lib/libc++.so.1 (0x41861000) > libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x4193d000) > libc.so.7 => /lib/libc.so.7 (0x41969000) > libgcc_s.so.1 => /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=g++9 > COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc9/gcc/powerpc-portbld-freebsd13.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=/usr/local/lib/gcc9 > --libexecdir=/usr/local/libexec/gcc9 --program-suffix=9 > --with-as=/usr/local/bin/as --with-gmp=/usr/local > --with-gxx-include-dir=/usr/local/lib/gcc9/include/c++/ > --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports > Collection' --with-system-zlib --enable-languages=c,c++,objc,fortran > --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man > --infodir=/usr/local/share/info/gcc9 > --build=powerpc-portbld-freebsd13.0 Thread model: posix gcc version > 9.2.0 (FreeBSD Ports Collection) > > # powerpc-unknown-freebsd13.0-g++9 -v > Using built-in specs. > COLLECT_GCC=powerpc-unknown-freebsd13.0-g++9 > COLLECT_LTO_WRAPPER=/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=powerpc-unknown-freebsd13.0 --disable-nls > --enable-languages=c,c++ --enable-gnu-indirect-function > --enable-initfini-array --program-prefix=powerpc-unknown-freebsd13.0- > --program-suffix=9 --without-headers --with-gmp=/usr/local > --with-pkgversion='FreeBSD Ports Collection for powerpc' > --with-system-zlib --with-gxx-include-dir=/usr/include/c++/v1/ > --with-sysroot=/ > --with-as=/usr/local/bin/powerpc-unknown-freebsd13.0-as > --with-ld=/usr/local/bin/powerpc-unknown-freebsd13.0-ld > --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man > --infodir=/usr/local/share/info/ --build=powerpc-unknown-freebsd13.0 > Thread model: posix gcc version 9.2.0 (FreeBSD Ports Collection for > powerpc) > > # 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 > > > === > Mark Millard > marklmi at yahoo.com > ( dsl-only.net went > away in early 2018-Mar) > Hi Mark, I think this is filed as a bug against LLVM already: https://bugs.llvm.org/show_bug.cgi?id=40736 . You can add to that PR. - Justin