Error: /usr/bin/ld: cannot find -lgcc_s

Hi all,

I am building bitvisor-1.1, a hypervisor with clang. I am getting the
following error with the trunk while compiling it
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc_s

I am able to compile it successfully with gcc. I tried with clang-2.8
and I was getting the following error.

"Unsupported asm: input constraint with a matching output constraint
of incompatible type!"

I changed the CC in Makefile to clang -v, I get the following information

clang -v -Wl,-melf_x86_64 -g -nostdlib -Wl,-r -o ccid.o IDMan_CcAtr.o
IDMan_CcIfdhandler.o IDMan_CcInitCard.o IDMan_CcProtocol.o
IDMan_CcReaderControl.o IDMan_CcUsb.o
clang version 2.9 (trunk 118799)
Target: x86_64-unknown-linux-gnu
Thread model: posix
clang: warning: argument unused during compilation: '-g'
"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m
elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o ccid.o
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtbegin.o
-L/usr/lib/gcc/x86_64-linux-gnu/4.4.5
-L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../..
-L/usr/lib/x86_64-linux-gnu -melf_x86_64 -r IDMan_CcAtr.o
IDMan_CcIfdhandler.o IDMan_CcInitCard.o IDMan_CcProtocol.o
IDMan_CcReaderControl.o IDMan_CcUsb.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crtn.o
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any suggestions on how I can get clang to compile bitvisor-1.1?

Santosh

Any suggestions on how I can get clang to compile bitvisor-1.1?

This is probably the driver missing support for your OS. Are you using
linux? What distro?

Santosh

Cheers,
Rafael

I am using Ubuntu 10.10 maverick with Linux kernel 2.6.35-22-generic on x86_64

Thanks,
Santosh

2010/11/11 Rafael Espíndola <rafael.espindola@gmail.com>

I am using Ubuntu 10.10 maverick with Linux kernel 2.6.35-22-generic on
x86_64

I think this was fixed on 118878. Let me know if you have any problems.

Thanks,
Santosh

Cheers,
Rafael

Thanks. Yes that was fixed. However, clang still does not compile the
hypervisor.

When I compile the callrealmode.c (in attached directory), clang gives
the following error.

callrealmode.c:62:3: error: invalid instruction mnemonic 'lretq'
                "push %%rax\n"
                ^
<inline asm>:20:1: note: instantiated into assembly here
lretq
^
callrealmode.c:62:3: error: warning: ignoring directive for now
                "push %%rax\n"
                ^
<inline asm>:21:1: note: instantiated into assembly here
.code32
^
callrealmode.c:62:3: error: instruction requires a CPU feature not
currently enabled
                "push %%rax\n"

However, just replace clang with gcc works. I used the following
commandline to compile the flags.

clang -m64 -mno-red-zone -g -O -nostdinc -fno-builtin -Wall
-DCPU_MMU_SPT_3 -DCPU_MMU_SPT_USE_PAE -DF12MSG -DDBGSH -DCRYPTO_VPN
-DACPI_DSDT -DDISABLE_SLEEP -DENABLE_ASSERT -DCARDSTATUS -DIDMAN
-DVPN_VE -DTTY_PRO1000 -DDISABLE_TCG_BIOS -DACPI_TIME_SOURCE -DUSE_PAE
-Iinclude -fno-stack-protector -mno-sse -c -o callrealmode.o
callrealmode.c

Any suggestions? Should I file a bug report?

Thanks,
Santosh

build.tar.gz (48.1 KB)

However, just replace clang with gcc works. I used the following
commandline to compile the flags.

clang -m64 -mno-red-zone -g -O -nostdinc -fno-builtin -Wall
-DCPU_MMU_SPT_3 -DCPU_MMU_SPT_USE_PAE -DF12MSG -DDBGSH -DCRYPTO_VPN
-DACPI_DSDT -DDISABLE_SLEEP -DENABLE_ASSERT -DCARDSTATUS -DIDMAN
-DVPN_VE -DTTY_PRO1000 -DDISABLE_TCG_BIOS -DACPI_TIME_SOURCE -DUSE_PAE
-Iinclude -fno-stack-protector -mno-sse -c -o callrealmode.o
callrealmode.c

Any suggestions? Should I file a bug report?

Please do. Run the above command with -v -save-temps and include both
the callrealmode.i file and the "clang -cc1" command line.

Thanks,
Santosh

Thanks,
Rafael

This is definitely an integrated assembler bug, I'll investigate tomorrow if I have time.

-Chris

I have filed a bug report 8592. It is available at
http://llvm.org/bugs/show_bug.cgi?id=8592

Thanks,
Santosh

This reduces to just:

Fixed in r118903, thanks!

-Chris

But still persists. Its the lretl instruction now.
I have attached the callrealmode.i file with this email. I will
update the bug report as well

cc1 commandline is as below

"/home/santoshn/llvm/llvm-svn-obj/Debug+Asserts/bin/clang" -cc1
-triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name
callrealmode.c -mrelocation-model static -mdisable-fp-elim
-masm-verbose -mconstructor-aliases -munwind-tables -disable-red-zone
-target-cpu x86-64 -target-feature -sse -target-linker-version 2.20.51
-v -g -nostdinc -resource-dir
/home/santoshn/llvm/llvm-svn-obj/Debug+Asserts/bin/../lib/clang/2.9
-O2 -Wall -ferror-limit 19 -fmessage-length 156 -fno-builtin
-fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o
callrealmode.s -x cpp-output callrealmode.i

Santosh

callrealmode.i (25.1 KB)