[llvm-commits] CVS: llvm/lib/Linker/LinkItems.cpp

2007-04-29 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkItems.cpp updated: 1.12 - 1.13
---
Log message:

Dependent libraries could be native too.


---
Diffs of the changes:  (+4 -1)

 LinkItems.cpp |5 -
 1 files changed, 4 insertions(+), 1 deletion(-)


Index: llvm/lib/Linker/LinkItems.cpp
diff -u llvm/lib/Linker/LinkItems.cpp:1.12 llvm/lib/Linker/LinkItems.cpp:1.13
--- llvm/lib/Linker/LinkItems.cpp:1.12  Tue Apr 10 21:44:19 2007
+++ llvm/lib/Linker/LinkItems.cpp   Sun Apr 29 19:00:10 2007
@@ -54,9 +54,12 @@
   // symbols.
   bool is_native;
   for (Module::lib_iterator I = Composite-lib_begin(),
- E = Composite-lib_end(); I != E; ++I)
+ E = Composite-lib_end(); I != E; ++I) {
 if(LinkInLibrary(*I, is_native))
   return true;
+if (is_native)
+  NativeItems.push_back(std::make_pair(*I, true));
+  }
 
   return false;
 }



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] CVS: llvm/lib/Linker/LinkItems.cpp

2007-04-04 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkItems.cpp updated: 1.9 - 1.10
---
Log message:

For PR1302: http://llvm.org/PR1302 :
Implement file tests for both LinkInLibrary and LinkInFile to determine if
the file is native. Don't generate warnings if the file is native. 


---
Diffs of the changes:  (+61 -31)

 LinkItems.cpp |   92 ++
 1 files changed, 61 insertions(+), 31 deletions(-)


Index: llvm/lib/Linker/LinkItems.cpp
diff -u llvm/lib/Linker/LinkItems.cpp:1.9 llvm/lib/Linker/LinkItems.cpp:1.10
--- llvm/lib/Linker/LinkItems.cpp:1.9   Sat Nov 11 05:54:25 2006
+++ llvm/lib/Linker/LinkItems.cpp   Wed Apr  4 01:33:17 2007
@@ -33,14 +33,17 @@
 if (I-second) {
   // Link in the library suggested.
   bool is_bytecode = true;
-  if (LinkInLibrary(I-first,is_bytecode))
+  if (LinkInLibrary(I-first, is_bytecode))
 return true;
   if (!is_bytecode)
 NativeItems.push_back(*I);
 } else {
   // Link in the file suggested
-  if (LinkInFile(sys::Path(I-first)))
+  bool is_native = false;
+  if (LinkInFile(sys::Path(I-first), is_native))
 return true;
+  if (is_native)
+NativeItems.push_back(*I);
 }
   }
 
@@ -61,8 +64,8 @@
 
 /// LinkInLibrary - links one library into the HeadModule.
 ///
