Index: gold-threads.cc =================================================================== RCS file: /cvs/src/src/gold/gold-threads.cc,v retrieving revision 1.8 diff -u -p -r1.8 gold-threads.cc --- gold-threads.cc 24 Mar 2009 04:50:32 -0000 1.8 +++ gold-threads.cc 24 Mar 2009 17:32:24 -0000 @@ -308,7 +308,7 @@ class Initialize_lock_once static pthread_mutex_t initialize_lock_control = PTHREAD_MUTEX_INITIALIZER; // A pointer to a pointer to the lock which we need to initialize -// once. Access to this is controlled by initialize_lock_pointer. +// once. Access to this is controlled by initialize_lock_control. static Lock** initialize_lock_pointer; Index: target-select.cc =================================================================== RCS file: /cvs/src/src/gold/target-select.cc,v retrieving revision 1.9 diff -u -p -r1.9 target-select.cc --- target-select.cc 24 Mar 2009 04:50:32 -0000 1.9 +++ target-select.cc 24 Mar 2009 17:32:24 -0000 @@ -60,10 +60,15 @@ Target_selector::Target_selector(int mac Target* Target_selector::instantiate_target() { - this->initialize_lock_.initialize(); - Hold_optional_lock hl(this->lock_); + // We assume that the pointer will either be written entirely or not + // at all. if (this->instantiated_target_ == NULL) - this->instantiated_target_ = this->do_instantiate_target(); + { + this->initialize_lock_.initialize(); + Hold_optional_lock hl(this->lock_); + if (this->instantiated_target_ == NULL) + this->instantiated_target_ = this->do_instantiate_target(); + } return this->instantiated_target_; }