Fail to build y86-64 simulator from sources

佐手、 提交于 2019-12-02 15:35:52

问题


I am attempting to compile a simulator for Y86-64 code on Linux.I have already rewritten the makefile but it turned out like below.It said "undefined reference for 'matherr'".(Looks like it connects with gcc when linking)

(cd pipe; make all GUIMODE=-DHAS_GUI TKLIBS="-L/usr/lib/ -ltk8.5 -ltcl8.5" TKINC="-I/usr/include/tcl8.5 ")
    make[1]: 进入目录“/home/gongchen/桌面/ICS/archlab-handout/sim/pipe”
    # Building the pipe-std.hcl version of PIPE
    ../misc/hcl2c -n pipe-std.hcl < pipe-std.hcl > pipe-std.c
    gcc -Wall -O2 -I/usr/include/tcl8.5  -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
        ../misc/isa.c -L/usr/lib/ -ltk8.5 -ltcl8.5 -lm
    /tmp/cchKTZy7.o:(.data.rel+0x0):对‘matherr’未定义的引用
    collect2: error: ld returned 1 exit status
    Makefile:42: recipe for target 'psim' failed
    make[1]: *** [psim] Error 1
    make[1]: 离开目录“/home/gongchen/桌面/ICS/archlab-handout/sim/pipe”
    Makefile:28: recipe for target 'all' failed
    make: *** [all] Error 2

回答1:


gcc -Wall -O2 -I/usr/include/tcl8.5  -I../misc -DHAS_GUI -o psim psim.c pipe-std.c \
    ../misc/isa.c -L/usr/lib/ -ltk8.5 -ltcl8.5 -lm
/tmp/cchKTZy7.o:(.data.rel+0x0):对‘matherr’未定义的引用

You are linking and getting an undefined reference error to matherr.

It looks like matherr is part of SVID math library. According to the matherr(3) man page the symbol is no longer present in Glibc 2.27 or above.

DESCRIPTION

Note: the mechanism described in this page is no longer supported by glibc. Before glibc 2.27, it had been marked as obsolete. Since glibc 2.27, the mechanism has been removed altogether. New applications should use the techniques described in math_error(7) and fenv(3). This page documents the matherr() mechanism as an aid for maintaining and porting older applications.

The math_error(7) man page says that you should do the following to check for errors:

  1. set errno to zero
  2. call feclearexcept(FE_ALL_EXCEPT);

After the math calculation completes you should check the following for non-zero value to indicate error:

  1. errno
  2. fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW);

Since you are a guy or gal trying to use the program (and not a maintainer) I suggest two courses of actions. The strategy is to use a distro where things just work, and punt to the Y86 maintainer to fix it.

First, use a different, older distro that provides Glibc 2.26 or early. Something like Debian 8 (Glibc 2.19) or Fedora 25 (Glibc 2.24) should do just fine.

Second, file a bug report against Y86 project. The Y86 maintainers need to fix the problem, not students trying to learn the class material.




回答2:


My classmates have a way to solve this problem: comment the code related to matherr, like the code in the picture. And the GUI mode works. 好厉害!



来源:https://stackoverflow.com/questions/52903488/fail-to-build-y86-64-simulator-from-sources

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!