From 2b706932eef86b25a7a833b0e3136d3a0429bfab Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 6 May 2008 20:40:33 +0000 Subject: [PATCH] * options.h (DEFINE_var): Add set_user_set_##varname__. (DEFINE_bool_alias): New macro. (class General_options): Define -Bstatic using DEFINE_bool_alias rather than DEFINE_special. Add --undefined as an alias for -z defs. * options.cc (General_options::parse_Bstatic): Remove. --- gold/ChangeLog | 7 ++++++ gold/options.cc | 6 ----- gold/options.h | 63 +++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 66 insertions(+), 10 deletions(-) diff --git a/gold/ChangeLog b/gold/ChangeLog index 3f77ed4307..3c015c8acd 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,5 +1,12 @@ 2008-05-06 Ian Lance Taylor + * options.h (DEFINE_var): Add set_user_set_##varname__. + (DEFINE_bool_alias): New macro. + (class General_options): Define -Bstatic using DEFINE_bool_alias + rather than DEFINE_special. Add --undefined as an alias for -z + defs. + * options.cc (General_options::parse_Bstatic): Remove. + * options.h (class General_options): Add --fatal-warnings. * main.cc (main): Implement --fatal-warnings. * errors.h (Errors::warning_count): New function. diff --git a/gold/options.cc b/gold/options.cc index af024b5c93..8d18c11fbc 100644 --- a/gold/options.cc +++ b/gold/options.cc @@ -281,12 +281,6 @@ General_options::parse_V(const char*, const char*, Command_line*) printf(" %s\n", *p); } -void -General_options::parse_Bstatic(const char*, const char*, Command_line*) -{ - this->set_Bdynamic(false); -} - void General_options::parse_defsym(const char*, const char* arg, Command_line* cmdline) diff --git a/gold/options.h b/gold/options.h index 2ea57ecb01..cf9b887f1c 100644 --- a/gold/options.h +++ b/gold/options.h @@ -239,6 +239,10 @@ struct Struct_special : public Struct_var user_set_##varname__() const \ { return this->varname__##_.user_set_via_option; } \ \ + void \ + set_user_set_##varname__() \ + { this->varname__##_.user_set_via_option = true; } \ + \ private: \ struct Struct_##varname__ : public options::Struct_var \ { \ @@ -390,6 +394,53 @@ struct Struct_special : public Struct_var choices, sizeof(choices) / sizeof(*choices)); \ } +// This is like DEFINE_bool, but VARNAME is the name of a different +// option. This option becomes an alias for that one. INVERT is true +// if this option is an inversion of the other one. +#define DEFINE_bool_alias(option__, varname__, dashes__, shortname__, \ + helpstring__, no_helpstring__, invert__) \ + private: \ + struct Struct_##option__ : public options::Struct_var \ + { \ + Struct_##option__() \ + : option(#option__, dashes__, shortname__, "", helpstring__, \ + NULL, false, this) \ + { } \ + \ + void \ + parse_to_value(const char*, const char*, \ + Command_line*, General_options* options) \ + { \ + options->set_##varname__(!invert__); \ + options->set_user_set_##varname__(); \ + } \ + \ + options::One_option option; \ + }; \ + Struct_##option__ option__##_; \ + \ + struct Struct_no_##option__ : public options::Struct_var \ + { \ + Struct_no_##option__() \ + : option((dashes__ == options::DASH_Z \ + ? "no" #option__ \ + : "no-" #option__), \ + dashes__, '\0', "", no_helpstring__, \ + NULL, false, this) \ + { } \ + \ + void \ + parse_to_value(const char*, const char*, \ + Command_line*, General_options* options) \ + { \ + options->set_##varname__(invert__); \ + options->set_user_set_##varname__(); \ + } \ + \ + options::One_option option; \ + }; \ + Struct_no_##option__ no_##option__##_initializer_ + // This is used for non-standard flags. It defines no functions; it // just calls General_options::parse_VARNAME whenever the flag is // seen. We declare parse_VARNAME as a static member of @@ -502,10 +553,9 @@ class General_options DEFINE_bool(Bdynamic, options::ONE_DASH, '\0', true, N_("-l searches for shared libraries"), NULL); - // Bstatic affects the same variable as Bdynamic, so we have to use - // the "special" macro to make that happen. - DEFINE_special(Bstatic, options::ONE_DASH, '\0', - N_("-l does not search for shared libraries"), NULL); + DEFINE_bool_alias(Bstatic, Bdynamic, options::ONE_DASH, '\0', + N_("-l does not search for shared libraries"), NULL, + true); DEFINE_bool(Bsymbolic, options::ONE_DASH, '\0', false, N_("Bind defined symbols locally"), NULL); @@ -683,6 +733,11 @@ class General_options DEFINE_uint64(Ttext, options::ONE_DASH, '\0', -1U, N_("Set the address of the text segment"), N_("ADDRESS")); + DEFINE_bool_alias(undefined, defs, options::TWO_DASHES, '\0', + "Allow undefined symbols with --shared", + "Report undefined symbols (even with --shared)", + true); + DEFINE_bool(verbose, options::TWO_DASHES, '\0', false, N_("Synonym for --debug=files"), NULL);