-bool Linker::LinkInLibrary(const std::string Lib, bool is_bytecode) {
-  is_bytecode = false;
+bool Linker::LinkInLibrary(const std::string Lib, bool is_native) {
+  is_native = false;
   // Determine where this library lives.
   sys::Path Pathname = FindLib(Lib);
   if (Pathname.isEmpty())
@@ -72,20 +75,27 @@
   std::string Magic;
   Pathname.getMagicNumber(Magic, 64);
   switch (sys::IdentifyFileType(Magic.c_str(), 64)) {
-case sys::BytecodeFileType:
-case sys::CompressedBytecodeFileType:
+default: assert(0  Bad file type identification);
+case sys::Unknown_FileType:
+  return warning(Supposed library ' + Lib + ' isn't a library.);
+
+case sys::Bytecode_FileType:
+case sys::CompressedBytecode_FileType:
   // LLVM .so file.
-  if (LinkInFile(Pathname))
+  if (LinkInFile(Pathname, is_native))
 return error(Cannot link file ' + Pathname.toString() + ');
-  is_bytecode = true;
   break;
-case sys::ArchiveFileType:
+
+case sys::Archive_FileType:
   if (LinkInArchive(Pathname))
 return error(Cannot link archive ' + Pathname.toString() + ');
-  is_bytecode = true;
   break;
-default:
-  return warning(Supposed library ' + Lib + ' isn't a library.);
+
+case sys::ELF_FileType:
+case sys::Mach_O_FileType:
+case sys::COFF_FileType:
+  is_native = true;
+  break;
   }
   return false;
 }
@@ -135,28 +145,47 @@
 ///  TRUE  - An error occurred.
 ///  FALSE - No errors.
 ///
-bool Linker::LinkInFile(const sys::Path File) {
+bool Linker::LinkInFile(const sys::Path File, bool is_native) {
+  is_native = false;
   // Make sure we can at least read the file
   if (!File.canRead())
 return error(Cannot find linker input ' + File.toString() + ');
 
-  // A user may specify an ar archive without -l, perhaps because it
-  // is not installed as a library. Detect that and link the library.
-  if (File.isArchive()) {
-if (LinkInArchive(File))
-  return error(Cannot link archive ' + File.toString() + ');
-  } else if (File.isBytecodeFile()) {
-verbose(Linking bytecode file ' + File.toString() + ');
-
-std::auto_ptrModule M(LoadObject(File));
-if (M.get() == 0)
-  return error(Cannot load file ' + File.toString() + ' + Error);
-if (LinkInModule(M.get()))
-  return error(Cannot link file ' + File.toString() + ' + Error);
-
-verbose(Linked in file ' + File.toString() + ');
-  } else {
-return warning(File of unknown type ' + File.toString() + ' ignored.);
+  // If its an archive, try to link it in
+  std::string Magic;
+  File.getMagicNumber(Magic, 64);
+  switch (sys::IdentifyFileType(Magic.c_str(), 64)) {
+default: assert(0  Bad file type identification);
+case sys::Unknown_FileType:
+  return warning(Supposed object file ' + File.toString() + 
+ ' not recognized as such);
+
+case sys::Archive_FileType:
+  // A user may specify an ar archive without -l, perhaps because it
+  // is not installed as a library. Detect that and link the archive.
+  verbose(Linking archive file ' + File.toString() + ');
+  if (LinkInArchive(File))
+return error(Cannot link archive ' + File.toString() + ');
+  break;
+
+case sys::Bytecode_FileType:
+case sys::CompressedBytecode_FileType: {
+  verbose(Linking bytecode file ' + File.toString() + ');
+  std::auto_ptrModule M(LoadObject(File));
+  if (M.get() == 0)
+return error(Cannot load file ' + File.toString() + ' + Error);
+  if (LinkInModule(M.get()))
+return error(Cannot link file ' + File.toString() + ' + Error);
+
+  

[llvm-commits] CVS: llvm/lib/Linker/LinkItems.cpp

2007-04-04 Thread Reid Spencer


Changes in directory llvm/lib/Linker:

LinkItems.cpp updated: 1.10 - 1.11
---
Log message:

For PR1302: http://llvm.org/PR1302 :
Use local variable names that match the function parameter name that it
is passed to so the code is more clear, to wit: is_bytecode - is_native


---
Diffs of the changes:  (+8 -8)

 LinkItems.cpp |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)


Index: llvm/lib/Linker/LinkItems.cpp
diff -u llvm/lib/Linker/LinkItems.cpp:1.10 llvm/lib/Linker/LinkItems.cpp:1.11
--- llvm/lib/Linker/LinkItems.cpp:1.10  Wed Apr  4 01:33:17 2007
+++ llvm/lib/Linker/LinkItems.cpp   Wed Apr  4 01:44:18 2007
@@ -32,10 +32,10 @@
I != E; ++I) {
 if (I-second) {
   // Link in the library suggested.
-  bool is_bytecode = true;
-  if (LinkInLibrary(I-first, is_bytecode))
+  bool is_native = false;
+  if (LinkInLibrary(I-first, is_native))
 return true;
-  if (!is_bytecode)
+  if (is_native)
 NativeItems.push_back(*I);
 } else {
   // Link in the file suggested
@@ -52,10 +52,10 @@
   // that module should also be aggregated with duplicates eliminated. This is
   // now the time to process the dependent libraries to resolve any remaining
   // symbols.
-  bool is_bytecode;
+  bool is_native;
   for (Module::lib_iterator I = Composite-lib_begin(),
  E = Composite-lib_end(); I != E; ++I)
-if(LinkInLibrary(*I, is_bytecode))
+if(LinkInLibrary(*I, is_native))
   return true;
 
   return false;
@@ -113,9 +113,9 @@
 bool Linker::LinkInLibraries(const std::vectorstd::string Libraries) {
 
   // Process the set of libraries we've been provided.
-  bool is_bytecode;
+  bool is_native = false;
   for (unsigned i = 0; i  Libraries.size(); ++i)
-if (LinkInLibrary(Libraries[i], is_bytecode))
+if (LinkInLibrary(Libraries[i], is_native))
   return true;
 
   // At this point we have processed all the libraries provided to us. Since
@@ -126,7 +126,7 @@
   const Module::LibraryListType DepLibs = Composite-getLibraries();
   for (Module::LibraryListType::const_iterator I = DepLibs.begin(),
  E = DepLibs.end(); I != E; ++I)
-if (LinkInLibrary(*I, is_bytecode))
+if (LinkInLibrary(*I, is_native))
   return true;
 
   return false;



___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits