Skip to content

[LLD][ELF] Import ObjFile::importCmseSymbols at call site #68025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 3, 2023

Conversation

aganea
Copy link
Member

@aganea aganea commented Oct 2, 2023

Before this patch, with MSVC I was seeing the following warnings:

[304/334] Building CXX object tools\lld\ELF\CMakeFiles\lldELF.dir\InputFiles.cpp.obj
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile<llvm::object::ELF32LE>::importCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(291): note: see declaration of 'lld::elf::ObjFile<llvm::object::ELF32LE>::importCmseSymbols'
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile<llvm::object::ELF32LE>::redirectCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(292): note: see declaration of 'lld::elf::ObjFile<llvm::object::ELF32LE>::redirectCmseSymbols'

This patch removes redirectCmseSymbols which is not defined. And it imports importCmseSymbols in InputFiles.cpp, because it is already explicitly instantiated in ARM.cpp.

Before this patch, with MSVC I was seeing the following warnings:
```
[304/334] Building CXX object tools\lld\ELF\CMakeFiles\lldELF.dir\InputFiles.cpp.obj
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile<llvm::object::ELF32LE>::importCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(291): note: see declaration of 'lld::elf::ObjFile<llvm::object::ELF32LE>::importCmseSymbols'
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile<llvm::object::ELF32LE>::redirectCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(292): note: see declaration of 'lld::elf::ObjFile<llvm::object::ELF32LE>::redirectCmseSymbols'
```

This patch removes `redirectCmseSymbols` which is not defined. And it imports `importCmseSymbols` in InputFiles.cpp, because it is already explicitly instantiated in ARM.cpp.
@llvmbot
Copy link
Member

llvmbot commented Oct 2, 2023

@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-elf

Changes

Before this patch, with MSVC I was seeing the following warnings:

[304/334] Building CXX object tools\lld\ELF\CMakeFiles\lldELF.dir\InputFiles.cpp.obj
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile&lt;llvm::object::ELF32LE&gt;::importCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(291): note: see declaration of 'lld::elf::ObjFile&lt;llvm::object::ELF32LE&gt;::importCmseSymbols'
C:\git\llvm-project\lld\ELF\InputFiles.h(327): warning C4661: 'void lld::elf::ObjFile&lt;llvm::object::ELF32LE&gt;::redirectCmseSymbols(void)': no suitable definition provided for explicit template instantiation request
C:\git\llvm-project\lld\ELF\InputFiles.h(292): note: see declaration of 'lld::elf::ObjFile&lt;llvm::object::ELF32LE&gt;::redirectCmseSymbols'

This patch removes redirectCmseSymbols which is not defined. And it imports importCmseSymbols in InputFiles.cpp, because it is already explicitly instantiated in ARM.cpp.


Full diff: https://github.com/llvm/llvm-project/pull/68025.diff

2 Files Affected:

  • (modified) lld/ELF/InputFiles.cpp (+7)
  • (modified) lld/ELF/InputFiles.h (-1)
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index fa0731854689b94..bb86269d49499cd 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -40,6 +40,13 @@ using namespace llvm::support::endian;
 using namespace lld;
 using namespace lld::elf;
 
+// This function is explicity instantiated in ARM.cpp, don't do it here to avoid
+// warnings with MSVC.
+extern template void ObjFile<ELF32LE>::importCmseSymbols();
+extern template void ObjFile<ELF32BE>::importCmseSymbols();
+extern template void ObjFile<ELF64LE>::importCmseSymbols();
+extern template void ObjFile<ELF64BE>::importCmseSymbols();
+
 bool InputFile::isInGroup;
 uint32_t InputFile::nextGroupId;
 
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index cc658bdc231988e..41c2ba4e307b36b 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -289,7 +289,6 @@ template <class ELFT> class ObjFile : public ELFFileBase {
   void initSectionsAndLocalSyms(bool ignoreComdats);
   void postParse();
   void importCmseSymbols();
-  void redirectCmseSymbols();
 
 private:
   void initializeSections(bool ignoreComdats,

@@ -40,6 +40,13 @@ using namespace llvm::support::endian;
using namespace lld;
using namespace lld::elf;

// This function is explicity instantiated in ARM.cpp, don't do it here to avoid
// warnings with MSVC.
extern template void ObjFile<ELF32LE>::importCmseSymbols();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be placed directly before doParseArmCMSEImportLib for clarity.

@aganea aganea changed the title [LLD][ELF] Don't instantiate ObjFile function but rather import it [LLD][ELF] Import ObjFile::importCmseSymbols at point of usage Oct 3, 2023
@aganea aganea changed the title [LLD][ELF] Import ObjFile::importCmseSymbols at point of usage [LLD][ELF] Import ObjFile::importCmseSymbols at call site Oct 3, 2023
@aganea aganea merged commit a2ef046 into llvm:main Oct 3, 2023
@aganea aganea deleted the fix/elf_objfile_template branch October 3, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants