Thread overview
[Issue 20668] Unresolved symbol (array equality) when using separate compilation
Dec 17, 2022
Iain Buclaw
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20668

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
April 28
https://issues.dlang.org/show_bug.cgi?id=20668

Andrei Horodniceanu <a.horodniceanu@proton.me> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |a.horodniceanu@proton.me

--- Comment #1 from Andrei Horodniceanu <a.horodniceanu@proton.me> ---
This has come up as an issue in tilix (https://github.com/gnunn1/tilix/issues/2210) making it uncompilable with dmd and gdc when using meson due to these linking errors.

The reduced files for tilix are:
---------
module terminal;

import common;
import session;

class Terminal {
        GenericEvent!() event;
}
---------
module common;

struct GenericEvent() {
        int[] arr;
}
---------
module session;

import common;
import terminal;

class Session {
        GenericEvent!() event;
}
---------

Compile with:
----
dmd -c terminal.d
dmd -c session.d
dmd -c common.d
dmd -of=main -main common.o session.o terminal.o
----
The results are:
----
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld:
session.o: in function
`_D6common__T12GenericEventZQp11__xopEqualsMxFKxSQBu__TQBqZQBuZb':
session.d:(.text._D6common__T12GenericEventZQp11__xopEqualsMxFKxSQBu__TQBqZQBuZb[_D6common__T12GenericEventZQp11__xopEqualsMxFKxSQBu__TQBqZQBuZb]+0x25):
undefined reference to
`_D4core8internal5array8equality__T8__equalsTiTiZQoFNaNbNiNeMxAiMxQeZb'
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
       cc common.o session.o terminal.o main.o -o main -m64 -Xlinker
--export-dynamic -Xlinker -rpath=/usr/lib/dmd/2.108/lib64
-L/usr/lib/dmd/2.108/lib64 -lphobos2 -lpthread -lm -lrt -ldl
----

--
April 28
https://issues.dlang.org/show_bug.cgi?id=20668

Richard Cattermole <alphaglosined@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |alphaglosined@gmail.com

--- Comment #2 from Richard Cattermole <alphaglosined@gmail.com> ---
This is likely a template emission eliding bug.

Try with ``-allinst`` to force emittance.

--
April 29
https://issues.dlang.org/show_bug.cgi?id=20668

--- Comment #3 from Andrei Horodniceanu <a.horodniceanu@proton.me> ---
(In reply to Richard Cattermole from comment #2)
> This is likely a template emission eliding bug.
> 
> Try with ``-allinst`` to force emittance.

This fixes it, thanks! This issue with tilix has been bugging me for a while, nice to have found a solution.

--