Fail to build y86-64 simulator from sources

2019-08-23 12:28发布

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

标签: linux y86
2条回答
霸刀☆藐视天下
2楼-- · 2019-08-23 12:53

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. 好厉害! enter image description here

查看更多
别忘想泡老子
3楼-- · 2019-08-23 12:56
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.

查看更多
登录 后发表回答