如何使用scheme2c编译文件



我正在尝试使用scheme2c (DEC Scheme->C编译器)编译Scheme程序。这是程序hello.sc:

(module hello (main run-main))
(define (run-main)
(display "Hello!")
(newline))

我尝试使用scc hello.sc编译程序,但是编译失败,出现以下链接器错误消息:

hello.sc:
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scinit.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(apply.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(callcc.o): relocation R_X86_64_32S against symbol `sc_display' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(cio.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(heap.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(objects.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scdebug.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(sceval.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpand.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpnd1.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scexpnd2.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(screp.o): relocation R_X86_64_32S against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt1.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt2.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt3.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt4.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt5.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt6.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scrt7.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: /usr/lib/scheme2c/libs2c.a(scqquote.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status

如何使用scc编译Scheme程序

(scheme2c version 2012.10.14 on Ubuntu 20.04.4 LTS)

PIE在Ubuntu的GCC中是默认启用的(Ubuntu使用--enable-default-pie选项编译GCC)。

这个问题可以通过使用GCC的-no-pie选项来解决:
$ scc -cc 'gcc -no-pie' hello.sc
hello.sc:
$ ./a.out
Hello!

最新更新