Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Q QA-2022s
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • pku-minicpku-minic
  • QA-2022s
  • Issues
  • #4
Closed
Open
Issue created Mar 13, 2022 by 李舒辰@pku1800012789

将mandelbrot编译到riscv后,与fp-math链接时提示__addsf3等未定义

用如下命令编译 mandelbrot.c 及 fp-math.c 并链接:

$ ./compiler -riscv mandelbrot.c -o mandelbrot.S
$ clang mandelbrot.S -c -o mandelbrot.o -target riscv32-unknown-linux-elf -march=rv32im -mabi=ilp32
$ clang fp-math.c -c -o fp-math.o -target riscv32-unknown-linux-elf -march=rv32im -mabi=ilp32
$ ld.lld mandelbrot.o fp-math.o -L$CDE_LIBRARY_PATH/riscv32 -lsysy -o mandelbrot

链接时报错:

ld.lld: error: undefined symbol: __addsf3
>>> referenced by fp-math.c
>>>               fp-math.o:(fp_add)

ld.lld: error: undefined symbol: __subsf3
>>> referenced by fp-math.c
>>>               fp-math.o:(fp_sub)

ld.lld: error: undefined symbol: __mulsf3
>>> referenced by fp-math.c
>>>               fp-math.o:(fp_mul)

ld.lld: error: undefined symbol: __divsf3
>>> referenced by fp-math.c
>>>               fp-math.o:(fp_div)

ld.lld: error: undefined symbol: __ltsf2
>>> referenced by fp-math.c
>>>               fp-math.o:(fp_lt)

ld.lld: error: undefined symbol: __floatsisf
>>> referenced by fp-math.c
>>>               fp-math.o:(to_fp)

ld.lld: error: undefined symbol: __fixsfsi
>>> referenced by fp-math.c
>>>               fp-math.o:(to_int)

这似乎意味着找不到软件浮点库. 我的解决方法是用选项 -march=rv32imf -mabi=ilp32f 重新编译 mandelbrot.S, fp-math.c 以及 /opt/lib/riscv32/libsysy.a (但我并非完全清楚这些选项的含义). 在这之后可以正常链接并输出正确的结果. 然而这样需要更改 libsysy.a, 感觉有点麻烦, 请问有没有更好的解决办法?

Assignee
Assign to
Time tracking