Bug 19510 - clang invalid library path when compiling with profiling enabled
Summary: clang invalid library path when compiling with profiling enabled
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Thierry Vignaud
QA Contact:
URL: http://llvm.org
Whiteboard:
Keywords: NEEDINFO
Depends on:
Blocks:
 
Reported: 2016-10-02 19:51 CEST by Giuseppe Ghibò
Modified: 2016-10-04 17:59 CEST (History)
2 users (show)

See Also:
Source RPM: compiler-rt-3.8.1-2.mga6.src.rpm
CVE:
Status comment:


Attachments
patch to fix path for library libclang_rt.profile-x86_64.a (734 bytes, patch)
2016-10-02 19:52 CEST, Giuseppe Ghibò
Details | Diff

Description Giuseppe Ghibò 2016-10-02 19:51:31 CEST
clang doesn't find the appropriate libclang_rt.profile when compiling with profiling enabled.

Step to reproduce:

1) Create a simple C program, e.g. prova.c, then compile it with profiling enabled:

clang -o prova -fprofile-generate prova.c

it would result in an invalid path for the library libclang_rt.profile-x86_64.a:

/bin/ld: cannot find /usr/bin/../lib64/clang/3.8.1/lib/linux/libclang_rt.profile-x86_64.a: No such file or directory
clang-3.8: error: linker command failed with exit code 1 (use -v to see invocation)

The library exists, but it's located in /usr/lib64/clang/3.8.1/lib/libclang_rt.profile-x86_64.a rather than  /usr/lib64/clang/3.8.1/lib/linux/libclang_rt.profile-x86_64.a; the attached patch fix the problem.
Comment 1 Giuseppe Ghibò 2016-10-02 19:52:54 CEST
Created attachment 8480 [details]
patch to fix path for library libclang_rt.profile-x86_64.a
Rémi Verschelde 2016-10-03 22:09:20 CEST

Assignee: bugsquad => basesystem

Rémi Verschelde 2016-10-03 22:09:51 CEST

CC: (none) => basesystem
Assignee: basesystem => thierry.vignaud

Comment 2 Thierry Vignaud 2016-10-03 23:03:21 CEST
We follow FC.
Does it work with FC24?

Keywords: (none) => NEEDINFO

Comment 3 Giuseppe Ghibò 2016-10-03 23:18:57 CEST
I've not tried with FC24, but if you try with a simple C file, even this

#include <stdio.h>
int main()
{printf("hello\n");}

