Opened 5 years ago

Last modified 5 years ago

#1553 new enhancement

Prevent the user defining non-static functions in more than one object file

Reported by: Ian Hinder Owned by:
Priority: minor Milestone:
Component: Cactus Version: development version
Keywords: Cc:


If a non-static function is defined in more than one object file, the results at run-time are unexpected or unpredictable. I was under the impression that there were compiler options to prevent this. At least on Mac OS, these must not be used, as I just ran into this problem.

So, either we find out which options are needed and add them, or we could provide some additional checks in the build system to help catch this error. For example, Cactus scheduled functions defined with the same name should be easy to catch.

Attachments (1)

0001-Prevent-linking-on-Mac-OS-if-symbols-are-defined-in-.patch (1.1 KB) - added by Ian Hinder 5 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 Changed 5 years ago by Erik Schnetter

This is a problem because we put thorn functions into libraries, and (by default) libraries can contain duplicate definitions. In this case, the linker uses the first definition it sees, which depends on the order in which we list the thorns when calling the linker.

We have modifications to the flesh that make Cactus use all functions from all thorns all the time. This leads to linker errors for duplicate functions. Since this is system-specific, this is not the default. (I am unaware of a system where this fails, though.)

For OS X, you enable this with the options

BEGIN_WHOLE_ARCHIVE_FLAGS = -L$(CCTK_LIBDIR)   # must not be empty

comment:2 Changed 5 years ago by Ian Hinder

Thanks; that works. I propose that this is added to the darwin known_architectures file so that it applies to all Mac OS systems. I have tested the attached patch and it works on Mac OS 10.8.5 (Mountain Lion) with the current SimFactory osx-mountain-lion-macports-gcc.cfg optionlist. [Aside: I have a long-term goal of eliminating the OS (as opposed to machine) optionlists in favour of auto-detecting everything in either the ExternalLibraries thorns or the known_architectures files. This is why I don't want to just add this to the existing OS X optionlist.]

Modify Ticket

Change Properties
Set your email in Preferences
as new The ticket will remain with no owner.
Next status will be 'review'.
as The resolution will be set.
to The owner will be changed from (none) to the specified user.
Next status will be 'confirmed'.
The owner will be changed from (none) to anonymous.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.