bochs-emu / Bochs

Bochs - Cross Platform x86 Emulator Project
https://bochs.sourceforge.io/
GNU Lesser General Public License v2.1
903 stars 108 forks source link

Version with debugger enabled fails to build with MSYS2 #394

Open Vort opened 1 day ago

Vort commented 1 day ago

This is what I see when I try to build Bochs with --enable-debugger --enable-debugger-gui with MSYS2 and clang:

g++ -o bochs -O3 -Wall -Wno-format -mno-ms-bitfields -DWIN32 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES     -DBX_SHARE_PATH='"/clang64/share/bochs"'   logio.o main.o config.o pc_system.o osdep.o plugin.o crc.o bxthread.o win32res.o  \
        iodev/libiodev.a iodev/display/libdisplay.a iodev/hdimage/libhdimage.a iodev/usb/libusb.a iodev/network/libnetwork.a iodev/sound/libsound.a \
        bx_debug/libdebug.a cpu/libcpu.a cpu/avx/libavx.a cpu/cpudb/libcpudb.a \
         memory/libmemory.a gui/libgui.a \
          \
         cpu/fpu/libfpu.a cpu/softfloat3e/libsoftfloat.a \
        -lws2_32 -luser32 -lgdi32 -lcomdlg32 -lcomctl32 -lshell32 \
        -liphlpapi -lws2_32 -lwinmm \
         \
         \
        -lreadline \
        -static \

ld.lld: error: undefined symbol: tputs
>>> referenced by libreadline.a(display.o):(rl_redisplay)
>>> referenced by libreadline.a(display.o):(rl_redisplay)
>>> referenced by libreadline.a(display.o):(rl_redisplay)
>>> referenced 19 more times

ld.lld: error: undefined symbol: tgetnum
>>> referenced by libreadline.a(terminal.o):(_rl_get_screen_size)
>>> referenced by libreadline.a(terminal.o):(_rl_get_screen_size)

ld.lld: error: undefined symbol: tgetent
>>> referenced by libreadline.a(terminal.o):(_rl_init_terminal_io)

ld.lld: error: undefined symbol: tgetstr
>>> referenced by libreadline.a(terminal.o):(_rl_init_terminal_io)

ld.lld: error: undefined symbol: tgetflag
>>> referenced by libreadline.a(terminal.o):(_rl_init_terminal_io)
>>> referenced by libreadline.a(terminal.o):(_rl_init_terminal_io)
>>> referenced by libreadline.a(terminal.o):(_rl_init_terminal_io)

ld.lld: error: undefined symbol: BC
>>> referenced by libreadline.a(terminal.o):(.refptr.BC)

ld.lld: error: undefined symbol: PC
>>> referenced by libreadline.a(terminal.o):(.refptr.PC)

ld.lld: error: undefined symbol: UP
>>> referenced by libreadline.a(terminal.o):(.refptr.UP)
g++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:180: bochs] Error 1

If I replace -lreadline with -lreadline -lncurses, build finishes correctly.

I did not figured out yet how to make correct change to build scripts.

Version: dbfb11f1ddd42f784af5089e24ec16cfaf683555

vruppert commented 11 hours ago

In the configure script there are checks whether or not readline needs the curses library. Checks for curses variants are only present if the term gui is compiled in. For testing you could try to build with --with-term. If this helps, I can have a look how to make the readline checks work correctly.

Vort commented 10 hours ago

It does not work with MSYS2. There is clang64/mingw-w64-clang-x86_64-ncurses package, which have no pkgconfig files. And there is msys/ncurses-devel package, which have pkgconfig files, but they are not accessible from clang64 environment (PKG_CONFIG_PATH is set to /clang64/lib/pkgconfig:/clang64/share/pkgconfig$, while ncurses-devel package drops file into /usr/lib/pkgconfig).

upd. clang64/mingw-w64-clang-x86_64-ncurses have ncursesw.pc, but no ncurses.pc. I will try to use w variant.

Vort commented 9 hours ago

I tried to use ncursesw, but looks like term.cc compilation in Windows is broken anyway:

term.cc:194:20: error: expression is not assignable
  194 |     stdin = stdout = fdopen(scr_fd,"wr");
term.cc:195:5: error: use of undeclared identifier 'grantpt'
  195 |     grantpt(scr_fd);
      |     ^
term.cc:196:5: error: use of undeclared identifier 'unlockpt'
  196 |     unlockpt(scr_fd);
      |     ^
term.cc:197:60: error: use of undeclared identifier 'ptsname'
  197 |     fprintf(stderr, "\nBochs connected to screen \"%s\"\n",ptsname(scr_fd));
      |      

Looks like this is wrong path. My goal was to obtain Bochs binary with GUI debugger enabled without manual hacking. If console debugging will work, that's a bonus, but GUI mode on windows platform is more important I think.