Boost logo

Boost-Build :

From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-04-18 17:11:17


  On HP-UX and Tru64, when using CVS HEAD, linking of process_jam_log fails
  because of multiply defined symbol. From ld output on HP-UX, for example:

ld: Duplicate symbol "boost::filesystem::basic_filesystem_error<boost::
filesystem::basic_path<std::basic_string<char,std::char_traits<char>,
std::allocator<char> >,boost::filesystem::path_traits> >::what() const"

  The duplicate symbol is coming from the explicit specialization in
  boost/filesystem/path.hpp conditionalized for anything but gcc with
  the following comment:

 // TODO: Figure out why this specialization is causing problems with GCC
#ifndef __GNUC__
 ...

  With aCC (HP-UX) and cxx (Tru64), this specialization is causing linker's
  muldef if several modules include header file with the specialization.
  According to reproducer below, this is the same problem with gcc also,
  although I don't know what "problems with GCC" the comment above refers
  to. This specialization does not cause a problem with Intel compiler for
  Itanium: see output for intel_ecc and iVMS below.

  Attached patch fixes the problem on HP-UX/aCC and Tru64/cxx by extending
  condition under which the specialization is not provided (before the fix,
  it was not provided for gcc only). I verified that it fixes the problem
  on the aforementioned platforms.

  Ok to commit?

  Thanks,
    Boris

path.hpp
--------
class path;

template<class T> class basic_filesystem_error {
  const char * what() const throw();
};

template<> const char * basic_filesystem_error<path>::what() const throw() {
  return 0;
}

x.cpp
-----
#include "path.hpp"

int main() {}

y.cpp
-----
#include "path.hpp"

bash-2.03$ aCC -V
aCC: HP C/aC++ B3910B A.06.14 [Feb 22 2007]
bash-2.03$ aCC x.cpp y.cpp
x.cpp:
y.cpp:
ld: Duplicate symbol "basic_filesystem_error<path>::what() const" in files x.o
and y.o
1 errors.
bash-2.03$ g++ x.cpp y.cpp
ld: Duplicate symbol "basic_filesystem_error<path>::what() const" in files
/var/tmp//ccvXAxka.o and /var/tmp//ccWe5Xga.o
1 errors.
collect2: ld returned 1 exit status
bash-2.03$

cxxosf.zko.hp.com> cxx -V
Compaq C++ V7.1-006 for Compaq Tru64 UNIX V5.1B (Rev. 2650)
Compiler Driver V7.1-006 (cxx) cxx Driver
cxxosf.zko.hp.com> cxx x.cpp y.cpp
x.cpp:
y.cpp:
ld (prelink):
y.o compressed: basic_filesystem_error<path>::what(void) const : multiply
defined
ld:
y.o compressed: basic_filesystem_error<path>::what(void) const : multiply
defined
cxxosf.zko.hp.com>

icc.zko.hp.com> $DECC_BIN/intel_ecc -V
Intel(R) C Itanium(R) Compiler for Itanium(R)-based applications
Version 9.0 Build 20060221
Built Jun 19 2006 17:12:01 by cbldr on icc.zko.dec.com in
/usr/proj/decc7/decc/intel_builds/latest/dev
Copyright (C) 1985-2006 Intel Corporation. All rights reserved.

icc.zko.hp.com> $DECC_BIN/intel_ecc x.cpp y.cpp
icc.zko.hp.com>

ICXX::_1> cxx/ver
HP C++ X7.3-100 on OpenVMS IA64 V8.3
ICXX::_1> cxx x.cpp
ICXX::_1> cxx y.cpp
ICXX::_1> link x.obj, y.obj
ICXX::_1>

Index: path.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/filesystem/path.hpp,v
retrieving revision 1.24
diff -u -d -r1.24 path.hpp
--- path.hpp 3 Nov 2006 16:57:29 -0000 1.24
+++ path.hpp 18 Apr 2007 20:33:16 -0000
@@ -611,8 +611,8 @@
       boost::shared_ptr<m_imp> m_imp_ptr;
     };

-// TODO: Figure out why this specialization is causing problems with GCC
-#ifndef __GNUC__
+// This specialization is causing problems with GCC, aCC (HP-UX) and cxx on
Alpha.
+#if !(defined(__GNUC__) || defined(__HP_aCC) || (defined(__DECCXX) &&
defined(__alpha)))
     template<> const char * basic_filesystem_error<path>::what() const throw()
     {
       if ( !m_imp_ptr.get() ) return system_error::what();


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk