LTO: undefined reference to `___t.0.1713.2134.2121

Anonymous avatarAnonymous created an issue
interface I {
   void m();
}
class C : I {
   void m() {}
}

void main(string[] args) {
}

$ gdc -O2 -flto lto01.d -o lto01

/tmp/cccld7WJ.ltrans0.ltrans.o:(.data+0x100): undefined reference to `_t.0.1713.2134.2121' collect2: ld returned 1 exit status

hg gdc: gcc version 4.6.3 20111204 (prerelease gdc 0.30, using dmd 2.056 Target: i686-pc-linux-gnu

Comments (26)

  1. Anonymous

    I have the same problem extending std.stream.Stream and overriding flush(). I'm using a cross-compiler (Linux64 to Win32) and while I have enabled LTO in the build, I didn't use it for compilation of my program:

    import std.stream;
    
    class Foo : Stream
    {
    	override void flush() {}
    }
    
    void main(string[] args) {}
    
    i686-mingw32-gdc src/fp8.d -owindows/fp8win32.exe -lpsapi
    /tmp/cckpduRz.o:fp8.d:(.data+0x50): undefined reference to `____t.0'
    /tmp/cckpduRz.o:fp8.d:(.data+0x54): undefined reference to `____t.1'
    /tmp/cckpduRz.o:fp8.d:(.data+0x58): undefined reference to `____t.2'
    /tmp/cckpduRz.o:fp8.d:(.data+0x5c): undefined reference to `____t.3'
    /tmp/cckpduRz.o:fp8.d:(.data+0x60): undefined reference to `____t.4'
    /tmp/cckpduRz.o:fp8.d:(.data+0x64): undefined reference to `____t.5'
    /tmp/cckpduRz.o:fp8.d:(.data+0x68): undefined reference to `____t.6'
    /tmp/cckpduRz.o:fp8.d:(.data+0x6c): undefined reference to `____t.7'
    /tmp/cckpduRz.o:fp8.d:(.data+0x70): undefined reference to `____t.8'
    /tmp/cckpduRz.o:fp8.d:(.data+0x74): undefined reference to `____t.9'
    /tmp/cckpduRz.o:fp8.d:(.data+0x78): undefined reference to `____t.10'
    /tmp/cckpduRz.o:fp8.d:(.data+0x7c): undefined reference to `____t.11'
    /tmp/cckpduRz.o:fp8.d:(.data+0x80): undefined reference to `____t.12'
    /tmp/cckpduRz.o:fp8.d:(.data+0x84): undefined reference to `____t.13'
    /tmp/cckpduRz.o:fp8.d:(.data+0x88): undefined reference to `____t.14'
    /tmp/cckpduRz.o:fp8.d:(.data+0x8c): undefined reference to `____t.15'
    /tmp/cckpduRz.o:fp8.d:(.data+0x90): undefined reference to `____t.16'
    /tmp/cckpduRz.o:fp8.d:(.data+0x94): undefined reference to `____t.17'
    /tmp/cckpduRz.o:fp8.d:(.data+0x98): undefined reference to `____t.18'
    /tmp/cckpduRz.o:fp8.d:(.data+0x9c): undefined reference to `____t.19'
    /tmp/cckpduRz.o:fp8.d:(.data+0xa0): undefined reference to `____t.20'
    /tmp/cckpduRz.o:fp8.d:(.data+0xa4): undefined reference to `____t.21'
    /tmp/cckpduRz.o:fp8.d:(.data+0xa8): undefined reference to `____t.22'
    /tmp/cckpduRz.o:fp8.d:(.data+0xac): undefined reference to `____t.23'
    /tmp/cckpduRz.o:fp8.d:(.data+0xb0): undefined reference to `____t.24'
    /tmp/cckpduRz.o:fp8.d:(.data+0xb4): undefined reference to `____t.25'
    /tmp/cckpduRz.o:fp8.d:(.data+0xb8): undefined reference to `____t.26'
    /tmp/cckpduRz.o:fp8.d:(.data+0xbc): undefined reference to `____t.27'
    /tmp/cckpduRz.o:fp8.d:(.data+0xc0): undefined reference to `____t.28'
    /tmp/cckpduRz.o:fp8.d:(.data+0xc4): undefined reference to `____t.29'
    /tmp/cckpduRz.o:fp8.d:(.data+0xc8): undefined reference to `____t.30'
    /tmp/cckpduRz.o:fp8.d:(.data+0xcc): undefined reference to `____t.31'
    /tmp/cckpduRz.o:fp8.d:(.data+0xd0): undefined reference to `____t.32'
    /tmp/cckpduRz.o:fp8.d:(.data+0xd8): undefined reference to `____t.34'
    /tmp/cckpduRz.o:fp8.d:(.data+0xdc): undefined reference to `____t.35'
    collect2: ld gab 1 als Ende-Status zurück
    
  2. opticron

    I'm getting this issue as well. I'm using the recommended build instructions on the main page (after attempting to use my own GDC build script and failing). Can't link anything :/ Two examples of my errors:

    /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../lib32/libgphobos.a(socketstream.o):(.data+0x13c): undefined reference to `___t.35'
    /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/../../../../lib32/libgphobos.a(cstream.o):(.data+0x90): undefined reference to `___t.0'
    
  3. opticron

    Trying to narrow down where this was introduced now...(after r758 and before r777, multiple definition of these symbols in r767).

  4. opticron

    8ce24563e42e is where my code starts breaking post-compilation (socket related). The actual error messages (stream/socket related) start showing up in later commits and I haven't tracked that down quite yet.

  5. Anonymous

    Same issue here:

    andres-macbook-pro:gtk_test aw$ gdc -I/opt/local/include/d -L/opt/local/lib -lgphobos2 -lgtkd -m64 -O2 test.d
    Undefined symbols for architecture x86_64:
      "____t.0", referenced from:
          __D3gtk5Label5Label7__ClassZ in libgtkd.a(Label.o)
          __D3gtk6Window6Window7__ClassZ in libgtkd.a(Window.o)
          __D3gtk9Container9Container7__ClassZ in libgtkd.a(Container.o)
          __D3gtk3Bin3Bin7__ClassZ in libgtkd.a(Bin.o)
          __D3gtk4Misc4Misc7__ClassZ in libgtkd.a(Misc.o)
      "____t.2", referenced from: ... as above ...
      "____t.3", referenced from: ... as above ...
      "____t.4", referenced from: ... as above ...
      "____t.5", referenced from: ... as above ...
      "____t.6", referenced from: ... as above ...
      "____t.7", referenced from: ... as above ...
      "____t.8", referenced from: ... as above ...
      "____t.9", referenced from: ... as above ...
      "____t.10", referenced from: ... as above ...
      "____t.11", referenced from: ... as above ...
    
  6. Lars Ivar Igesund

    I appear to have the same/similar issue, but without using -flto (at least not explicitly).

    My gdc is configured to provide D1.

    I first compiled Tango into libgtango, using bob, no special switches. I then compiled my application, giving gdc all the sources, and -defaultlib=gtango

    Now, when my application is linked, I get a bunch of ___t.x missing references from a bunch of the object files in libgtango (presumably those used).

  7. Johannes Pfau

    Here's a reduced test case without LTO:

    module stream;
    
    interface OutputStream
    {
        void writeExact(const void* buffer, size_t a);
        void flush();
    }
    
    class Stream : OutputStream
    {
        void writeExact(const void* buffer, size_t a) {}
        void flush() {}
    }
    
    import stream;
    
    class CFile : Stream
    {
        void flush() { }
    }
    
    void main() {}
    

    Compile like this: (also happens with -nostdlib and without the main, but then you'll of course have other linker errors as well)

    gdc stream.d cstream.d
    /tmp/ccHnHq6q.o:(.data+0x50): undefined reference to `___t.0'
    collect2: ld returned 1 exit status
    
  8. Daniel Green

    After some digging, I've discovered why e060d079e138 breaks thunks with interfaces.

    1. DMD requires any class that inherits from an interface, to output thunks for that interface. It's irrelevant how far back that inheritance took place. This is why it's always the second generation class that has the issue. As the first generation is required to implement all methods.
    2. Prior to the mentioned changeset. GDC would force the generation of thunk functions. As of now, it relies upon the the GCC backend to output thunk functions.
    3. The GCC backend will only generate thunks when a function is generated. So attempting to generate thunks for external functions fails.

    I've looked over thunk generation in the GCC backend and as far as I can tell it only outputs aliases when the function is output as well. If there is no function to output no thunk will be generated.

    edit: clarified some stuff.

  9. Anonymous

    Finally I know which one is the last known working changeset (00b19ad7e81f). How do you get along with fixing this issue? I couldn't build a working compiler since this happened 3 months ago. You must be using some workaround in the meantime, right?

  10. Anonymous

    I'm getting dozens of these errors (Undefined reference to _t.xxx) when trying to build gtkd. Is there a workaround?

  11. Anonymous

    I'm having the exact same issue, also trying to compile gtkd under Windows. Was is the last windows binary release without this bug?

  12. Anonymous

    I posted comment #14, try if that reversion works for you.

    In the mean time i moved on to the GitHub branch gcc-4.x-compat which works with my GCC 4.6.2. The master branch on GitHub is only compatible with the mainline development version (now at 4.8.x or so). With this compatibility branch I can compile GtkD including the options -O3, -ffunction-sections, -fdata-sections (excluding LTO). So try that if GtkD is your only problem.

    If you get get _t.xxx errors on some sources, that involve what is described in #12, then try the revision given in #14, which is probably the most stable one available at the moment.

    -- Marco <mleise>

  13. Anonymous

    Sorry for the incorrect links, I thought they would create local links to the comments.

  14. Calrama

    Just tried a few things with gdc git master + gcc svn trunk (see config.log for the options):

    The first code piece (see original post at top)

    now actually compiles (and links) fine with either command:

    gdc lto01.d
    gdc -O2 -flto lto01.d -o lto01
    

    while the second code piece

    https://bitbucket.org/goshawk/gdc/issue/284/lto-undefined-reference-to#comment-1046308

    does not and gives different errors whether its done with -flto or without, see lto02.log and lto02_flto.log,

    the third code piece

    https://bitbucket.org/goshawk/gdc/issue/284/lto-undefined-reference-to#comment-1121360

    does neither with the same error that was given in the comment and another code piece does not compile as well (see lto04.log):

    import std.cstream;
    
    void main(string[] args)
    {
        auto input = din.toString();
    }
    

    I already tried to revert the commit that broke it by hand (on current master) and that didn't go so well (internal compiler error(s) when trying to compile gdc) and using the compat branch isn't really an option because I need the 2.058 updates (and they aren't in the compat branch afaict), is there any news about this in sight?

  15. Calrama

    That's great, thanks!

    Just one thing: Could you try whether the code in the zip compiles+links with the new version (make) before marking this issue as resolved? The same code compiles+links fine with dmd (make dmd), but not with gdc (error message below); since it's also about undefined references, but different ones I'm not sure whether this is even really related to this issue. Sorry about the amount of src, but I wasn't able to remove more files while still keeping the error (e.g. semitwist without goldie alone compile+links fine, but if goldie+semitwist together, I get the error in the semitwist file...).

    gdc  -omain main.d  semitwist/refbox.d semitwist/treeout.d semitwist/cmdlineparser.d  semitwist/util/array.d semitwist/util/text.d semitwist/util/container.d semitwist/util/io.d semitwist/util/all.d semitwist/util/os.d semitwist/util/mixins.d semitwist/util/ctfe.d semitwist/util/process.d semitwist/util/reflect.d semitwist/util/ver.d semitwist/util/unittests.d semitwist/util/functional.d  goldie/base.d goldie/lexer.d goldie/exception.d goldie/all.d goldie/lang.d goldie/parser.d goldie/file.d goldie/token.d goldie/langHelper.d goldie/ver.d  goldie/grmc/ast.d goldie/grmc/fsm.d goldie/grmc/gendfa.d goldie/grmc/genlalr.d goldie/grmc/process.d    goldie/langs/grm/lexer.d goldie/langs/grm/all.d goldie/langs/grm/lang.d goldie/langs/grm/parser.d goldie/langs/grm/token.d goldie/langs/grm/langHelper.d tools/util.d
    /tmp/ccCA7LrV.o: In function `_D9semitwist4util4text22__T12unindentImplTAyaZ12unindentImplFAAyaAyaZAAya119__T6reduceS104_D9se
    mitwist4util4text22__T12unindentImplTAyaZ12unindentImplFAAyaAyaZAAya17shorterAndNonNullMFAyaAyaZ
    AyaZ16__T6reduceTAAyaZ6reduceMFAAyaZAya':
    main.d:(.text+0x7e00): undefined reference to `_D9semitwist4util4text22__T12unindentImplTAyaZ12unindentImplFAAyaAyaZAAya119__T6reduceS104_D9se
    mitwist4util4text22__T12unindentImplTAyaZ12unindentImplFAAyaAyaZAAya17shorterAndNonNullMFAyaAyaZ
    AyaZ20__T6reduceTAyaTAAyaZ6reduceMFAyaAAyaZAya'
    collect2: error: ld returned 1 exit status
    

    PS: I don't own Goldie or Semitwist

  16. Calrama

    Thank you for the fix, just compiled latest gdc+gcc and tested with these results:

    This

    gdc lto0(1/2/4).d
    gdc -O2 -flto lto0(1/4).d
    

    works, but this still gives undefined references (see lto02.log):

    gdc -O2 -flto lto02.d -o lto02
    

    lto02.d:

    import std.stream;
    
    class Foo : Stream
    {
            override void flush() {}
    }
    
    void main(string[] args) {}
    
    

    lto02.log:

    gdc -O2 -flto lto02.d
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x50): undefined reference to `___t.0.2518.2384'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x54): undefined reference to `___t.1.2520.2387'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x58): undefined reference to `___t.2.2522.2393'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x5c): undefined reference to `___t.3.2524.2395'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x60): undefined reference to `___t.4.2526.2397'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x64): undefined reference to `___t.5.2528.2399'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x68): undefined reference to `___t.6.2530.2401'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x6c): undefined reference to `___t.7.2532.2403'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x70): undefined reference to `___t.8.2534.2405'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x74): undefined reference to `___t.9.2536.2407'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x78): undefined reference to `___t.10.2538.2409'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x7c): undefined reference to `___t.11.2540.2411'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x80): undefined reference to `___t.12.2542.2413'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x84): undefined reference to `___t.13.2544.2415'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x88): undefined reference to `___t.14.2546.2418'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x8c): undefined reference to `___t.15.2548.2421'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x90): undefined reference to `___t.16.2550.2424'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x94): undefined reference to `___t.17.2552.2426'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x98): undefined reference to `___t.18.2554.2428'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0x9c): undefined reference to `___t.19.2556.2430'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xa0): undefined reference to `___t.20.2558.2432'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xa4): undefined reference to `___t.21.2560.2434'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xa8): undefined reference to `___t.22.2562.2437'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xac): undefined reference to `___t.23.2564.2442'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xb0): undefined reference to `___t.24.2566.2447'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xb4): undefined reference to `___t.25.2568.2449'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xb8): undefined reference to `___t.26.2570.2451'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xbc): undefined reference to `___t.27.2572.2453'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xc0): undefined reference to `___t.28.2574.2455'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xc4): undefined reference to `___t.29.2576.2457'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xc8): undefined reference to `___t.30.2578.2471'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xcc): undefined reference to `___t.31.2580.2475'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xd0): undefined reference to `___t.32.2582.2477'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xd8): undefined reference to `___t.34.2584.2479'
    /tmp/cchTaPiq.ltrans0.ltrans.o:(.data+0xdc): undefined reference to `___t.35.2586.2481'
    collect2: error: ld returned 1 exit status
    
  17. Calrama

    Just compiled and tested with latest gdc git and gcc svn. I can confirm that the reported lto errors are gone.

    Sadly the undefinered reference error in undref.zip isn't gone and thus it is not the same bug. I'll open another issue for it.

  18. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.