Llvm-link tool --override and --only-needed flags, bug or feature?

I’m struggling a little bit here trying to understand the interactions between this two flags (–override,–only-needed) of the llvm-link tool.

To my understanding, these two flags should operate independently, and I couldn’t find any documentation stating otherwise. Basically I want to use the --override flag to get rid of some “symbol multiply defined!” errors while generating a unified bitcode file from two separate ones.

However, such feature seems to be only available if --only-needed flag is also provided.

Looking at the llvm-link.cpp main source code file:

    unsigned Flags = Linker::Flags::None;
  if (OnlyNeeded)
    Flags |= Linker::Flags::LinkOnlyNeeded;

  // First add all the regular input files
  if (!linkFiles(argv[0], Context, L, InputFilenames, Flags))
    return 1;

  // Next the -override ones.
  if (!linkFiles(argv[0], Context, L, OverridingInputs,
                 Flags | Linker::Flags::OverrideFromSrc))
    return 1;

And also at the LinkModules.cpp source code file:

bool shouldOverrideFromSrc() { return Flags & Linker::OverrideFromSrc; }
bool shouldLinkOnlyNeeded() { return Flags & Linker::LinkOnlyNeeded; } 

The later code block is pretty obvious, just checks whether the appropriate flag is set. Initially, this seems to be an independent check and I don’t see any interaction between those flags.

The problem comes from the former code block (llvm-link.cpp) which as stated has two passes of linkFiles, but the Flags attribute is only set with the --override option on the second one. Therefore leading to a situation where if there are ‘multiply defined symbols’, llvm-link will report the error on the first try, and stop.

Maybe I’m getting it all wrong, and this is not the intended use of the --override flag. Any guidance would be appretiated.

Thanks a lot,