Quantcast

getting clang to find non-default libstdc++

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

getting clang to find non-default libstdc++

Nathan Ridge

Hello,

I am trying to use clang for the first time, on Ubuntu 10.04.

The default compiler on Ubuntu 10.04 is GCC 4.4, but I've built
GCC 4.7 from source and use it to compile C++11 programs.

Clang finds GCC 4.4's libstdc++ no problem, but I need it to
use GCC 4.7's libstdc++ because my program uses standard
library features that have been added between GCC 4.4 and 4.7.
How do I direct clang to find the 4.7 libstdc++?

I saw the following instructions on the "Get Started" page:

"If Clang cannot find your system libstdc++ headers, please
follow these instructions:
 - 'gcc -v -x c++ /dev/null -fsyntax-only' to get the
   path.
 - Look for the comment "FIXME: temporary hack:
   hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp
   and change the lines below to include that path"

Is that the only way? Having to recompile the compiler to get
it to find a different standard library seems a bit excessive...
shouldn't one be able to switch standard libraries without
recompiling the compiler?

Thanks,
Nate
     
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Rafael Espíndola
On 27 April 2012 15:07, Nathan Ridge <[hidden email]> wrote:

>
> Hello,
>
> I am trying to use clang for the first time, on Ubuntu 10.04.
>
> The default compiler on Ubuntu 10.04 is GCC 4.4, but I've built
> GCC 4.7 from source and use it to compile C++11 programs.
>
> Clang finds GCC 4.4's libstdc++ no problem, but I need it to
> use GCC 4.7's libstdc++ because my program uses standard
> library features that have been added between GCC 4.4 and 4.7.
> How do I direct clang to find the 4.7 libstdc++?
>
> I saw the following instructions on the "Get Started" page:
>
> "If Clang cannot find your system libstdc++ headers, please
> follow these instructions:
>  - 'gcc -v -x c++ /dev/null -fsyntax-only' to get the
>    path.
>  - Look for the comment "FIXME: temporary hack:
>    hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp
>    and change the lines below to include that path"
>
> Is that the only way? Having to recompile the compiler to get
> it to find a different standard library seems a bit excessive...
> shouldn't one be able to switch standard libraries without
> recompiling the compiler?

Those comments are a bit out of date for linux.  You should be able to
configure clang with --with-gcc-toolchain pointing to where you
install g++ 4.7.

> Thanks,
> Nate
>

Cheers,
Rafael

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Marc Glisse
In reply to this post by Nathan Ridge
On Fri, 27 Apr 2012, Nathan Ridge wrote:

> Hello,
>
> I am trying to use clang for the first time, on Ubuntu 10.04.
>
> The default compiler on Ubuntu 10.04 is GCC 4.4, but I've built
> GCC 4.7 from source and use it to compile C++11 programs.
>
> Clang finds GCC 4.4's libstdc++ no problem, but I need it to
> use GCC 4.7's libstdc++ because my program uses standard
> library features that have been added between GCC 4.4 and 4.7.
> How do I direct clang to find the 4.7 libstdc++?
>
> I saw the following instructions on the "Get Started" page:
>
> "If Clang cannot find your system libstdc++ headers, please
> follow these instructions:
>  - 'gcc -v -x c++ /dev/null -fsyntax-only' to get the
>    path.
>  - Look for the comment "FIXME: temporary hack:
>    hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp
>    and change the lines below to include that path"
>
> Is that the only way? Having to recompile the compiler to get
> it to find a different standard library seems a bit excessive...
> shouldn't one be able to switch standard libraries without
> recompiling the compiler?

Yes, of course. Finding the standard library is no magic, you can simply
add some -isystem, -L, and possibly -Wl,-rpath arguments to clang++ when
using it. Use the -v option to see what clang is using by default, so you
can just add the same with s/4.4/4.7/g. If clang puts one of its own
directories first (before the gcc ones), be sure to specify it again
yourself so it still ends up first. You can even try some flags like
-nostdinc++ to clean up a bit (again, check with -v that the list makes
sense).

--
Marc Glisse
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Chandler Carruth
In reply to this post by Rafael Espíndola
On Fri, Apr 27, 2012 at 2:14 PM, Rafael Espíndola <[hidden email]> wrote:
On 27 April 2012 15:07, Nathan Ridge <[hidden email]> wrote:
>
> Hello,
>
> I am trying to use clang for the first time, on Ubuntu 10.04.
>
> The default compiler on Ubuntu 10.04 is GCC 4.4, but I've built
> GCC 4.7 from source and use it to compile C++11 programs.
>
> Clang finds GCC 4.4's libstdc++ no problem, but I need it to
> use GCC 4.7's libstdc++ because my program uses standard
> library features that have been added between GCC 4.4 and 4.7.
> How do I direct clang to find the 4.7 libstdc++?
>
> I saw the following instructions on the "Get Started" page:
>
> "If Clang cannot find your system libstdc++ headers, please
> follow these instructions:
>  - 'gcc -v -x c++ /dev/null -fsyntax-only' to get the
>    path.
>  - Look for the comment "FIXME: temporary hack:
>    hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp
>    and change the lines below to include that path"
>
> Is that the only way? Having to recompile the compiler to get
> it to find a different standard library seems a bit excessive...
> shouldn't one be able to switch standard libraries without
> recompiling the compiler?

Those comments are a bit out of date for linux.  You should be able to
configure clang with --with-gcc-toolchain pointing to where you
install g++ 4.7.

Or if you install Clang alongside the gcc 4.7 installation, it should Just Work without any further action. We look adjacent to the clang binaries for a companion GCC installation specifically to support this (quite common) use case.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Nathan Ridge
In reply to this post by Rafael Espíndola

> > I am trying to use clang for the first time, on Ubuntu 10.04.
> >
> > The default compiler on Ubuntu 10.04 is GCC 4.4, but I've built
> > GCC 4.7 from source and use it to compile C++11 programs.
> >
> > Clang finds GCC 4.4's libstdc++ no problem, but I need it to
> > use GCC 4.7's libstdc++ because my program uses standard
> > library features that have been added between GCC 4.4 and 4.7.
> > How do I direct clang to find the 4.7 libstdc++?
> >
> > I saw the following instructions on the "Get Started" page:
> >
> > "If Clang cannot find your system libstdc++ headers, please
> > follow these instructions:
> >  - 'gcc -v -x c++ /dev/null -fsyntax-only' to get the
> >    path.
> >  - Look for the comment "FIXME: temporary hack:
> >    hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp
> >    and change the lines below to include that path"
> >
> > Is that the only way? Having to recompile the compiler to get
> > it to find a different standard library seems a bit excessive...
> > shouldn't one be able to switch standard libraries without
> > recompiling the compiler?
>
> Those comments are a bit out of date for linux. You should be able to
> configure clang with --with-gcc-toolchain pointing to where you
> install g++ 4.7.
Thanks! I think the webpage should be updated to reflect this.
I attached a patch.

Regards,
Nate
     
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

find-libstdc++.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Chandler Carruth
On Sat, Apr 28, 2012 at 11:57 PM, Nathan Ridge <[hidden email]> wrote:

> > I am trying to use clang for the first time, on Ubuntu 10.04.
> >
> > The default compiler on Ubuntu 10.04 is GCC 4.4, but I've built
> > GCC 4.7 from source and use it to compile C++11 programs.
> >
> > Clang finds GCC 4.4's libstdc++ no problem, but I need it to
> > use GCC 4.7's libstdc++ because my program uses standard
> > library features that have been added between GCC 4.4 and 4.7.
> > How do I direct clang to find the 4.7 libstdc++?
> >
> > I saw the following instructions on the "Get Started" page:
> >
> > "If Clang cannot find your system libstdc++ headers, please
> > follow these instructions:
> >  - 'gcc -v -x c++ /dev/null -fsyntax-only' to get the
> >    path.
> >  - Look for the comment "FIXME: temporary hack:
> >    hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp
> >    and change the lines below to include that path"
> >
> > Is that the only way? Having to recompile the compiler to get
> > it to find a different standard library seems a bit excessive...
> > shouldn't one be able to switch standard libraries without
> > recompiling the compiler?
>
> Those comments are a bit out of date for linux. You should be able to
> configure clang with --with-gcc-toolchain pointing to where you
> install g++ 4.7.

Thanks! I think the webpage should be updated to reflect this.
I attached a patch.

Can you mention that in general, Clang should automatically detect the best version of libstdc++ headers available and use them, and that it will look both for system installations of libstdc++ as well as installations adjacent to clang itself?

The --with-gcc-toolchain should really be a fallback for when the configuration is quite strange.
 

Regards,
Nate
                                         
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Nathan Ridge

