New issue
Advanced search Search tips

Issue 828505 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: May 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug
Build-Toolchain



Sign in to add a comment

clang links with chroot's x86_64-pc-linux-gnu libraries instead of x86_64-cros-linux-gnu

Project Member Reported by manojgupta@chromium.org, Apr 3 2018

Issue description

$ cat test.cpp
int main() {
  std::cout << "Hello World" << std::endl;
  return 0;
}

$ x86_64-cros-linux-gnu-clang++ ../../test.cpp -o main -Wl,-t|& grep x86_64-pc-linux-gnu
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtbeginS.o
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/libgcc_eh.a(unwind-dw2.o)
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/libgcc_eh.a(unwind-dw2-fde-dip.o)
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtendS.o

This happens even whnm a board's sysroot is specified:

$ x86_64-cros-linux-gnu-clang++ test.cpp -o main -Wl,-t --sysroot=/build/betty|& grep x86_64-pc-linux-gnu
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtbeginS.o
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/libgcc_eh.a(unwind-dw2.o)
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/libgcc_eh.a(unwind-dw2-fde-dip.o)
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.x/crtendS.o


The expectation is that x86_64-cros-linux-gnu libraries should be used, e.g.:
/usr/lib/gcc/x86_64-cros-linux-gnu/4.9.x/crtbeginS.o
/usr/lib/gcc/x86_64-cros-linux-gnu/4.9.x/libgcc_eh.a(unwind-dw2.o)
/usr/lib/gcc/x86_64-cros-linux-gnu/4.9.x/libgcc_eh.a(unwind-dw2-fde-dip.o)
/usr/lib/gcc/x86_64-cros-linux-gnu/4.9.x/libstdc++.so
/usr/lib/gcc/x86_64-cros-linux-gnu/4.9.x/libgcc_s.so.1
/usr/lib/gcc/x86_64-cros-linux-gnu/4.9.x/libgcc_s.so.1
/usr/lib/gcc/x86_64-cros-linux-gnu/4.9.x/crtendS.o

It is rather fortunate that the above x86_64-cros-linux-gnu binaries are same as x86_64-pc-linux-gnu and we don't see any problems.
 
https://reviews.llvm.org/D45233 should address this.
Project Member

Comment 2 by bugdroid1@chromium.org, Apr 9 2018

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

commit 06edb884e91542068f8f54fd4605d3e66e7cc348
Author: Manoj Gupta <manojgupta@google.com>
Date: Mon Apr 09 22:18:59 2018

llvm-next: Cherry-pick 2 upstream commits.

Cherrypick following CLs to llvm-next:

Author:     Manoj Gupta <manojgupta@google.com>

    [Driver] Update GCC libraries detection logic for Gentoo.

    Summary:
    1. Find GCC's LDPATH from the actual GCC config file.
    2. Avoid picking libraries from a similar named tuple if the exact
       tuple is installed.

Author:     Manoj Gupta <manojgupta@google.com>

    Disable -fmerge-all-constants as default.

    Summary:
    "-fmerge-all-constants" is a non-conforming optimization and should not
    be the default. It is also causing miscompiles when building Linux
    Kernel (https://lkml.org/lkml/2018/3/20/872).

BUG= chromium:828942 
BUG= chromium:828505 

TEST=USE="llvm-next" sudo emerge llvm works.

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

[rename] https://crrev.com/06edb884e91542068f8f54fd4605d3e66e7cc348/sys-devel/llvm/llvm-7.0_pre326829_p20180318-r9.ebuild
[add] https://crrev.com/06edb884e91542068f8f54fd4605d3e66e7cc348/sys-devel/llvm/files/cherry/abb490ec962c6db7c2071ba9d1bd0cd60b4a1b3a.patch
[add] https://crrev.com/06edb884e91542068f8f54fd4605d3e66e7cc348/sys-devel/llvm/files/cherry/6f11d411da7302cfb1d049928a8222c649eef441.patch

Status: Verified (was: Untriaged)
Marking as fixed after latest llvm roll.

Sign in to add a comment