New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 705071 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Closed: Aug 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Blocked on:
issue 722482
issue 728360
issue 749263



Sign in to add a comment

Make compiler-rt as default lib for llvm

Project Member Reported by manojgupta@chromium.org, Mar 24 2017

Issue description

We want to move to compiler-rt instead of using libgcc in llvm.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Mar 27 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/b38326b15a11dcb28564b96469ed55f8a5f00f4a

commit b38326b15a11dcb28564b96469ed55f8a5f00f4a
Author: Manoj Gupta <manojgupta@google.com>
Date: Mon Mar 27 06:11:34 2017

Add default-compiler-rt and default-libcxx use flags to llvm.

Add these use flags from Gentoo upstream ebuild. This change
only adds the flags.
To actually make compiler-rt and libc++ as default,
must do USE="default-compiler-rt default-libcxx" emerge llvm clang.

BUG= chromium:705071 
TEST=USE="default-compiler-rt" emerge llvm clang works. And clang add
libclang_rt.builtins-armhf.a to linker command line by default.

Change-Id: I6ebd524058ffccbe4b3c4c710c73d5646c3a390d
Reviewed-on: https://chromium-review.googlesource.com/458966
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Yunlian Jiang <yunlian@chromium.org>

[rename] https://crrev.com/b38326b15a11dcb28564b96469ed55f8a5f00f4a/sys-devel/llvm/llvm-4.0_pre285905-r11.ebuild

Comment 2 by bcf@chromium.org, Apr 5 2017

Cc: bcf@chromium.org llozano@chromium.org wzhong@chromium.org
 Issue 708405  has been merged into this issue.
llvm-libunwind is now part of toolchain prebuilts.
Compiler-rt can be used now by adding these 2 options to clang:

-rtlib=compiler-rt -lunwind
Project Member

Comment 4 by bugdroid1@chromium.org, Apr 22 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/56a0198065757e37b0830bc477357c9a4c85584b

commit 56a0198065757e37b0830bc477357c9a4c85584b
Author: Manoj Gupta <manojgupta@google.com>
Date: Sat Apr 22 04:57:33 2017

Add llvm-next use to compiler-rt and llvm-libunwind ebuilds.

Also add a patch to clang in llvm-next to use libunwind when compiler-rt
is the default rtlib.

BUG= chromium:705071 
TEST=compiler-rt and llvm-libwinds build with llvm-next use.
TEST=-lunwind is added to linker flags when -rtlib=compiler-rt
is specified in clang (llvm-next).

Change-Id: I5c7d47cf8f6d52f60f3c9a7db679f10927d3de08
Reviewed-on: https://chromium-review.googlesource.com/482465
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Rahul Chaudhry <rahulchaudhry@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>

[add] https://crrev.com/56a0198065757e37b0830bc477357c9a4c85584b/sys-devel/llvm/files/cherry/clang-5.0-enable-libunwind-with-compiler-rt.patch
[modify] https://crrev.com/56a0198065757e37b0830bc477357c9a4c85584b/sys-libs/compiler-rt/compiler-rt-4.0_pre285905.ebuild
[rename] https://crrev.com/56a0198065757e37b0830bc477357c9a4c85584b/sys-devel/llvm/llvm-4.0_pre285905-r17.ebuild
[modify] https://crrev.com/56a0198065757e37b0830bc477357c9a4c85584b/sys-libs/llvm-libunwind/llvm-libunwind-4.0_pre285905.ebuild

bcf@ can you try using compiler-rt now? Please pass -rtlib=compiler-rt to clang arguments.

Comment 6 by bcf@chromium.org, May 3 2017

Sure, I'll give it a try.
Updates:

amd64 boards work fine with compiler-rt. 
Caroline: https://uberchromegw.corp.google.com/i/chromiumos.tryserver/builders/release/builds/10942
Peppy: https://uberchromegw.corp.google.com/i/chromiumos.tryserver/builders/release/builds/11026

Arm however does not work (failed in UnitTests).
Kevin: https://uberchromegw.corp.google.com/i/chromiumos.tryserver/builders/release/builds/11027
Failed packages: chromeos-base/p2p chromeos-base/quipper

After quite a bit of debugging, I root caused it to be a calling convention mismatch. LLVM expects aapcs for aeabi_ functions but compiler-rt was mapping them to aapcs_vfp. 
Fixing the incorrect calling convention issues in compiler-rt locally fixed these UnitTests.
However, there is a new UnitTest fail in chromeos-base/shill (qeum-arm seg faults). Also the image when booting reaches the logo stage but fails to continue and reboots.


I suspect kevin failures because of using llvm-libunwind as the unwinder, and not compiler-rt itself.

In particular, the UnitTest shows the problem with this sequence of code using GTest.

