Passing -r to the linker

Hi,

Is there a good reason why -r is not passed to the linker? There is a line for it in Options.def, but it is not marked as "l" so the linker doesn't see it and things break when you try using it. If this is an oversight, I shall correct it, otherwise please let me know what the correct fix is.

David

It passes it for me:

$ touch t.c
$ clang t.c
Undefined symbols:
   "_main", referenced from:
       start in crt1.10.6.o
ld: symbol(s) not found
$ clang t.c -r -nostdlib -o me

ConstructJob has:

   Args.AddAllArgs(CmdArgs, options::OPT_r);

which is how it works for me. You can add this line to yours... That is simple and easy. Now, as for what's best... I suspect sharing more bits between architectures would be good. This certainly seems like one to share.

Hi,

Is there a good reason why -r is not passed to the linker? There is a
line for it in Options.def, but it is not marked as "l" so the linker
doesn't see it and things break when you try using it. If this is an
oversight, I shall correct it, otherwise please let me know what the
correct fix is.

Note that marking it with "l" is not the correct fix. Think of
Options.def as defining the AST for command lines, thats (hopefully)
target independent. On the other hand, what actually happens to the
"-r" is up to the tool chain and its tools.
"l" is a special flag which changes the driver action more than just
passing the option to the linker. Specifically, its the difference
between: