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

Issue 628524 link

Starred by 3 users

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Jul 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Blocking:
issue 537368



Sign in to add a comment

llvm: clang used in Simple Chrome workflow is confused about its own identity

Project Member Reported by llozano@chromium.org, Jul 15 2016

Issue description

I am seeing some weird behavior with clang on simple chrome:

.cros_cache/chrome-sdk/t
arballs/daisy+8530.0.0+target_toolchain/usr/bin/clang++ /tmp/hello.o
/tmp/hello.o: In function `main':
/tmp/hello.cpp:(.text+0xa): undefined reference to `std::cout'
/tmp/hello.cpp:(.text+0x24): undefined reference to `std::basic_ostream<char, std::char_traits<char> >
& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char c
onst*)'

This is happening because clang is not adding -lstdc++ to the link line.
clang should do that whenver it recognizes itself as clang++. 
This works fine within the chromeos chroot. 

it turns out that clang in Simple Chrome is executed through ld-linux.so (not sure why this is)

.cros_cache/chrome-sdk/tarballs/daisy+8530.0.0+target_toolchain/usr/bin/clang
#!/bin/sh
if ! base=$(realpath "$0" 2>/dev/null); then
  case $0 in
  /*) base=$0;;
  *)  base=${PWD:-`pwd`}/$0;;
  esac
fi
basedir=${base%/*}
exec   "${basedir}/../../lib/ld-linux-x86-64.so.2"   --library-path "${basedir}/../../lib:${basedir}/../lib64"   --inhibit-rpath ''   "${base}.elf"   "$@"

within this bash script $0 ends up in clang++ but after the invocation through ld-linux.so there is no trace of the name "clang++". I think this is the reason why clang does not identify itself correctly.

There is an interesting thread related to this in https://marc.info/?l=glibc-alpha&m=146150049816403&w=2

POssible solutions
- change the name of clang.elf to something like elf.clang and elf.clang++ and call the appropriate one depending on the value of $0.
- or put the real clang in a different directory (together with clang++)


 
Project Member

Comment 1 by bugdroid1@chromium.org, Jul 27 2016

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

commit f778b1f9f606d4448aa6569dd0b051f2af22f750
Author: Rahul Chaudhry <rahulchaudhry@chromium.org>
Date: Fri Jul 22 23:51:19 2016

Remove the temporary workaround that added -lstdc++ to linker commands.

https://chromium-review.googlesource.com/#/c/362682/ fixes the clang++
invocation, so this workaround is no longer needed.

BUG= chromium:628524 
TEST='cros_setup_toolchains --create-packages -t x86_64-cros-linux-gnu'
TEST=Used x86_64-cros-linux-gnu.tar.xz to successfully build chrome for panther (simple-chrome).
TEST='cros_setup_toolchains --create-packages -t i686-pc-linux-gnu'
TEST=Used i686-pc-linux-gnu.tar.xz to successfully build chrome for x86-zgb (simple-chrome).
TEST='cros_setup_toolchains --create-packages -t armv7a-cros-linux-gnueabi'
TEST=Used armv7a-cros-linux-gnueabi.tar.xz to successfully build chrome for daisy (simple-chrome).
CQ-DEPEND=CL:362682

Change-Id: I814434d878b3281a9c31b081347980af904235cd
Reviewed-on: https://chromium-review.googlesource.com/362608
Commit-Ready: Luis Lozano <llozano@chromium.org>
Tested-by: Luis Lozano <llozano@chromium.org>
Reviewed-by: Luis Lozano <llozano@chromium.org>

[modify] https://crrev.com/f778b1f9f606d4448aa6569dd0b051f2af22f750/cli/cros/cros_chrome_sdk.py

Project Member

Comment 2 by bugdroid1@chromium.org, Jul 27 2016

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

commit a8127bb7fb34a4fcc2d72fab07961b08b647c101
Author: Rahul Chaudhry <rahulchaudhry@chromium.org>
Date: Fri Jul 22 22:53:17 2016

Fix wrapper shell scripts and symlinks for invoking clang++

In a typical installation, clang++ symlinks to clang, which symlinks to the
elf executable. The executable distinguishes between clang and clang++ based
on argv[0].

When invoked through the LdsoWrapper, argv[0] always contains the path to the
executable elf file, making clang/clang++ invocations indistinguishable.

This CL adjusts the symlinks and wrappers so clang++ invocation works correctly.

BUG= chromium:628524 
TEST='cros_setup_toolchains --create-packages -t x86_64-cros-linux-gnu'
TEST=Used x86_64-cros-linux-gnu.tar.xz to successfully build chrome for panther (simple-chrome).
TEST='cros_setup_toolchains --create-packages -t i686-pc-linux-gnu'
TEST=Used i686-pc-linux-gnu.tar.xz to successfully build chrome for x86-zgb (simple-chrome).
TEST='cros_setup_toolchains --create-packages -t armv7a-cros-linux-gnueabi'
TEST=Used armv7a-cros-linux-gnueabi.tar.xz to successfully build chrome for daisy (simple-chrome).

Change-Id: Id2ecb65b99226b65a3da4197c09eda28c5fdefca
Reviewed-on: https://chromium-review.googlesource.com/362682
Commit-Ready: Luis Lozano <llozano@chromium.org>
Tested-by: Luis Lozano <llozano@chromium.org>
Reviewed-by: Luis Lozano <llozano@chromium.org>

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

Status: Fixed (was: Assigned)
the shell scripts & ld.so indirection are needed for the standalone toolchains to actually be standalone, otherwise the version of glibc used would be the host one which would be bad.

i think this is another argv[0] issue that should be fixed by the patch i sent uptsream:
  https://sourceware.org/ml/libc-alpha/2016-04/msg00576.html

i need to finish that up and then we can revert that CL.
Sounds good (I assume you mean reverting this CL and adding the new --argv0 flag in the LdsoWrappers).

Feel free to reopen this issue when the new Ldso is available.

Blocking: 537368
Labels: VerifyIn-54
Status: Verified (was: Fixed)
bulk verified

Sign in to add a comment