cellular_capability_universal_unittest.cc
TEST_F(CellularCapabilityUniversalMainTest, UpdateActiveBearer) {
 ....
   // Handle exceptions in following statement.
  EXPECT_DEATH(capability_->UpdateActiveBearer(),
               "Found more than one active bearer.");
...

void CellularCapabilityUniversal::UpdateActiveBearer() {
...
     // This statement is expected to fail
    CHECK(!active_bearer_) << "Found more than one active bearer.";


I am testing using libgcc as the unwinder for compiler-rt. If that works, llvm-libunwind can't be used as the unwinder for now.
Kevin image with compiler_rt and libgcc as unwinder works :)

Blockedon: 722482
Status: Started (was: Untriaged)
Project Member

Comment 14 by bugdroid1@chromium.org, May 23 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/chromite/+/b818156c0bd4701dd8887ea596c18fa9ace0a4d7

commit b818156c0bd4701dd8887ea596c18fa9ace0a4d7
Author: Manoj Gupta <manojgupta@google.com>
Date: Tue May 23 15:28:11 2017

Build compiler-rt before other cross-target packages.

When compiler-rt is used as builtin library,
compiler-rt library needs to be built before other cross packages
are built.

BUG= chromium:705071 
TEST=Cross packages get built with compiler-rt as default.

Change-Id: I59d2284a4fd76d98ab552ac1b1de0093ea71b57a
Reviewed-on: https://chromium-review.googlesource.com/510175
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Caroline Tice <cmtice@chromium.org>

[modify] https://crrev.com/b818156c0bd4701dd8887ea596c18fa9ace0a4d7/scripts/cros_setup_toolchains.py

Project Member

Comment 15 by bugdroid1@chromium.org, May 24 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/toolchain-utils/+/66682c74f91da6a90274dfea967dba1a43504bcb

commit 66682c74f91da6a90274dfea967dba1a43504bcb
Author: Manoj Gupta <manojgupta@google.com>
Date: Wed May 24 22:56:23 2017

Start testing compiler-rt with llvm-next.

We want to test compiler-rt performance and stability.
So start testing llvm-next with compiler-rt as default using CL
513590.

BUG= chromium:705071 
TEST=buildbot runs with CL 513590 are fine for daisy, squawks, elm and
peppy.

Change-Id: Ic43ef238c7fce0cb88caabab7e6a32b1940cb860
Reviewed-on: https://chromium-review.googlesource.com/514302
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Trybot-Ready: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Caroline Tice <cmtice@chromium.org>

[modify] https://crrev.com/66682c74f91da6a90274dfea967dba1a43504bcb/buildbot_test_toolchains.py

Blockedon: 728360
Blockedon: 729178
Labels: compiler-rt-migration
Blockedon: 749263
Status: Verified (was: Started)
Done as part of llvm roll on Aug 6.
Project Member

Comment 21 by bugdroid1@chromium.org, Sep 15 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/1697df2534816342993337cb64b8c2ed1691d44f

commit 1697df2534816342993337cb64b8c2ed1691d44f
Author: Manoj Gupta <manojgupta@google.com>
Date: Fri Sep 15 23:54:09 2017

compiler-rt: Patches for ARM softfp and clear_cache bugs.

clear_cache: Disable abort() if ARM syscall may error.

Also Cherry pick upstream CL 4854a215fc3c0b10ab57b4b9b5e4cbeb5bf0624a
Author:     Oleg Ranevskyy <oranevskyy@accesssoftek.com>
CommitDate: Wed Aug 23 14:26:31 2017 +0000

    [ARM][Compiler-rt] Fix AEABI builtins to correctly pass arguments to non-AEABI functions on HF targets

    Summary:
    This is a patch for PR34167.

    On HF targets functions like `__{eq,lt,le,ge,gt}df2` and `__{eq,lt,le,ge,gt}sf2` expect their arguments to be passed in d/s
registers, while some of the AEABI builtins pass them in r registers.

    Reviewers: compnerd, peter.smith, asl

    Reviewed By: peter.smith, asl

    Subscribers: peter.smith, aemerson, dberris, javed.absar, llvm-commits, asl, kristof.beyls

    Differential Revision: https://reviews.llvm.org/D36675

BUG= chromium:761103 
BUG= chromium:705071 

TEST=NaCL on ARM works.
TEST=ARM softfp code with mfpu=none and mfloat-abi=softfp is correct for cmp builtins.

Change-Id: I399ebae1e69dbb6727b89dffa062de72dbf39a62
Reviewed-on: https://chromium-review.googlesource.com/669661
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Trybot-Ready: Manoj Gupta <manojgupta@chromium.org>

[add] https://crrev.com/1697df2534816342993337cb64b8c2ed1691d44f/sys-libs/compiler-rt/files/compiler-rt-disable-abort-cacheflush.patch
[rename] https://crrev.com/1697df2534816342993337cb64b8c2ed1691d44f/sys-libs/compiler-rt/compiler-rt-5.0_pre305632-r4.ebuild
[add] https://crrev.com/1697df2534816342993337cb64b8c2ed1691d44f/sys-libs/compiler-rt/files/cherry/4854a215fc3c0b10ab57b4b9b5e4cbeb5bf0624a.patch

Comment 22 by bcf@chromium.org, Sep 22 2017

On 2017.08.01.163007, it looks like if I specify '-rtlib=compiler-rt', we still depend on libgcc. Is this expected?

./prebuilt/toolchain/armv7a/bin/armv7a-cros-linux-gnueabi-clang++ -stdlib=libc++ -std=c++11 -rtlib=compiler-rt ~/src/scratch/test.cc

% readelf -d a.out | grep gcc
 0x00000001 (NEEDED)                     Shared library: [libgcc_s.so.1]
bcf@ You need a newer version of toolchain :).

This is what I see for a simple c++ file.

$ armv7a-cros-linux-gnueabi-clang++ -stdlib=libc++ -std=c++11 -rtlib=compiler-rt main.cpp -o main
$ readelf -d main|grep NEEDED
 0x00000001 (NEEDED)                     Shared library: [libc++.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc++abi.so.1]
 0x00000001 (NEEDED)                     Shared library: [libm.so.6]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]

For reference, I enabled building libc++ with compiler-rt on  Sept 1. 
So toolchains post Sept 2 or 3 should not have libgcc_s dependency when compiling a file with libc++.
(https://bugs.chromium.org/p/chromium/issues/detail?id=747113)

Comment 25 by bcf@chromium.org, Sep 22 2017

Thanks for confirming.
Blockedon: -729178

Sign in to add a comment