Cargo/Build scripts tend to build/link with (lowercase) cc. On FreeBSD this is hard linked to clang.
No matter how I set CC, CXX, and so on, cc always = clang.
Some crates require to be built with gcc. How can I set this?
Cargo/Build scripts tend to build/link with (lowercase) cc. On FreeBSD this is hard linked to clang.
No matter how I set CC, CXX, and so on, cc always = clang.
Some crates require to be built with gcc. How can I set this?
Anything compiled using gcc-rs should respect CC
, CFLAGS
etc: https://github.com/alexcrichton/gcc-rs#external-configuration-via-environment-variables. If things are shelling out to cc
manually you'd have to file issue with those projects.
Servo is one example that won't build. Many of the dependency crates won't build because of some gcc-only functions expected in 'cc'.
Output:
error: linking with 'cc' failed: exit code: 1
...
/usr/lib/libgcc_s.so: error: undefined reference .......
Replacing cc with gcc and running the printed command string manually works. I don't think this is in the specific crates but rather Cargo that links using 'cc'.
The standard linker is indeed cc
, but you can use an environment variable to change it: https://github.com/rust-lang/rust/blob/b14785d/src/librustc_back/target/mod.rs#L406
That environment variable is checked at rustc build time, by the way. If you already have a rustc, you can use cargo's configuration to change the linker: Page Moved
Thanks for pointing me in the right direction.
I got it building by adding linker = gcc
to .cargo/config
To get the default (clang) to find libraries properly, I needed to add "-L/usr/local/lib"
to rustflags in [target.x86_64-unknown-freebsd]
section.