[PATCH] Refactoring of Driver and TargetInfo

Shankar Kalpathi Easwaran shankarke at gmail.com
Fri Mar 29 16:51:29 PDT 2013



================
Comment at: lib/Core/Resolver.cpp:313
@@ -313,5 +312,3 @@
   // error message about missing symbols
-  if (!undefinedAtoms.empty() &&
-      (!_targetInfo.getLinkerOptions()._noInhibitExec ||
-       _targetInfo.getLinkerOptions()._outputKind == OutputKind::Relocatable)) {
+  if (!undefinedAtoms.empty() && _targetInfo.printRemainingUndefines()) {
     // FIXME: need diagonstics interface for writing error messages
----------------
kledzik at apple.com wrote:
> Shankar Kalpathi Easwaran wrote:
> > looks like printRemainingUndefines is silently performing the effect of noinhibit-exec option too, which it shouldnt. A no inhibit exec option should be provided by core. 
> > 
> > $cat x.c
> > extern int a;
> > 
> > int _start() { a = 10; }
> > $gcc -c x.c
> > $ld x.o -noinhibit-exec
> > x.o: In function `_start':
> > x.c:(.text+0x6): undefined reference to `a'
> > 
> I thought --noinhibit-exec meant "do not delete existing (old) file if link fails".  But after reading more man pages, it looks to mean "write output file, even if it is it contains errors".  
> The GnuLdDriver currently only calls setPrintRemainingUndefines(false) for -r mdoe and --allow-undefines.   I needed to invent --allow-undefines to get some elf cases to pass without writing to stderr.  What should --noinhibit-exec? Does it mean turn errors into warnings?  All errors or just undefined symbosl?
-noinhibit-exec is an option valid only when creating the executable.

If -noinhibit-exec option is passed, does the following :-

a) prints undefined symbols as errors
b) moves onto create the executable

If -noinhibit-exec is not passed, the linker aborts when there are undefined symbols

================
Comment at: lib/Driver/CoreDriver.cpp:144-149
@@ +143,8 @@
+  
+  // Handle --add-pass xxx option
+  for (llvm::opt::arg_iterator it = parsedArgs->filtered_begin(OPT_add_pass),
+                               ie = parsedArgs->filtered_end();
+                              it != ie; ++it) {
+    info.addPassNamed((*it)->getValue());
+  }
+
----------------
Shankar Kalpathi Easwaran wrote:
> I think there is a need for a --remove-pass option too, for targets that have set few options by default.
?

================
Comment at: lib/Driver/GnuLdDriver.cpp:181-196
@@ +180,18 @@
+  
+  // Handle --allow-undefines
+  if (parsedArgs->getLastArg(OPT_allow_undefines))
+    options->setPrintRemainingUndefines(false);
+  
+  // Handle --force-load
+  if (parsedArgs->getLastArg(OPT_force_load))
+    options->setForceLoadAllArchives(true);
+  
+  // Handle --merge-strings
+  if (parsedArgs->getLastArg(OPT_merge_strings))
+    options->setMergeCommonStrings(true);
+  
+  // Handle -t
+  if (parsedArgs->getLastArg(OPT_t))
+    options->setLogInputFiles(true);
+  
+  // Handle -Lxxx
----------------
Shankar Kalpathi Easwaran wrote:
> -dead-strip/ --add-pass is missing in target. Isnt it better for the targets to call the Core to parse the options and set appropriate values in the targetInfo structure, otherwise if there is an option added in core, you have to duplicate handling that option in all targets.
?


http://llvm-reviews.chandlerc.com/D589

BRANCH
  svn

ARCANIST PROJECT
  lld



More information about the llvm-commits mailing list