Can't run simple program

I’m not able to run a simple program by using archlinux binaries from the community repository. I was able to run crystal scripts in the past without issues.

➜ ~ uname -a
Linux marcos-arch 5.4.32-1-lts #1 SMP Mon, 13 Apr 2020 12:21:10 +0000 x86_64 GNU/Linux

➜ ~ crystal -v
Crystal 0.34.0 (2020-04-07)
LLVM: 9.0.1
Default target: x86_64-pc-linux-gnu

➜ ~ cat test.cr
pp “hi”

➜ ~ crystal test.cr
/usr/bin/ld: /usr/local/lib/libgc.a(alloc.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(blacklst.o): relocation R_X86_64_32 against .rodata.str1.1’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(finalize.o): relocation R_X86_64_32 against símbolo GC_ll_hashtbl' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(headers.o): relocation R_X86_64_32S against símbolo GC_arrays’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(malloc.o): relocation R_X86_64_32 against símbolo GC_allocate_ml' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(mallocx.o): relocation R_X86_64_32S against símbolo GC_obj_kinds’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(mark.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(mark_rts.o): relocation R_X86_64_32 against símbolo GC_arrays’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(misc.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(new_hblk.o): relocation R_X86_64_32S against símbolo GC_obj_kinds’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(obj_map.o): relocation R_X86_64_32S against símbolo GC_arrays' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(os_dep.o): relocation R_X86_64_32 against símbolo GC_jmp_buf’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(reclaim.o): relocation R_X86_64_32 against .rodata.str1.1' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(thread_local_alloc.o): relocation R_X86_64_32 against símbolo GC_arrays’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(pthread_support.o): relocation R_X86_64_32 against símbolo GC_inner_start_routine' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(pthread_stop_world.o): relocation R_X86_64_32 against .rodata.str1.1’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(allchblk.o): relocation R_X86_64_32S against símbolo GC_obj_kinds' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(dbg_mlc.o): relocation R_X86_64_32 against símbolo GC_check_heap_block’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(dyn_load.o): relocation R_X86_64_32S against .bss' can not be used when making un objeto PIE; recompile with -fPIE /usr/bin/ld: /usr/local/lib/libgc.a(gcj_mlc.o): relocation R_X86_64_32 against símbolo GC_allocate_ml’ can not be used when making un objeto PIE; recompile with -fPIE
/usr/bin/ld: /usr/local/lib/libgc.a(mach_dep.o): relocation R_X86_64_32 against .rodata.str1.8' can not be used when making un objeto PIE; recompile with -fPIE collect2: error: ld devolvió el estado de salida 1 Error: execution of command failed with code: 1: cc “${@}” -o ‘/home/marcos/.cache/crystal/crystal-run-test.tmp’ -rdynamic -lpcre -lm /usr/local/lib/libgc.a -lpthread /usr/lib/crystal/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`

Gc version

➜ ~ pacman -Qi gc |grep Versión
Versión : 8.0.4-3

Same error happens if I try to compile from source.

/usr/local/lib/libgc

Well that’s what’s messing you up, it’s probably some old and /special/ build of libgc.

This is Arch Linux, there’s no good reason to use /usr/local paths; just let the package manager do everything. Globally installing things manually is technical debt from the get-go.

Thanks Oprypin. The binary is from the default repository in Archlinux. Trying to compile it myself also leads to the same issue. Both things worked for me in the past. Please let me know if you need more information. You can see the version of gc package in my comment. My system is fully updated.

The version of gc package is irrelevant here. It resides in /usr/lib. In your error you can see /usr/local/lib. So I would not agree that everything is from Arch Linux repository. If you eliminate the foreign additions, everything will work.

For reference, here’s how /usr/local looks on a good system:

$ tree /usr/local    
/usr/local
├── bin
├── etc
├── games
├── include
├── lib
├── man
├── sbin
├── share
│   └── man -> ../man
└── src

That is, it’s empty.

1 Like

Thanks @oprypin that was it. I probably messed up the installation trying another gc or something and forgot :)

1 Like