New issue
Advanced search Search tips

Issue 616082 link

Starred by 2 users

Issue metadata

Status: Archived
Owner: ----
Closed: Jul 2017
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Linker issue due to sysroot_ld_path.py returning empty string for linker search paths (-L and -Wl,-rpath-link)

Reported by milko.le...@imgtec.com, May 31 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

Steps to reproduce the problem:
1. gn gen out_gn/mips --args="is_debug=false target_os=\"linux\" target_cpu=\"mipsel\" is_clang=true mips_arch_variant=\"r2\""
2. ninja -j4 -C out_gn/mips chrome 

What is the expected behavior?
Target chrome is built.

What went wrong?
Linker errors reported:

./src/build/linux/debian_wheezy_mips-sysroot/usr/lib/gcc/mipsel-linux-gnu/4.6/../../../mipsel-linux-gnu/crtn.o
libpcre.so.3 needed by ./src/build/linux/debian_wheezy_mips-sysroot/usr/lib/gcc/mipsel-linux-gnu/4.6/../../../mipsel-linux-gnu/libglib-2.0.so
mipsel-linux-gnu-ld: warning: libpcre.so.3, needed by ./src/build/linux/debian_wheezy_mips-sysroot/usr/lib/gcc/mipsel-linux-gnu/4.6/../../../mipsel-linux-gnu/libglib-2.0.so, not found (try using -rpath or -rpath-link)

Did this work before? No 

Chrome version: r396700  Channel: dev
OS Version: Debian Jessie
Flash Version: 

This issue can be reproduced on x86_64 Chromium Linux when bundled ld.bfd is used.
 
This issue can be seen at buildbot:

http://www.rt-rk.com/mips-buildbot/builders/Chromium_linux_GN/builds/648/steps/Build%20Chromium/logs/stdio

Analysis shown that there are several issues contributing to this linker failure:

sysroot_ld_path.py called from build/config/posix/BUILD.gn should populate ldflags with "-L" and "-Wl,-rpath-link" paths from build/linux/debian_wheezy_mips-sysroot/etc/ld.so.conf.d/mipsel-linux-gnu.conf, but it returns empty string.

This is caused by sysroot argument being equal to "//build/linux/debian_wheezy_mips-sysroot" which then in sysroot_ld_path.sh will be concatenated with "/etc/ld.so.conf.d" and resulting path will not exist.
Solution for this could be to provide absolute path using rebase_path(sysroot) in build/config/posix/BUILD.gn.

Fixing this issue leads to another. Content of mipsel-linux-gnu.conf is:

# Multiarch support
/lib/mipsel-linux-gnu
/usr/lib/mipsel-linux-gnu

so, resulting -L and -Wl,-rpath-link= lines should be:

-L<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/lib/mipsel-linux-gnu
-Wl,-rpath-link=<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/lib/mipsel-linux-gnu
-L<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/usr/lib/mipsel-linux-gnu
-Wl,-rpath-link=<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/usr/lib/mipsel-linux-gnu

and these lines are assigned to ldflags in build/config/posix/BUILD.gn as one string:

ldflags += [ "-L<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/lib/mipsel-linux-gnu -Wl,-rpath-link=<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/lib/mipsel-linux-gnu -L<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/usr/lib/mipsel-linux-gnu -Wl,-rpath-link=<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/usr/lib/mipsel-linux-gnu" ]

Issue with this is that GN does not support separating multiple arguments with space, but expects newline instead.
And this then results in incorrect paths used in generated ninja files.

For example:

-L/<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/lib/mipsel-linux-gnu\$ -Wl,-rpath-link=<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/lib/mipsel-linux-gnu\$ -L<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/usr/lib/mipsel-linux-gnu\$ -Wl,-rpath-link=<CHROMIUM_PATH>/src/build/linux/debian_wheezy_mips-sysroot/usr/lib/mipsel-linux-gnu

These paths are not recognized by the linker, and it can not locate libpcre.so.3



Proposed solution at https://codereview.chromium.org/2025883002/ which:

1. uses absolute path for sysroot in build/config/posix/BUILD.gn
2. formats return value in sysroot_ld_path.py as list of strings so that it is compliant with GN rules
Labels: Te-NeedsFurtherTriage
Project Member

Comment 4 by bugdroid1@chromium.org, Jun 1 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/75522f446b904fb6a68ed38a02ed4ff8aa321188

commit 75522f446b904fb6a68ed38a02ed4ff8aa321188
Author: milko.leporis <milko.leporis@imgtec.com>
Date: Wed Jun 01 08:54:59 2016

[MIPS] Fix issue with sysroot_ld_path.py returning empty string

This change fixes ld.bfd failure when GN is used,
which was caused by missing "-Wl,-rpath-link=" path.

BUG= 616082 
TEST=Build Chromium for Linux MIPS using ld.bfd and GN

Review-Url: https://codereview.chromium.org/2025883002
Cr-Commit-Position: refs/heads/master@{#397086}

[modify] https://crrev.com/75522f446b904fb6a68ed38a02ed4ff8aa321188/build/config/posix/BUILD.gn
[modify] https://crrev.com/75522f446b904fb6a68ed38a02ed4ff8aa321188/build/config/posix/sysroot_ld_path.py

Labels: Build
Project Member

Comment 6 by sheriffbot@chromium.org, Jul 14 2017

Status: Archived (was: Unconfirmed)
Issue has not been modified or commented on in the last 365 days, please re-open or file a new bug if this is still an issue.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot

Sign in to add a comment