workaround for `The module 'foo.bar' is already defined` when recompiling objects?

Timothee Cour via Digitalmars-d digitalmars-d at puremagic.com
Sat Jun 10 23:54:07 PDT 2017


NOTE: this is on linux, and the above simple case doesn't reproduce
the error, but my test case is similar albeit from a larger program
that's hard to reduce.

the code that crashes is in druntime:
/**
 * Check for module collisions. A module in a shared library collides
 * with an existing module if it's ModuleInfo is interposed (search
 * symbol interposition) by another DSO.  Therefor two modules with the
 * same name do not collide if their DSOs are in separate symbol resolution
 * chains.
 */
void checkModuleCollisions(in ref dl_phdr_info info, in
immutable(ModuleInfo)*[] modules,
                           in void[] copyRelocSection) nothrow

Could someone please explain:

* what that means
* what's the simplest example that would exhibit this error
* what's a workaround ? (where i want to do partial recompilation)

On Sat, Jun 10, 2017 at 10:21 PM, Timothee Cour
<thelastmammoth at gmail.com> wrote:
> ```
> dmd -shared -oflibfoo.so a1.d a2.d
> dmd -ofmain -L-lfoo a2.d main.d
> ./main
> ```
> gives runtime error: `The module 'foo.bar' is already defined in 'main'`
>
> How would I work around this error?
>
> Use case: allow partial recompilation of a binary without rebuilding
> everything to optimize compile time for fast edit debug cycles.


More information about the Digitalmars-d mailing list