it would give the error above, while applying the patch included here would work. Regards FC24, I've not tried there, but I doubt it works there too if they don't changed the path (unless they installed directly in /usr/lib or /usr/lib64), as to use lib/linux/* is hardcoded in the compiler-rt sources.
Comment 4 Rémi Verschelde 2016-10-03 23:24:18 CEST
Could you give it a try on FC24 Neal?

CC: (none) => ngompa13

Comment 5 Neal Gompa 2016-10-03 23:39:39 CEST
On Fedora 24, I've tested with the following packages installed:

clang-3.8.0-2.fc24
compiler-rt-3.8.0-2.fc24

(Note that compiler-rt had to be installed separately)

The test case mentioned (using the sample code) works.

[~]$ clang test-hello-clang.c -o test-hello-clang -fprofile-generate

The program runs too.
[~]$ ./test-hello-clang
hello

If I don't have compiler-rt installed, I get the error mentioned earlier.
Comment 6 Neal Gompa 2016-10-03 23:41:26 CEST
Oh, and for verification purposes, this is what Fedora's compiler-rt has:

[~]$ rpm -qil compiler-rt
Name        : compiler-rt
Version     : 3.8.0
Release     : 2.fc24
Architecture: x86_64
Install Date: Mon 03 Oct 2016 05:36:43 PM EDT
Group       : Unspecified
Size        : 12704494
License     : NCSA or MIT
Signature   : RSA/SHA256, Wed 04 May 2016 08:06:44 AM EDT, Key ID 73bde98381b46521
Source RPM  : compiler-rt-3.8.0-2.fc24.src.rpm
Build Date  : Tue 03 May 2016 04:10:33 PM EDT
Build Host  : buildhw-10.phx2.fedoraproject.org
Relocations : (not relocatable)
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://llvm.org
Summary     : LLVM "compiler-rt" runtime libraries
Description :
The compiler-rt project is a part of the LLVM project. It provides
implementation of the low-level target-specific hooks required by
code generation, sanitizer runtimes and profiling library for code
instrumentation, and Blocks C language extension.
/usr/include/sanitizer
/usr/include/sanitizer/allocator_interface.h
/usr/include/sanitizer/asan_interface.h
/usr/include/sanitizer/common_interface_defs.h
/usr/include/sanitizer/coverage_interface.h
/usr/include/sanitizer/dfsan_interface.h
/usr/include/sanitizer/linux_syscall_hooks.h
/usr/include/sanitizer/lsan_interface.h
/usr/include/sanitizer/msan_interface.h
/usr/include/sanitizer/tsan_interface_atomic.h
/usr/lib64/clang/3.8.0
/usr/lib64/clang/3.8.0/asan_blacklist.txt
/usr/lib64/clang/3.8.0/cfi_blacklist.txt
/usr/lib64/clang/3.8.0/dfsan_abilist.txt
/usr/lib64/clang/3.8.0/lib
/usr/lib64/clang/3.8.0/lib/libclang_rt.asan-preinit-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.asan-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.asan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.asan-x86_64.so
/usr/lib64/clang/3.8.0/lib/libclang_rt.asan_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.asan_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.builtins-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.cfi-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.cfi_diag-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.dd-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.dfsan-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.dfsan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.dyndd-x86_64.so
/usr/lib64/clang/3.8.0/lib/libclang_rt.lsan-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.msan-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.msan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.msan_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.msan_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.profile-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.safestack-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.tsan-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.tsan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.tsan_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.tsan_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.ubsan_standalone-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.ubsan_standalone-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/libclang_rt.ubsan_standalone_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/libclang_rt.ubsan_standalone_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.asan-preinit-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.asan-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.asan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.asan-x86_64.so
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.asan_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.asan_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.builtins-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.cfi-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.cfi_diag-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.dd-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.dfsan-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.dfsan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.dyndd-x86_64.so
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.lsan-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.msan-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.msan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.msan_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.msan_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.profile-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.safestack-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.tsan-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.tsan-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.tsan_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.tsan_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.ubsan_standalone-x86_64.a.syms
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a
/usr/lib64/clang/3.8.0/lib/linux/libclang_rt.ubsan_standalone_cxx-x86_64.a.syms
/usr/lib64/clang/3.8.0/msan_blacklist.txt
Comment 7 Giuseppe Ghibò 2016-10-03 23:57:39 CEST
in fact FC24 installs the libraries into lib/linux, as with the suggested patch.
Comment 8 Giuseppe Ghibò 2016-10-03 23:58:46 CEST
or to be precise they install in both /usr/lib64/clang/3.8.0/lib/ and /usr/lib64/clang/3.8.0/lib/linux/ (a soft link?).
Comment 9 Neal Gompa 2016-10-04 00:00:07 CEST
Here's the Fedora spec for compiler-rt: http://pkgs.fedoraproject.org/cgit/rpms/compiler-rt.git/tree/compiler-rt.spec

It looks like they do some stuff to make that work...
Comment 10 Giuseppe Ghibò 2016-10-04 00:07:03 CEST
yep, seems FC24 is using a soft link to place the libraries in both places 
(so at least once would hit). I thought to the double softlinking solution, but then looking at the code I realized that one place (the one with lib/linux) is enough, as the other won't never be reached anyway.
Comment 11 Thierry Vignaud 2016-10-04 08:20:59 CEST
Please try compiler-rt-3.8.1-2.mga6
Comment 12 Giuseppe Ghibò 2016-10-04 17:57:14 CEST
Yes, compiler-rt-3.8.1-2.mga6 works.
Comment 13 Thierry Vignaud 2016-10-04 17:59:28 CEST
Closing then

Status: NEW => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.