You are not logged in.

#1 2018-01-06 11:49:54

TJM
Member
Registered: 2016-09-18
Posts: 118

Any package provides header files for clang without gcc?

Hi there,

It seems that clang have no header files in its search path if I add `-stdlib=c++` to compile command.

[tjm@ArchPad tmp]$ clang++ poc.cc -v -std=c++1y -stdlib=libc++ 
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/7.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/7.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-5.0" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name poc.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib/clang/5.0.1 -internal-isystem /usr/local/include -internal-isystem /usr/lib/clang/5.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++1y -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 136 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/poc-2b3b8c.o -x c++ poc.cc
clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/clang/5.0.1/include
 /usr/include
End of search list.
poc.cc:1:9: fatal error: 'iostream' file not found
#include<iostream>
        ^~~~~~~~~~
1 error generated.
[tjm@ArchPad tmp]$ 

However, it success without using this option:

[tjm@ArchPad tmp]$ clang++ poc.cc -v -std=c++1y 
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-pc-linux-gnu/7.2.1
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-pc-linux-gnu/7.2.1
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/4.9.4
Found candidate GCC installation: /usr/lib64/gcc/x86_64-pc-linux-gnu/7.2.1
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
 "/usr/bin/clang-5.0" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name poc.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -v -dwarf-column-info -debugger-tuning=gdb -resource-dir /usr/lib/clang/5.0.1 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1 -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/x86_64-pc-linux-gnu -internal-isystem /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/backward -internal-isystem /usr/local/include -internal-isystem /usr/lib/clang/5.0.1/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++1y -fdeprecated-macro -fdebug-compilation-dir /tmp -ferror-limit 19 -fmessage-length 136 -stack-protector 2 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/poc-10ea96.o -x c++ poc.cc
clang -cc1 version 5.0.1 based upon LLVM 5.0.1 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1
 /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/x86_64-pc-linux-gnu
 /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../include/c++/7.2.1/backward
 /usr/local/include
 /usr/lib/clang/5.0.1/include
 /usr/include
End of search list.
 "/usr/bin/ld" -pie --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../lib64/Scrt1.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../lib64/crti.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/crtbeginS.o -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../lib64 -L/usr/bin/../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../.. -L/usr/bin/../lib -L/lib -L/usr/lib /tmp/poc-10ea96.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/crtendS.o /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/7.2.1/../../../../lib64/crtn.o
[tjm@ArchPad tmp]$ echo $?
0
[tjm@ArchPad tmp]$ 

According to the output log and Clang official documents, it seems that this option prevent clang from using gcc's header files.
So, I wonder whether there's any packages provides c++ headers for clang without gcc?

Offline

#2 2018-01-06 11:52:05

TJM
Member
Registered: 2016-09-18
Posts: 118

Re: Any package provides header files for clang without gcc?

And here comes poc.cc

#include<iostream>
#include<string>

using namespace std;

int main(){
	string greeting("Hello world!");
	cout << greeting << endl;
	return 0;
}

Offline

#3 2018-01-06 12:18:04

progandy
Member
Registered: 2012-05-17
Posts: 5,322

Re: Any package provides header files for clang without gcc?

the GNU standard library for c++ is part of gcc, so if you don't want to use it, you'll probably have to try an alternative implementation like libc++ or stlport from the AUR.

Edit: libc++ is part of the LLVM project, so that is probably the one most closely related to clang.

Last edited by progandy (2018-01-06 13:32:38)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#4 2018-01-06 12:21:19

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: Any package provides header files for clang without gcc?

clang is a compiler.  Headers are associated with libaries.  For the c library, you use the headers for the libc implementation you are using, so one set of headers comes with glibc, another with musl, others with uclibc, dietlibc, etc.

For C++ I don't know of any alternative libstdc++ implementations.  GNU bundles libstdc++ with their compiler (which is just odd to me), but clang is an alternative compiler, not an alternative libc(++).

So don't look just for headers as they will not do any good, look for alternative libc++ implementations.

EDIT: beaten to it by Progandy who has pointed to some alternative libstdc++ implementations.

Last edited by Trilby (2018-01-06 12:22:31)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2018-01-06 14:40:51

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,558

Re: Any package provides header files for clang without gcc?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

Board footer

Powered by FluxBB