[PATCH] lld: handling of -flavor / -core command line switches
Oleg Ranevskyy
llvm.mail.list at gmail.com
Wed Sep 17 13:03:27 PDT 2014
>>! In D5384#8, @kledzik wrote:
> The original design was that -flavor had to be the first arg (so incrementing argv worked). But now the use of ParseArgs() means that -flavor is being searched for everywhere in the arg list. That is a mismatch.
This is not always under direct user's control, unfortunately. I encountered this problem trying to build Boost with clang/lld using Boost.Build. I am passing arguments to the linker by using the -Xlinker option. -flavor doesn't go first in the lld's command line in my case.
Even if it was the first argument, the algorithm would still malfunction. Assume we have the following command: /some/path/lld -flavor gnu -llib... When lld meets -flavor it does this to skip the switch:
argv += 2;
argc -= 2;
Looks ok, but argv[0] is actually "/some/path/lld", not "-flavor"! After this operation we end up with the command line "gnu -llib...". This malformed line is then passed to GnuLdDriver. The reason GnuLdDriver does not fail on it is mere luck. GnuLdDriver expects argv[0] ("gnu" in our case) to be the program name and skips it :-)
http://reviews.llvm.org/D5384
More information about the llvm-commits
mailing list