Is fPIC broken on x86_64 in LLVM 2.6? I looked through the release notes but did not see anything mentioned. When I try: ------------------- > llvm-gcc -Iinclude -emit-llvm -fPIC -O3 -c -o file.opt.bc file.c > llvm-ld -native -Xlinker=-shared -Xlinker=-Wl,-soname,libtest.so -o file.so file.opt.bc ------------------- on an x86 machine it works fine. When I try it on x86_64, the linking command complains with: ------------------- /usr/bin/ld: /tmp/ccjE1tcG.o: relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC /tmp/ccjE1tcG.o: could not read symbols: Bad value collect2: ld returned 1 exit status llvm-ld: ------------------- Thanks, Ryan
> Is fPIC broken on x86_64 in LLVM 2.6?No, it works w/o any problems> ------------------- > > llvm-gcc -Iinclude -emit-llvm -fPIC -O3 -c -o file.opt.bc file.c > > llvm-ld -native -Xlinker=-shared -Xlinker=-Wl,-soname,libtest.so -o > file.so file.opt.bc > -------------------PIC-ness is a backend option. So, passing -fPIC to llvm-gcc does not make any sense, it is not saved into the bytecode. Try passing -relocation-model=pic to llvm-ld, or just compile everything via llvm-gcc which known how to pass necessary options to backend :) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
On Sun, Oct 3, 2010 at 11:13 AM, Anton Korobeynikov <anton at korobeynikov.info> wrote:>> Is fPIC broken on x86_64 in LLVM 2.6? > No, it works w/o any problems > >> ------------------- >> > llvm-gcc -Iinclude -emit-llvm -fPIC -O3 -c -o file.opt.bc file.c >> > llvm-ld -native -Xlinker=-shared -Xlinker=-Wl,-soname,libtest.so -o >> file.so file.opt.bc >> ------------------- > PIC-ness is a backend option. So, passing -fPIC to llvm-gcc does not > make any sense, it is not saved into the bytecode. > Try passing -relocation-model=pic to llvm-ld, or just compile > everything via llvm-gcc which known how to pass necessary options to > backend :)Alternately, use Clang to compile your bitcode files, which also knows how to pass the necessary options to the backend in that case! :) - Daniel> -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
The reason I was linking via llvm-ld is because I didn't know how to pass bitcode files to llvm-gcc. How can I do that? Anton Korobeynikov wrote:>> Is fPIC broken on x86_64 in LLVM 2.6? > No, it works w/o any problems > >> ------------------- >> > llvm-gcc -Iinclude -emit-llvm -fPIC -O3 -c -o file.opt.bc file.c >> > llvm-ld -native -Xlinker=-shared -Xlinker=-Wl,-soname,libtest.so -o >> file.so file.opt.bc >> ------------------- > PIC-ness is a backend option. So, passing -fPIC to llvm-gcc does not > make any sense, it is not saved into the bytecode. > Try passing -relocation-model=pic to llvm-ld, or just compile > everything via llvm-gcc which known how to pass necessary options to > backend :) >