Skip to content

Commit

Permalink
HBSD: Pull in llvm commit r317358
Browse files Browse the repository at this point in the history
    [llvm-ar] Support an options string that start with a dash

    Some projects call $AR like "$AR -crs output input1 input2".

    Differential Revision: https://reviews.llvm.org/D39538

This fixes a huge gap in the exp-run when the following flags are
set in base:

WITH_LLVM_AR_IS_AR
WITH_LLVM_NM_IS_NM
WITH_LLVM_OBJDUMP_IS_OBJDUMP

We will need to switch to llvm-ar, llvm-nm, and llvm-objdump for
Cross-DSO CFI support.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
Sponsored-by:	SoldierX
  • Loading branch information
lattera committed Dec 13, 2017
1 parent 06fda73 commit a809755
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions contrib/llvm/tools/llvm-ar/llvm-ar.cpp
Expand Up @@ -126,6 +126,8 @@ static cl::extrahelp MoreHelp(
" [v] - be verbose about actions taken\n"
);

static const char OptionChars[] = "dmpqrtxabiosSTucv";

// This enumeration delineates the kinds of operations on an archive
// that are permitted.
enum ArchiveOperation {
Expand Down Expand Up @@ -871,6 +873,24 @@ int main(int argc, char **argv) {
Stem.find("lib") != StringRef::npos)
return libDriverMain(makeArrayRef(argv, argc));

for (int i = 1; i < argc; i++) {
// If an argument starts with a dash and only contains chars
// that belong to the options chars set, remove the dash.
// We can't handle it after the command line options parsing
// is done, since it will error out on an unrecognized string
// starting with a dash.
// Make sure this doesn't match the actual llvm-ar specific options
// that start with a dash.
StringRef S = argv[i];
if (S.startswith("-") &&
S.find_first_not_of(OptionChars, 1) == StringRef::npos) {
argv[i]++;
break;
}
if (S == "--")
break;
}

// Have the command line options parsed and handle things
// like --help and --version.
cl::ParseCommandLineOptions(argc, argv,
Expand Down

0 comments on commit a809755

Please sign in to comment.