Flux
Flux

Reputation: 10920

How to compile file using scheme2c

I am trying to compile a Scheme program using scheme2c (the DEC Scheme->C Compiler). This is the program hello.sc:

(module hello (main run-main))

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

I tried to compile the program using scc hello.sc, but the compilation fails with these linker error messages:

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

How do I compile a Scheme program using scc?

(scheme2c version 2012.10.14 on Ubuntu 20.04.4 LTS)

Upvotes: 1

Views: 2381

Answers (1)

Flux
Flux

Reputation: 10920

PIE is enabled by default in Ubuntu's GCC (Ubuntu compiles GCC using the --enable-default-pie option).

The problem can be solved by using GCC's -no-pie option:

$ scc -cc 'gcc -no-pie' hello.sc
hello.sc:
$ ./a.out
Hello!

Upvotes: 1

Related Questions