# Rust does not compile



## Alain De Vos (Nov 28, 2019)

Compiling rust from the ports produces an error :

```
--- stderr
error: couldn't load codegen backend "/usr/ports/lang/rust/work/rustc-1.38.0-src/build/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/codegen-backends/librustc_codegen_llvm-llvm.so": "/usr/ports/lang/rust/work/rustc-1.38.0-src/build/x86_64-unknown-freebsd/stage1/lib/rustlib/x86_64-unknown-freebsd/codegen-backends/librustc_codegen_llvm-llvm.so: Undefined symbol \"_ZNKSt3_V214error_category10_M_messageB5cxx11Ei\""
```
For completeness my make.conf:

```
MAKE_JOBS_UNSAFE=yes

MTREE_FOLLOWS_SYMLINKS= -L
BOOTWAIT= 0

MAKE_JOBS_NUMBER= 7
CPUTYPE?= ivybridge

COMPILER_TYPE= clang
CC=      /usr/local/bin/clang90
CXX=     /usr/local/bin/clang++90
CPP=     /usr/local/bin/clang-cpp90
LD=      /usr/local/bin/ld.lld90
NM=      /usr/local/bin/llvm-nm90
OBJDUMP= /usr/local/bin/llvm-objdump90
STRINGS= /usr/local/bin/llvm-strings90

CFLAGS+=    -O2 -pipe
CXXFLAGS+=  -O2 -pipe
#kernel
COPTFLAGS+= -O2 -pipe

DEFAULT_VERSIONS+= python=3.6

#Out_for_chromium
DEFAULT_VERSIONS+= ssl=openssl

DEFAULT_VERSIONS+= ssh=openssh-portable
DEFAULT_VERSIONS+= openssh=openssh-portable

WITH_PKGNG=yes

OPTIONS_SET+= OSS OSS4 SNDIO OPTIMIZED_CFLAGS NO_PROFILE CPUFLAGS BUILD_OPTIMIZED GSSAPI_HEIMDAL
OPTIONS_UNSET+= DEBUG ALSA JACK  PULSE PULSEAUDIO AO LIBAO SPEEX LIBSPEEX SAMPLERATE LIBSAMPLERATE

.if ${.CURDIR:M*/www/node}
USE_GCC=yes
COMPILER_TYPE= gcc
CC=  gcc9
CXX= g++9
CPP= cpp9
LD=    
NM=    
OBJDUMP=
STRINGS=
.endif

.if ${.CURDIR:M*/lang/rust}
USE_GCC=yes
COMPILER_TYPE= gcc
CC=  gcc9
CXX= g++9
CPP= cpp9
LD=    
NM=    
OBJDUMP=
STRINGS=
.endif

.if ${.CURDIR:M*/devel/rust-bindgen}
USE_GCC=yes
COMPILER_TYPE= gcc
CC=  gcc9
CXX= g++9
CPP= cpp9
LD=    
NM=    
OBJDUMP=
STRINGS=
.endif

.if ${.CURDIR:M*/devel/rust-cbindgen}
USE_GCC=yes
COMPILER_TYPE= gcc
CC=  gcc9
CXX= g++9
CPP= cpp9
LD=    
NM=    
OBJDUMP=
STRINGS=
.endif
```


----------



## shkhln (Nov 28, 2019)

Don't be silly. There is no reason to muck around with compiler settings.


----------



## Alain De Vos (Nov 28, 2019)

I use the binary packages now. It seems libgit was crashing cargo for some reason.
It is  also not 100% clear to me which compiler versions are supposed to work and which are known to produce errors.
https://www.freshports.org/lang/rust/


----------



## SirDice (Nov 29, 2019)

Alain De Vos said:


> It is also not 100% clear to me which compiler versions are supposed to work and which are known to produce errors.


Don't muck with them then. Just let the ports system figure it out. Remove all the CFLAGS, compiler types and whatnot. The system does an excellent job automatically. Leave the DEFAULT_VERSIONS and OPTIONS_* and remove everything else.


----------



## Alain De Vos (Nov 29, 2019)

I found out rust is bootstrapping with some llvm-rt compiler.
I'll triedout a conservative setting for rust, and this seemed to work
CC=   cc
CXX= c++
CPP= cpp


----------

