Mercury Bugs - mercury
View Issue Details
0000106mercuryBugpublic2009-09-22 01:072009-09-22 02:09
Reporterjanicek 
Assigned Tojuliensf 
PrioritynormalSeveritymajorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000106: Linking with multiple C++ files yields a "duplicate symbol" error
DescriptionLinking a Mercury main module with two (or more) C++ files that utilise some Mercury code through pragma foreign_export fails with the linker reporting the following:

** Error making `mercury_main'.
ld: duplicate symbol _MR_trace_tailrec_have_reused_frames in CPlusPlus2.o and CPlusPlus1.o
collect2: ld returned 1 exit status

(See the attachment for a minimal example.)

The platform is Darwin (Mac OS X 10.5.8), using Apple's GCC 4.1.2 which is shipped with Xcode 3.1.2.

$ uname -a
Darwin dfki-guestpool3.dfki.uni-sb.de 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386

$ g++ --version
i686-apple-darwin9-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5566)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ mmc --version
Mercury Compiler, version rotd-2008-11-30, configured for i686-apple-darwin9.6.0
Copyright (C) 1993-2008 The University of Melbourne
Additional InformationAdding the keyword "extern" to variables

MR_trace_tailrec_have_reused_frames
and
MR_trace_tailrec_num_reused_frames

in `mercury_trace_base.h'

seems to resolve the issue, i.e. the program links and seems to run fine.
TagsNo tags attached.
Attached Filesgz duplicate-symbol-error.tar.gz (1,794) 2009-09-22 01:07
https://bugs.mercurylang.org/file_download.php?file_id=80&type=bug

Notes
(0000183)
janicek   
2009-09-22 01:09   
Ah, forgot to mention the grade -- it's hlc.gc. Sorry!
(0000184)
juliensf   
2009-09-22 01:53   
The missing externs are a bug - I will fix this shortly.
(0000185)
juliensf   
2009-09-22 02:09   
Fix committed - it will take a day or two to make its way into the ROTDS.

Issue History
2009-09-22 01:07janicekNew Issue
2009-09-22 01:07janicekFile Added: duplicate-symbol-error.tar.gz
2009-09-22 01:09janicekNote Added: 0000183
2009-09-22 01:53juliensfNote Added: 0000184
2009-09-22 01:53juliensfAssigned To => juliensf
2009-09-22 01:53juliensfStatusnew => assigned
2009-09-22 02:09juliensfNote Added: 0000185
2009-09-22 02:09juliensfStatusassigned => resolved
2009-09-22 02:09juliensfResolutionopen => fixed