>  > > I am trying to use clang for the first time, on Ubuntu 10.04.
>  > >
>  > > The default compiler on Ubuntu 10.04 is GCC 4.4, but I've built
>  > > GCC 4.7 from source and use it to compile C++11 programs.
>  > >
>  > > Clang finds GCC 4.4's libstdc++ no problem, but I need it to
>  > > use GCC 4.7's libstdc++ because my program uses standard
>  > > library features that have been added between GCC 4.4 and 4.7.
>  > > How do I direct clang to find the 4.7 libstdc++?
>  > >
>  > > I saw the following instructions on the "Get Started" page:
>  > >
>  > > "If Clang cannot find your system libstdc++ headers, please
>  > > follow these instructions:
>  > >  - 'gcc -v -x c++ /dev/null -fsyntax-only' to get the
>  > >    path.
>  > >  - Look for the comment "FIXME: temporary hack:
>  > >    hard-coded paths" in clang/lib/Frontend/InitHeaderSearch.cpp
>  > >    and change the lines below to include that path"
>  > >
>  > > Is that the only way? Having to recompile the compiler to get
>  > > it to find a different standard library seems a bit excessive...
>  > > shouldn't one be able to switch standard libraries without
>  > > recompiling the compiler?
>  >
>  > Those comments are a bit out of date for linux. You should be able to
>  > configure clang with --with-gcc-toolchain pointing to where you
>  > install g++ 4.7.
>  
> Thanks! I think the webpage should be updated to reflect this.
> I attached a patch.
>  
> Can you mention that in general, Clang should automatically detect the  
> best version of libstdc++ headers available and use them, and that it  
> will look both for system installations of libstdc++ as well as  
> installations adjacent to clang itself?
>  
> The --with-gcc-toolchain should really be a fallback for when the  
> configuration is quite strange.
You callin' my configuration strange? ;)

Updated patch is attached.

Regards,
Nate
     
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

find-libstdc++.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Rafael Espíndola
> You callin' my configuration strange? ;)
>
> Updated patch is attached.

Linux, which was the main user of the "temporary hack", is fixed, so I
think this is OK. Chandler?

> Regards,
> Nate

Cheers,
Rafael
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Chandler Carruth
On Sun, Apr 29, 2012 at 6:47 AM, Rafael Espíndola <[hidden email]> wrote:
> You callin' my configuration strange? ;)
>
> Updated patch is attached.

Linux, which was the main user of the "temporary hack", is fixed, so I
think this is OK. Chandler?

LGTM

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Nathan Ridge


> On Sun, Apr 29, 2012 at 6:47 AM, Rafael Espíndola
>  wrote:
> > You callin' my configuration strange? ;)
> >
> > Updated patch is attached.
>
> Linux, which was the main user of the "temporary hack", is fixed, so I
> think this is OK. Chandler?
>
> LGTM

Could someone commit it then?

Thanks,
Nate
     
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Chandler Carruth
On Tue, May 15, 2012 at 11:27 PM, Nathan Ridge <[hidden email]> wrote:


> On Sun, Apr 29, 2012 at 6:47 AM, Rafael Espíndola
>  wrote:
> > You callin' my configuration strange? ;)
> >
> > Updated patch is attached.
>
> Linux, which was the main user of the "temporary hack", is fixed, so I
> think this is OK. Chandler?
>
> LGTM

Could someone commit it then?

Committed in r156911, thanks!

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Marc J. Driftmeyer
From Trunk on Debian Linux after including the update of libcxx and compile-rt under clang/runtime:
-- Clang version: 3.2
CMake Error at tools/clang/runtime/compiler-rt/CMakeLists.txt:48 (add_subdirectory):
  The source directory

    /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/tools/clang/runtime/compiler-rt/test

  does not contain a CMakeLists.txt file.


-- Host triple: x86_64-pc-linux
-- Target triple: x86_64-pc-linux
-- Target triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Configuring incomplete, errors occurred!
mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-clang-llvm$

- Marc

On 05/16/2012 01:20 AM, Chandler Carruth wrote:
On Tue, May 15, 2012 at 11:27 PM, Nathan Ridge <[hidden email]> wrote:


> On Sun, Apr 29, 2012 at 6:47 AM, Rafael Espíndola
>  wrote:
> > You callin' my configuration strange? ;)
> >
> > Updated patch is attached.
>
> Linux, which was the main user of the "temporary hack", is fixed, so I
> think this is OK. Chandler?
>
> LGTM

