I am using cc
crate in build.rs
. My current target is x86_64-unknown-uefi
. I set CC
to cl
and AR
to lib
in environment variable. It seems cc
crate recognizes cl
and used proper arguments to compile C codes, but it seems cc
crate doesn't recognize lib
as archiver and it didn't use correct arguments. Things became:
lib cq liboutput.a input1.o input2.o ...
where cq
is ar
-specific: lib
recognize cq
as a file name instead of a command.
I think I can make up some scripts to wrap lib
into ar
, but is there any options that let cc
crate actually use lib
properly?
normally cc
should support the msvc tools very well. maybe it doesn't know the uefi
target should use the msvc toolchain.
search for uefi
in the issue tracker, I found #606 but they were cross compiling from linux host using clang. maybe you want to open a feature request to cc
for support of the uefi
target.
in the mean time, you can try this workaround by tricking cc
to build for the -windows-msvc
target. I might be wrong, but I think a static library built for windows is compatible with uefi:
cc::Build::new()
.file("src/foo.c")
.target("x86_64-pc-windows-msvc")
.compile("foo");
Thanks for your answer! I haven't tried using -windows-msvc
target yet, but I accidentally found that LLVM provides llvm-ar
, which can replace the job as lib
and it worked well. So setting AR=llvm-ar
in environment variable can solve the issue.