security/bitwarden_rs on aarch64

John F Carr jfc at mit.edu
Wed Mar 17 12:52:01 UTC 2021


On Mar 17, 2021, at 07:37 , Mark Dixon <freebsd at markdixon.name> wrote:
> 
> Hi
> 
> I've got my hands on a Helios64 board and I'm playing around with it running 
> FreeBSD 13 to see what it can run, and I've run into something I do not 
> understand. I've been trying to compile security/bitwarden_rs to see if I can 
> use it to host my password manager and I've hit an issue:
> 
> The build, out of the box fails with:
> 
> error: /usr/ports/security/bitwarden_rs/work/target/release/deps/
> libmigrations_macros-2f2155501ff102fe.so: Undefined symbol "__addtf3"
>  --> /usr/ports/security/bitwarden_rs/work/bitwarden_rs-1.19.0/cargo-crates/
> diesel_migrations-1.4.0/src/lib.rs:82:1
>   |
> 82 | extern crate migrations_macros;
> 
> I'm no rust developer, but that looks a lot like a linker error. A quick 
> google suggest that symbol is from libgcc and relates to soft float emulation 
> which I guess we shouldn't need on aarch64 but I guess if that's what it wants 
> I go with it. Sure enough that .so depends on libgcc:
> 
> /usr/ports/security/bitwarden_rs/work/target/release/deps/
> libmigrations_macros-2f2155501ff102fe.so:
> 	libpq.so.5 => /usr/local/lib/libpq.so.5 (0x406d0000)
> 	libmysqlclient.so.20 => /usr/local/lib/mysql/libmysqlclient.so.20 
> (0x41c00000)
> 	libthr.so.3 => /lib/libthr.so.3 (0x40749000)
> 	libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x407a5000)
> 
> 
> /lib/libgcc_so.1 though - I didn't think FreeBSD ships GCC anymore, although 
> I've been out of the FreeBSD loop for a while. 
> 
> Okay, let's look in /usr/src/lib/libgcc_s, seems like it's just some sort of 
> gcc thunking library. Let's try adding __subtf3 to Symbols.map and see what 
> happens. Surprisingly, after adding __subtf3, __multf3, __divtf3 and __addtf3; 
> (and installing libgcc_s) the bitwarden_rs build now compiles just fine, and 
> seems to run - although I haven't actually done much with it yet.
> 
> I'm not sure what is going on here because I'm really at the limits of my 
> knowledge. It seems unlikely, but not impossible, that these symbols are just 
> missing from Symbols.map in the base system. How should I proceed to fix this 
> 'properly'? 
> 
> Mark
> 

__addtf3 is a software implementation of add for the "TF" type, 128 bit floating point, when not implemented in hardware.

The following program compiles for me on FreeBSD 13 on 64 bit ARM using cc without having gcc installed.  You can look at the assembly or symbol table to see it is using __addtf3 (for +) and __netf2 (for !=).

long double add(long double x, long double y) { return x + y; }
int main(int argc, char *argv[]) { return add(1.0, 1.0) != 2.0; }

Based on the library dependencies it looks like rust or bitwarden is being built with gcc and gcc is not configured as well as cc.  Is it possible to use clang instead of gcc?


More information about the freebsd-arm mailing list