Preface: lld is very likely to become the default linker in FreeBSD (in the next year or such).
In order to help the transition, we're going to ask FreeBSD developers to try out the new linker and report bugs.
--reproduce dumps the object files in a directory chosen (preserving the file system layout) and the linker invocation so that people can create an archive and upload to bugzilla.
Details
Diff Detail
Event Timeline
ELF/Config.h | ||
---|---|---|
51 | Remove = "". Strings are initialized to empty string by default. Also please rename Reproduce as the members of Config have the same name as command line options. | |
ELF/Driver.cpp | ||
101–107 | Why do you need to make a path full path? | |
115 | I think you want to use path::append instead of appending "/". | |
118 | Let's create a std::string for the directory name so that we don't need to repeat this string concatenation twice. | |
121 | Let's make it explicit that the feature is optional. if (Config->Reproduce) dumpFile(Path); | |
250 | error(EC, "--reproduce: can't create directory"); | |
257 | auto -> const char * | |
258 | This would leave a space character at end of the line and does not terminate the line with '\n'. As this is not a speed-critical path, I'd do OS << llvm::join(Args.begin(), Args.end(), " ") << "\n"; | |
277 | Guard with if (Config->Reproduce) as well. | |
428–429 | This error would be caught in dumpLinkerInvocation, no? |
For what it is worth, something like this would have been very handy
at creating the test directories I use for benchmarking :-)
ELF/Driver.cpp | ||
---|---|---|
101–107 | I don't think I need. Fixed. | |
258 | I don't think your solution works because the way join works right now. In file included from ../tools/lld/ELF/Driver.cpp:21: Len += (*Begin).size(); ~~~~~~~~^~~~~ ../include/llvm/ADT/StringExtras.h:192:10: note: in instantiation of function template specialization 'llvm::join_impl<const char *>' requested here return join_impl(Begin, End, Separator, tag()); ^ ../tools/lld/ELF/Driver.cpp:271:15: note: in instantiation of function template specialization 'llvm::join<const char *>' requested here OS << llvm::join(*Args.begin(), *Args.end(), " "); ^ 1 error generated. We might want to fix in StringExtras.h, but I'd rather do that later. | |
428–429 | It doesn't seem so, i.e. if I remove the check: [davide@localhost build-clang]$ rm -rf /home/davide/work/llvm/tools/lld/test/ELF/repro2 |
ELF/Driver.cpp | ||
---|---|---|
247 | Remove trailing . and pass EC to error. Then error will format the message for you by appending a colon and EC.message(). error(EC, "--reproduce: can't create directory"); | |
258 | OK, but please do not emit trailing whitespace to the generated file. | |
425–426 | Looks like create_directories accepts IgnoreExisting parameter as the second parameter. std::error_code create_directories(const Twine &path, bool IgnoreExisting = true, perms Perms = owner_all | group_all); You want to pass false then you can remove this code. |
ELF/Driver.cpp | ||
---|---|---|
102–103 | Remove. | |
105 | Please do not add llvm:: for consistency. | |
106–107 | if (std::error_code EC = sys::fs::create_directories(DirName)) | |
108 | Please pass EC as the first argument at this place too. | |
114–115 | if (std::error_code EC = sys::fs::copy_file(SrcPath, DestPathName)) | |
252 | Please fix this place as well. You want to use sys::path::append instead of textually appending path fragments. | |
257 | I'd do this (because ARGV[0] must exist) OS << Args[0]; for (size_t I = 1, E = Args.size(); I < E; ++I) OS << " " << Args[I]; OS << "\n"; |
LGTM with a nit.
ELF/Driver.cpp | ||
---|---|---|
423–424 | Replace this with Config->Reproduce = getString(Args, OPT_reproduce, ""); and move to the group at line 350-356 (and sort the group). |
ELF/Driver.cpp | ||
---|---|---|
259 | An argument might contain a space, so let's separate these by newlines instead. |
ELF/Driver.cpp | ||
---|---|---|
259 | Pathname with spaces are also rare (except on Windows), no? An upside of writing all options in one line is you can (re-)execute the command just by passing the file to the shell. |
ELF/Driver.cpp | ||
---|---|---|
259 |
Exactly. Windows is one of our supported platforms.
For now, let's go ahead with how Davide had it (one line). We can make this more robust in future patches. |
Remove = "". Strings are initialized to empty string by default. Also please rename Reproduce as the members of Config have the same name as command line options.