Bug 1150985 - Clang does not work; looks for include and lib in a wrong place
Summary: Clang does not work; looks for include and lib in a wrong place
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: llvm
Version: 21
Hardware: aarch64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Peter Robinson
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: ARM64, F-ExcludeArch-aarch64
TreeView+ depends on / blocked
 
Reported: 2014-10-09 11:24 UTC by David Abdurachmanov
Modified: 2015-09-16 13:48 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-09-16 13:48:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description David Abdurachmanov 2014-10-09 11:24:38 UTC
Description of problem:

Clang looks for headers and libraries in a wrong place on AArch64. 

$ clang++ -std=c++11 tc.cc
tt.cc:1:10: fatal error: 'list' file not found
#include <list>
         ^
1 error generated.


How reproducible:

Compile any C++ code, e.g., example from en.cppreference.com

cat << EOF > tc.cc
#include <list>
#include <string>
#include <iostream>
 
template<typename T>
std::ostream& operator<<(std::ostream& s, const std::list<T>& v) {
    s.put('[');
    char comma[3] = {'\0', ' ', '\0'};
    for (const auto& e : v) {
        s << comma << e;
        comma[0] = ',';
    }
    return s << ']';
}
 
int main() 
{
    // c++11 initializer list syntax:
    std::list<std::string> words1 {"the", "frogurt", "is", "also", "cursed"};
    std::cout << "words1: " << words1 << '\n';
 
    // words2 == words1
    std::list<std::string> words2(words1.begin(), words1.end());
    std::cout << "words2: " << words2 << '\n';
 
    // words3 == words1
    std::list<std::string> words3(words1);
    std::cout << "words3: " << words3 << '\n';
 
    // words4 is {"Mo", "Mo", "Mo", "Mo", "Mo"}
    std::list<std::string> words4(5, "Mo");
    std::cout << "words4: " << words4 << '\n';
}
EOF

clang++ -std=c++11 tc.cc

The libraries are installed at /usr/lib/gcc/aarch64-redhat-linux/4.8.1/ When I was debugging Clang driver (on F19) on aarch64 and x86_64 it looked like driver never used GCC version in the paths. Thus is went for /usr/lib/gcc/aarch64-redhat-linux.

For headers defaults:
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/bin/../lib/clang/3.4.1/include
 /usr/include
 /usr/lib/gcc/aarch64-redhat-linux/4.8.1/include
End of search list.

Missing /usr/include/c++/4.8.1

The followed is enough to test lib paths:

int main(void) {
  return 0;
}

Clang fails with:

 "/usr/bin/ld" --hash-style=gnu --no-add-needed --build-id --eh-frame-hdr -m aarch64linux -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out /lib/../lib64/crt1.o /lib/../lib64/crti.o crtbegin.o -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/test-0ff054.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc crtend.o /lib/../lib64/crtn.o
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lstdc++
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc
clang: error: linker command failed with exit code 1 (use -v to see invocation)

While on x86_64 it has /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2

Clang driver logic for finding the paths needs to be reviewed.

Comment 1 Peter Robinson 2014-10-09 12:06:39 UTC
I'm aware of some of these issues. We're awaiting 3.5 to land because there's been some massive improvements and changes for aarch64 in that release.

Comment 2 Peter Robinson 2014-10-09 12:07:47 UTC
> Clang fails with:
> 
>  "/usr/bin/ld" --hash-style=gnu --no-add-needed --build-id --eh-frame-hdr -m
> aarch64linux -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out
> /lib/../lib64/crt1.o /lib/../lib64/crti.o crtbegin.o -L/lib/../lib64
> -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/test-0ff054.o -lstdc++ -lm
> -lgcc_s -lgcc -lc -lgcc_s -lgcc crtend.o /lib/../lib64/crtn.o
> /usr/bin/ld: cannot find crtbegin.o: No such file or directory
> /usr/bin/ld: cannot find -lstdc++
> /usr/bin/ld: cannot find -lgcc_s
> /usr/bin/ld: cannot find -lgcc
> clang: error: linker command failed with exit code 1 (use -v to see
> invocation)
> 
> While on x86_64 it has /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2

What release are you using? F-21 has gcc 4.9.x not 4.8.x

Comment 3 David Abdurachmanov 2014-10-09 12:22:18 UTC
I am still running F19 with Clang 3.4 on the boards, but hrw (IRC) double checked it on F21.

Comment 4 Peter Robinson 2014-10-09 12:25:42 UTC
(In reply to David Abdurachmanov from comment #3)
> I am still running F19 with Clang 3.4 on the boards, but hrw (IRC) double
> checked it on F21.

F-19 isn't supported. Please move to F-21. There are numerous toolchain issues and changes between the two.

Comment 5 Marcin Juszkiewicz 2015-09-16 13:32:14 UTC
15:28 hrw@pinkiepie-rawhide:devel$ clang++ --verbose hello.cc 
clang version 3.6.2 (tags/RELEASE_362/final)
Target: aarch64-redhat-linux-gnu
Thread model: posix
Found candidate GCC installation: /bin/../lib/gcc/aarch64-redhat-linux/5.2.1
Found candidate GCC installation: /usr/lib/gcc/aarch64-redhat-linux/5.2.1
Selected GCC installation: /bin/../lib/gcc/aarch64-redhat-linux/5.2.1
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/usr/bin/clang" -cc1 -triple aarch64-redhat-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name hello.cc -mrelocation-m
odel static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -target-feature +
neon -target-abi aapcs -target-linker-version 2.25 -v -dwarf-column-info -resource-dir /usr/bin/../lib/clang/3.6.2 -internal-isystem /bin/../lib/gcc/aarch
64-redhat-linux/5.2.1/../../../../include/c++/5.2.1 -internal-isystem /bin/../lib/gcc/aarch64-redhat-linux/5.2.1/../../../../include/c++/5.2.1/aarch64-red
hat-linux -internal-isystem /bin/../lib/gcc/aarch64-redhat-linux/5.2.1/../../../../include/c++/5.2.1/backward -internal-isystem /usr/local/include -intern
al-isystem /usr/bin/../lib/clang/3.6.2/include -internal-externc-isystem /usr/include -internal-externc-isystem /usr/lib/gcc/aarch64-redhat-linux/5.1.1/in
clude -fdeprecated-macro -fdebug-compilation-dir /home/hrw/devel -ferror-limit 19 -fmessage-length 154 -mstackrealign -fallow-half-arguments-and-returns -
fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/hello-409df4.o -x c++ hello.cc
clang -cc1 version 3.6.2 based upon LLVM 3.6.2 default target aarch64-redhat-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/aarch64-redhat-linux/5.1.1/include"
#include "..." search starts here:
#include <...> search starts here:
 /bin/../lib/gcc/aarch64-redhat-linux/5.2.1/../../../../include/c++/5.2.1
 /bin/../lib/gcc/aarch64-redhat-linux/5.2.1/../../../../include/c++/5.2.1/aarch64-redhat-linux
 /bin/../lib/gcc/aarch64-redhat-linux/5.2.1/../../../../include/c++/5.2.1/backward
 /usr/local/include
 /usr/bin/../lib/clang/3.6.2/include
 /usr/include
End of search list.

Comment 6 Marcin Juszkiewicz 2015-09-16 13:48:00 UTC
version rawhide has it sorted out

then it crashes - bug 1227460


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