Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 700126 - app-emulation/dosemu fails to compile with LTO
Summary: app-emulation/dosemu fails to compile with LTO
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Sergei Trofimovich (RETIRED)
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2019-11-14 23:56 UTC by Robert Gill
Modified: 2024-03-11 22:48 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
fix compilation with -flto flag (dosemu-1.4.1_pre20130107-fix-lto.patch,594 bytes, patch)
2019-11-14 23:56 UTC, Robert Gill
Details | Diff
fix compilation with -flto flag (alternative) (dosemu-1.4.1_pre20130107-fix-lto.patch,6.46 KB, patch)
2019-11-16 01:28 UTC, Robert Gill
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Gill 2019-11-14 23:56:45 UTC
Created attachment 596184 [details, diff]
fix compilation with -flto flag

Due to name mangling, gcc seems to have issues with referencing static functions in inline assembly sections when compiling with -flto. The included patch disables LTO when compiling the dosemu source file cpatch.c. This allows dosemu to be compiled when the -flto flag is included in CFLAGS.
Comment 1 Sergei Trofimovich (RETIRED) gentoo-dev 2019-11-15 12:12:49 UTC
-fno-lto is an unportable workaround. I would prefer making the symbol directly usable for assembly. There should be a few ways to do it.

With CFLAGS='-flto -O2' CXXFLAGS='-flto -O2' the build failure looks like that:

x86_64-pc-linux-gnu-gcc -Wl,-warn-common -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -rdynamic -o ../1.4.0.8/bin/dosemu.bin emu.o \
   -Wl,--whole-archive lib/libenv_video.a lib/libbase.a lib/libbase_async.a lib/libarch_linux_async.a lib/libarch_linux_mapping.a lib/libbase_misc.a lib/libbase_misc_libpcl.a lib/libbase_dev_misc.a lib/libemu-i386.a lib/libemu-i386_simx86.a lib/libenv.a lib/libbase_speaker.a lib/libbase_dev_pic.a lib/libdosext_dpmi.a lib/libdosext_mfs.a lib/libdosext_misc.a lib/libbase_init.a lib/libbase_serial.a lib/libbase_mouse.a lib/libbase_dev_dma.a lib/libarch_linux_debugger.a lib/libdosext_net_net.a lib/libdosext_sound.a lib/libarch_linux_dosext_sound.a lib/libbase_dev_sb16.a lib/libbase_sound.a lib/libdosext_drivers.a lib/libbase_bios.a lib/libplugin_translate.a lib/libplugin_translate_charsets.a lib/libplugin_term.a lib/libplugin_sdl.a lib/libplugin_midimisc.a lib/libplugin_kbd_unicode.a lib/libplugin_gpm.a lib/libplugin_fluidsynth.a lib/libplugin_extra_charsets.a lib/libplugin_commands.a lib/libplugin_alsa.a lib/libplugin_X.a -Wl,--no-whole-archive -lrt  -ldl -lm
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_rep__':
<artificial>:(.text+0xe): undefined reference to `rep_movs_stos'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_stk_16__':
<artificial>:(.text+0x25): undefined reference to `stk_16'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_stk_32__':
<artificial>:(.text+0x3a): undefined reference to `stk_32'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_wri_8__':
<artificial>:(.text+0x4c): undefined reference to `wri_8'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_wri_16__':
<artificial>:(.text+0x5a): undefined reference to `wri_16'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_wri_32__':
<artificial>:(.text+0x68): undefined reference to `wri_32'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_movsb__':
<artificial>:(.text+0x7f): undefined reference to `wri_8'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_movsw__':
<artificial>:(.text+0x9a): undefined reference to `wri_16'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_movsl__':
<artificial>:(.text+0xb3): undefined reference to `wri_32'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_stosb__':
<artificial>:(.text+0xcb): undefined reference to `wri_8'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_stosw__':
<artificial>:(.text+0xe4): undefined reference to `wri_16'
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/dosemu.bin.h8Y59G.ltrans0.ltrans.o: in function `stub_stosl__':
<artificial>:(.text+0xfc): undefined reference to `wri_32'
collect2: error: ld returned 1 exit status
Comment 2 Larry the Git Cow gentoo-dev 2019-11-15 12:31:07 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=328509762ae5fa834d72e58858252200ed52f6a8

commit 328509762ae5fa834d72e58858252200ed52f6a8
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2019-11-15 12:30:08 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2019-11-15 12:31:00 +0000

    app-emulation/dosemu: fix LTO build, bug #700126
    
    Reported-by: Robert Gill
    Closes: https://bugs.gentoo.org/700126
    Package-Manager: Portage-2.3.79, Repoman-2.3.18
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 .../dosemu/dosemu-1.4.1_pre20130107-r5.ebuild      |  1 +
 .../files/dosemu-1.4.1_pre20130107-lto.patch       | 27 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)
Comment 3 Robert Gill 2019-11-16 01:27:01 UTC
(In reply to Sergei Trofimovich from comment #1)
> -fno-lto is an unportable workaround. I would prefer making the symbol
> directly usable for assembly. There should be a few ways to do it.

I'm attaching another patch that's pretty hacky and I'm not at all sure if it's any more portable, but it allows the concerned functions to be included in LTO.
-fno-lto is unnecessary. You may use it as an alternative to the previous patch.
Comment 4 Robert Gill 2019-11-16 01:28:00 UTC
Created attachment 596302 [details, diff]
fix compilation with -flto flag (alternative)
Comment 5 Robert Gill 2019-11-16 22:21:02 UTC
Whoops, didn't bother looking at the commit. I guess exporting the symbols is the cleanest way to go.