Could someone commit it then?

Committed in r156911, thanks!


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

--
Marc J. Driftmeyer
Email :: [hidden email]
Web :: http://www.reanimality.com
Cell :: (509) 435-5212

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

mjd.vcf (434 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Chandler Carruth
I dunno what this error is, will look into it more depth later, but the patch I committed only touched documentation, so it seems unlikely to have caused this. I suspect these are independent issues.

On Wed, May 16, 2012 at 3:50 AM, Marc J. Driftmeyer <[hidden email]> wrote:
From Trunk on Debian Linux after including the update of libcxx and compile-rt under clang/runtime:
-- Clang version: 3.2
CMake Error at tools/clang/runtime/compiler-rt/CMakeLists.txt:48 (add_subdirectory):
  The source directory

    /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/tools/clang/runtime/compiler-rt/test

  does not contain a CMakeLists.txt file.


-- Host triple: x86_64-pc-linux
-- Target triple: x86_64-pc-linux
-- Target triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Configuring incomplete, errors occurred!
mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-clang-llvm$

- Marc


On 05/16/2012 01:20 AM, Chandler Carruth wrote:
On Tue, May 15, 2012 at 11:27 PM, Nathan Ridge <[hidden email]> wrote:


> On Sun, Apr 29, 2012 at 6:47 AM, Rafael Espíndola
>  wrote:
> > You callin' my configuration strange? ;)
> >
> > Updated patch is attached.
>
> Linux, which was the main user of the "temporary hack", is fixed, so I
> think this is OK. Chandler?
>
> LGTM

Could someone commit it then?

Committed in r156911, thanks!


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

--
Marc J. Driftmeyer
Email :: [hidden email]
Web :: http://www.reanimality.com
Cell :: <a href="tel:%28509%29%20435-5212" value="+15094355212" target="_blank">(509) 435-5212

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: getting clang to find non-default libstdc++

Marc J. Driftmeyer
Doing an update on clang pulled in libcxx and compiler-rt.

Removing both today only restores place holders and a Makefile for both compiler-rt and libcxx.

So clearly, something prematurely got injected into both of those paths.

- Marc

On 05/16/2012 06:41 AM, Chandler Carruth wrote:
I dunno what this error is, will look into it more depth later, but the patch I committed only touched documentation, so it seems unlikely to have caused this. I suspect these are independent issues.

On Wed, May 16, 2012 at 3:50 AM, Marc J. Driftmeyer <[hidden email]> wrote:
From Trunk on Debian Linux after including the update of libcxx and compile-rt under clang/runtime:
-- Clang version: 3.2
CMake Error at tools/clang/runtime/compiler-rt/CMakeLists.txt:48 (add_subdirectory):
  The source directory

    /home/mdriftmeyer/DeveloperProjects/LLVMProject/trunk/llvm/tools/clang/runtime/compiler-rt/test

  does not contain a CMakeLists.txt file.


-- Host triple: x86_64-pc-linux
-- Target triple: x86_64-pc-linux
-- Target triple: x86_64-unknown-linux-gnu
-- Native target architecture is X86
-- Threads enabled.
-- Configuring incomplete, errors occurred!
mdriftmeyer@horus:~/DeveloperProjects/LLVMProject/cmake-clang-llvm$

- Marc


On 05/16/2012 01:20 AM, Chandler Carruth wrote:
On Tue, May 15, 2012 at 11:27 PM, Nathan Ridge <[hidden email]> wrote:


> On Sun, Apr 29, 2012 at 6:47 AM, Rafael Espíndola
>  wrote:
> > You callin' my configuration strange? ;)
> >
> > Updated patch is attached.
>
> Linux, which was the main user of the "temporary hack", is fixed, so I
> think this is OK. Chandler?
>
> LGTM

Could someone commit it then?

Committed in r156911, thanks!


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

--
Marc J. Driftmeyer
Email :: [hidden email]
Web :: http://www.reanimality.com
Cell :: <a moz-do-not-send="true" href="tel:%28509%29%20435-5212" value="+15094355212" target="_blank">(509) 435-5212

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



--
Marc J. Driftmeyer
Email :: [hidden email]
Web :: http://www.reanimality.com
Cell :: (509) 435-5212

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

mjd.vcf (434 bytes) Download Attachment
Loading...