How to change the linker of clang

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

How to change the linker of clang

eric.lew

1) Build clang with GCC-4.9.2, when compling other application s with clang/clang++, the default linker is ld, can I replace it with other linker tool, if we can, how to do it? 

I.E. can we use collect2 instead?

2) how to specify the  path, if we do not use the default vertion GCC?


Best Regards!
Eric Lew


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] How to change the linker of clang

Nathan Wilson


On Thu, Jun 11, 2015 at 8:31 PM, Eric Lu <[hidden email]> wrote:

1) Build clang with GCC-4.9.2, when compling other application s with clang/clang++, the default linker is ld, can I replace it with other linker tool, if we can, how to do it? 

I.E. can we use collect2 instead?

You could symlink ld to point to collect2.

For example I use gold and point to:
ls -la /usr/local/bin/ld:
/usr/local/bin/ld -> /usr/bin/gold
 

2) how to specify the  path, if we do not use the default vertion GCC?


You can specify which version of GCC when you run cmake by adding the flags:
-DCMAKE_C_COMPILER=<path> -DCMAKE_CXX_COMPILER=<path>



Best Regards!
Eric Lew


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



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] How to change the linker of clang

Nikola Smiljanic
That's what I used to do but each Ubuntu update would revert the symlink. That's when I found about -fuse-ld=gold, I'd expect it to work with other linkers as well.

On Fri, Jun 12, 2015 at 11:52 AM, Nathan Wilson <[hidden email]> wrote:


On Thu, Jun 11, 2015 at 8:31 PM, Eric Lu <[hidden email]> wrote:

1) Build clang with GCC-4.9.2, when compling other application s with clang/clang++, the default linker is ld, can I replace it with other linker tool, if we can, how to do it? 

I.E. can we use collect2 instead?

You could symlink ld to point to collect2.

For example I use gold and point to:
ls -la /usr/local/bin/ld:
/usr/local/bin/ld -> /usr/bin/gold
 

2) how to specify the  path, if we do not use the default vertion GCC?


You can specify which version of GCC when you run cmake by adding the flags:
-DCMAKE_C_COMPILER=<path> -DCMAKE_CXX_COMPILER=<path>



Best Regards!
Eric Lew


_______________________________________________
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



_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: How to change the linker of clang

Sandeep Raju
In reply to this post by eric.lew
The -B option tells clang where to look for the linker. So you could try:

clang -B /path/to/other/linker/ ...

Sandeep

On Thu, Jun 11, 2015 at 6:36 PM Eric Lu <[hidden email]> wrote:

1) Build clang with GCC-4.9.2, when compling other application s with clang/clang++, the default linker is ld, can I replace it with other linker tool, if we can, how to do it? 

I.E. can we use collect2 instead?

2) how to specify the  path, if we do not use the default vertion GCC?


Best Regards!
Eric Lew

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] How to change the linker of clang

Brian Faull
In reply to this post by Nathan Wilson
For #1: Consider also the -B option to specify a path prefix to consult for compiler-related sub-programs (e.g., GNU binutils) if the executables / symlinks etc. have similar names. 

Brian


On Jun 11, 2015, at 21:52, Nathan Wilson <[hidden email]> wrote:



On Thu, Jun 11, 2015 at 8:31 PM, Eric Lu <[hidden email]> wrote:

1) Build clang with GCC-4.9.2, when compling other application s with clang/clang++, the default linker is ld, can I replace it with other linker tool, if we can, how to do it? 

I.E. can we use collect2 instead?

You could symlink ld to point to collect2.

For example I use gold and point to:
ls -la /usr/local/bin/ld:
/usr/local/bin/ld -> /usr/bin/gold
 

2) how to specify the  path, if we do not use the default vertion GCC?


You can specify which version of GCC when you run cmake by adding the flags:
-DCMAKE_C_COMPILER=<path> -DCMAKE_CXX_COMPILER=<path>



Best Regards!
Eric Lew


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


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] How to change the linker of clang

Azat Khuzhin
In reply to this post by Nikola Smiljanic
On Fri, Jun 12, 2015 at 12:30:54PM +1000, Nikola Smiljanic wrote:
> That's what I used to do but each Ubuntu update would revert the symlink.
> That's when I found about -fuse-ld=gold, I'd expect it to work with other
> linkers as well.

Also maybe clang could support -B option like gcc have [1], that allow
you to change prefix for executables and other compiler stuff.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] How to change the linker of clang

Joerg Sonnenberger
On Fri, Jun 12, 2015 at 12:17:04PM +0300, Azat Khuzhin wrote:
> On Fri, Jun 12, 2015 at 12:30:54PM +1000, Nikola Smiljanic wrote:
> > That's what I used to do but each Ubuntu update would revert the symlink.
> > That's when I found about -fuse-ld=gold, I'd expect it to work with other
> > linkers as well.
>
> Also maybe clang could support -B option like gcc have [1], that allow
> you to change prefix for executables and other compiler stuff.

It does.

Joerg
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] How to change the linker of clang

David Chisnall-5
In reply to this post by Nathan Wilson
On 11 Jun 2015, at 21:52, Nathan Wilson <[hidden email]> wrote:

> On Thu, Jun 11, 2015 at 8:31 PM, Eric Lu <[hidden email]> wrote:
> 1) Build clang with GCC-4.9.2, when compling other application s with clang/clang++, the default linker is ld, can I replace it with other linker tool, if we can, how to do it?
>
> I.E. can we use collect2 instead?
>
> You could symlink ld to point to collect2.
>
> For example I use gold and point to:
> ls -la /usr/local/bin/ld:
> /usr/local/bin/ld -> /usr/bin/gold
>  
> 2) how to specify the  path, if we do not use the default vertion GCC?
>
>
> You can specify which version of GCC when you run cmake by adding the flags:
> -DCMAKE_C_COMPILER=<path> -DCMAKE_CXX_COMPILER=<path>

Didn’t we upstream the support for -fuse-ld=foo, which would use ld.foo in your default linker search path, so if you install gold as /usr/bin/ld.gold (as, I believe, is the default), it will work with -fuse-ld=gold?

David


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: [cfe-dev] How to change the linker of clang

Kim Gräsman
Hi David,

On Sat, Jun 13, 2015 at 11:05 PM, David Chisnall
<[hidden email]> wrote:
>
> Didn’t we upstream the support for -fuse-ld=foo, which would use ld.foo in your default linker search path, so if you install gold as /usr/bin/ld.gold (as, I believe, is the default), it will work with -fuse-ld=gold?

I think it happened relatively recently, so dated versions of Clang
might not have it.

I can't remember the details now, but when I set up my FreeBSD 10.1
box, I don't think the bundled Clang had -fuse-ld yet.

- Kim

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev