#include <cstdio>
#include <cstring>
#include <unistd.h>
+#include "libiberty.h"
#include "options.h"
#include "workqueue.h"
void
gold_exit(bool status)
{
+ if (!status && parameters != NULL)
+ unlink_if_ordinary(parameters->output_file_name());
exit(status ? EXIT_SUCCESS : EXIT_FAILURE);
}
-void
-gold_fatal(const char* msg, bool perrno)
-{
- fprintf(stderr, "%s: ", program_name);
- if (perrno)
- perror(msg);
- else
- fprintf(stderr, "%s\n", msg);
- gold_exit(false);
-}
-
void
gold_nomem()
{
Workqueue* workqueue, Input_objects* input_objects,
Symbol_table* symtab, Layout* layout)
{
+ int thread_count = options.thread_count_initial();
+ if (thread_count == 0)
+ {
+ thread_count = cmdline.number_of_input_files();
+ if (thread_count == 0)
+ thread_count = 1;
+ }
+ workqueue->set_thread_count(thread_count);
+
if (cmdline.begin() == cmdline.end())
- gold_fatal(_("no input files"), false);
+ gold_fatal(_("no input files"));
// Read the input files. We have to add the symbols to the symbol
// table in order. We do this by creating a separate blocker for
Layout* layout,
Workqueue* workqueue)
{
+ int thread_count = options.thread_count_middle();
+ if (thread_count == 0)
+ {
+ thread_count = input_objects->number_of_input_objects();
+ if (thread_count == 0)
+ thread_count = 1;
+ }
+ workqueue->set_thread_count(thread_count);
+
// Now we have seen all the input files.
- const bool doing_static_link = !input_objects->any_dynamic();
+ const bool doing_static_link = (!input_objects->any_dynamic()
+ && !parameters->output_is_shared());
set_parameters_doing_static_link(doing_static_link);
if (!doing_static_link && options.is_static())
{
// We print out just the first .so we see; there may be others.
- fprintf(stderr, _("%s: cannot mix -static with dynamic object %s\n"),
- program_name, (*input_objects->dynobj_begin())->name().c_str());
- gold_exit(false);
+ gold_error(_("cannot mix -static with dynamic object %s"),
+ (*input_objects->dynobj_begin())->name().c_str());
}
// Define some sections and symbols needed for a dynamic link. This
Workqueue* workqueue,
Output_file* of)
{
+ int thread_count = options.thread_count_final();
+ if (thread_count == 0)
+ {
+ thread_count = input_objects->number_of_input_objects();
+ if (thread_count == 0)
+ thread_count = 1;
+ }
+ workqueue->set_thread_count(thread_count);
+
// Use a blocker to block the final cleanup task.
Task_token* final_blocker = new Task_token();