linker argument order

Hi,

there's a quirk in the Sun Studio 12 RC version you distributed at LinuxTag 2007

in Berlin, Germany (Александр Горшенев told me to report any more bugs I find

to this forum).

begin pastetg@odem:~ $ $SP/bin/cc -# -Wl,-dynamic-linker,/usr/libexec/ld.so hello.c

### Note: NLSPATH = /home/.data/tg/suncc/sunstudio12/prod/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/home/.data/tg/suncc/sunstudio12/prod/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat

###command line files and options (expanded):

### -Wl,-dynamic-linker,/usr/libexec/ld.so hello.c

/home/.data/tg/suncc/sunstudio12/prod/bin/acomp -xldscope=global -i hello.c -y-fbe -y/home/.data/tg/suncc/sunstudio12/prod/bin/fbe -y-xarch=generic -y-o -yhello.o -y-verbose -y-xthreadvar=no%dynamic -y-comdat -xdbggen=no%stabs+dwarf2+usedonly -xdbggen=incl -y-s -m32 -fparam_ir -Qy -D__SUNPRO_C=0x590 -D__unix -D__unix__ -D__i386 -D__i386__ -D__linux__ -D__linux -Dlinux -D__gnu__linux__ -D__BUILTIN_VA_ARG_INCR -D__C99FEATURES__ -Xa -D__PRAGMA_REDEFINE_EXTNAME -Dunix -Di386 -D__RESTRICT -xc99=%all,no%lib -D__FLT_EVAL_METHOD__=-1 -c99OS -I/home/.data/tg/suncc/sunstudio12/prod/include/cc"-g/home/.data/tg/suncc/sunstudio12/prod/bin/cc -Wl,-dynamic-linker,/usr/libexec/ld.so -c " -fsimple=0 -D__SUN_PREFETCH -destination_ir=yabe

/home/.data/tg/suncc/sunstudio12/prod/bin/fbe -s -o hello.o -warn=%none -Qy /tmp/yabeevaqyh

rm /tmp/yabeevaqyh

### Note: LD_LIBRARY_PATH = /data/tg/Misc/.home/suncc/sunstudio12/prod/lib/sys:/data/tg/Misc/.home/suncc/sunstudio12/prod/lib

### Note: LD_RUN_PATH = <null>

/usr/bin/ld -dynamic-linker /usr/libexec/ld.so -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 --enable-new-dtags /home/.data/tg/suncc/sunstudio12/prod/lib/crti.o /home/.data/tg/suncc/sunstudio12/prod/lib/crt1.o /home/.data/tg/suncc/sunstudio12/prod/lib/values-xa.o hello.o -Y"/home/.data/tg/suncc/sunstudio12/prod/lib:/lib:/usr/lib" -Qy -lc /home/.data/tg/suncc/sunstudio12/prod/lib/libc_supp.a /home/.data/tg/suncc/sunstudio12/prod/lib/crtn.o

end paste

As you can see, the argument "-dynamic-linker /lib/ld-linux.so.2" overrides the one I

give it on the command line, instead of vice versa (i.e. the other way round).

Also, where is that -Y argument generated from?

Ideally, I would use something like “-Wl,-dynamic-linker,/usr/libexec/ld.so -Wl,-Y,/usr/lib”

to create binaries (for BSD, not for Linux – it works, I just have to create a wrapper around

ld as described in http://marc.info/?m=118099390924175 and in mails to Alexander).

So it'd be nice if the options given on the command line via -Wl (etc.) are appended to

all automatically generated flags, instead of prepended. I'm not quite sure about the

order of the arguments w.r.t the files – maybe the -Y and -Qy arguments should be moved

before the crti.o, and between them and crti.o place the user-given arguments.

Also, is there a kind of “spec file” like gcc or a command line option or whatever to tell

it to use different crt*.o files? At the moment, I'm using “ld -r” to combine our five into the

three the Sun compiler expects.

But still (despite bug 6565674) a great job you have done, thanks!

[3490 byte] By [mirabilosa] at [2007-11-27 6:28:09]
# 1

> As you can see, the argument "-dynamic-linker /lib/ld-linux.so.2" overrides the one I

give it on the command line, instead of vice versa (i.e. the other way round).

Its just a bug in -Wl. All other -Wx options add to the end of the component options line.

> where is that -Y argument generated from?

It is the default path for linking our own compiler libraries. Its just hardcoded in the driver.

> is there a kind of “spec file” like gcc or a command line option or whatever to tell

it to use different crt*.o files?

Sorry, nothing similar to the spec. And I do not expect it to be changed any soon.

regards,

__Fedor.

PS just have filed 6565771bug for -Wl problem

SFVa at 2007-7-12 17:50:31 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
Thanks for the verbose answer and opening that bug report.When -Wl,* is appended, -Y* can be fixed easily via LDFLAGS etc.
mirabilosa at 2007-7-12 17:50:31 > top of Java-index,Development Tools,Solaris and Linux Development Tools...