[PATCH] D158004: llvm-nm ignore the Import symbol file for the --export-symbol option.

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 10:35:28 PDT 2023


hubert.reinterpretcast added a comment.

In D158004#4598105 <https://reviews.llvm.org/D158004#4598105>, @jhenderson wrote:

> I'd just like to make sure I follow what is going on here:
>
> 1. On AIX, clang uses llvm-nm to produce a list of exported symbols for its command-line. It does this by calling `llvm-nm --export-symbols` on each input file to clang.
> 2. Import files can be passed on the command-line like regular object files. They are distinguished from regular objects because they start with `#!`.
> 3. Because of these two points, clang ends up passing import files to llvm-nm, which should be ignored.

Correct.

> The question I have though is why should we special-case import files specifically for `--export-symbols`? I'm thinking that they should actually be another kind of `Binary` file, like `COFFImportFile`. It would then fit more naturally into the framework that already exists, whereas the proposed patch feels like a sticking plaster to cover a specific edge-case. If this is causing a major issue, I'm okay with this patch landing, but I'd like a TODO added to the code indicating that it is temporary and should be replaced with something more appropriate like `AIXImportFile` or similar in the near future.

This is causing a major issue for users linking shared objects using Clang on AIX; yes. Thanks for the understanding. I have some doubts about implementing further functionality for an `AIXImportFile` though: It is already human-readable. Also, it seems (to me) inappropriate to model is as a `Binary` because it is text.



================
Comment at: llvm/tools/llvm-nm/llvm-nm.cpp:2267-2270
+  const char *BuffStart = (*BufferOrErr)->getBufferStart();
+  if (ExportSymbols && (*BufferOrErr)->getBufferSize() >= 2 &&
+      BuffStart[0] == '#' && BuffStart[1] == '!')
+    return SymbolList;
----------------
DiggerLin wrote:
> jhenderson wrote:
> > Should this be limited to AIX or similar in some way? Certainly, the comment should highlight that these import files are specific to AIX, as the format is not a generic format that all systems follow. Something like "Ignore AIX import symbol files (these files start with "#!"), when exporting symbols."
> > 
> > I'd also strongly consider moving the identification code into the `createBinary` tree. See my out-of-line comment for more detail.
> it only limit to AIX Import symbol File. 
@jhenderson, do you have a suggestion on how to limit it in such a way? I was under the impression that the tools were designed to work in cross-compilation environments. A host-environment-based or build configuration property could be employed, but I think your input on the choice is needed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158004/new/

https://reviews.llvm.org/D158004



More information about the llvm-commits mailing list