Which linker gcc




















Just testing against a different version of the linker. Olaf: Yes, I know what cc is. This question is specifically about how to tell cc which can execute all build stages with a single invocation of cc how to use a different linker than the one that is specified by default when cc is built.

Maybe you weren't aware that cc can invoke the linker try building a simple C program with cc -v helloworld. Looks like an XY problem. Why do you want to use a different than the default linker? For normal compilation, that should be what you want, for cross-compilation, you should use the appropriate toolchain which also includes the correct linker. Comments are not part of the question. But yes, I oversaw that Basil already suspected the same.

Still, I don't see what your problem is. For any larger program you should use a build-tool anyway and they always allow to specify compiler and linker seperately. Show 7 more comments. Active Oldest Votes. Improve this answer. Martin - Which gcc version? Was your gcc built --with-ld see the footnote? Add a comment. Hopefully this helps people coming from searches, as OP long ago had their question answered.

This is a good find. Sorry that should be split into two lines - I don't know how to do that in a comment. That's nice.

Note that -fuse-ld does not even show up with clang --help. As I mentioned in my answer, this only works in a few special cases. Martin - As asky indicated, the argument to some of the current implementations of -fuse-ld is special. As mentioned in my earlier comment above, for gcc's implementation e. As mentioned, a path works for clang , though.

The answer could be tweaked to make that a little more clear. The default spec is obtained with gcc -dumpspecs Also, by strace 1 -ing some gcc command, you'll find out that it tries to access e. Those spec files are textual, so you should be able to write your own. But I am not sure it is a good idea.

Basile Starynkevitch Basile Starynkevitch k 16 16 gold badges silver badges bronze badges. The -T option is for ld 1 , not for cc 1. I'll look at -specs. Looks like it is gcc-specific. And I agree it doesn't feel like the right solution. The -T option is for gcc — Basile Starynkevitch. If linking is done, these object files are used as input to the linker. See Overall Options. The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.

It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified.

If bar. The linker searches a standard list of directories for the library, which is actually a file named lib library. The linker then uses this file as if it had been specified precisely by name.

The directories searched include several standard system directories plus any that you specify with -L. Normally the files found this way are library files—archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined.

But if the file that is found is an ordinary object file, it is linked in the usual fashion. The standard system libraries are used normally, unless -nostdlib or -nodefaultlibs is used. Only the libraries you specify will be passed to the linker, options specifying linkage of the system libraries, such as -static-libgcc or -shared-libgcc , will be ignored. The standard startup files are used normally, unless -nostartfiles is used. The compiler may generate calls to memcmp , memset , memcpy and memmove.

These entries are usually resolved by entries in libc. These entry points should be supplied through some other mechanism when this option is specified. The command-line options to ld may be specified in any order, and may be repeated at will.

Repeating most options with a different argument will either have no further effect, or override prior occurrences those further to the left on the command line of that option. Options which may be meaningfully specified more than once are noted in the descriptions below. Non-option arguments are objects files which are to be linked together.



0コメント

  • 1000 / 1000