Commit Graph

8 Commits

Author SHA1 Message Date
devtty1er d561c49ae5
Update Dockerfiles (#4070)
* Use LABEL in place of MAINTAINER

* Remove LABEL maintainer from Dockerfiles
2020-07-06 13:18:23 -07:00
Abhishek Arya 4f7cf1b334
Simplify rust project setup. (#3830)
* Simplify rust project setup.

- Add rust and cargo-fuzz in base builder.
- Set RUSTC_BOOSTRAP to make ASan available.
- Set RUSTFLAGS and C,CXXFLAGS properly.
2020-05-17 16:45:54 -07:00
David Wong f5098035eb
[libra] Fix building failure (#3566)
After many days banging my head on FFI issues in rust,
I hereby present a fix to the issue.

Note that I've got some help, and I'm not sure I understand everything here.
But this is my understanding of what was not working, and how we fixed it.

The **problem** is that on Ubuntu 16 with llvm/clang 10,
we were **statically linking libc++** in [rocksdb][1]:

```rust
let stdlib = if tool.is_like_gnu() {
  "libstdc++.a"
} else if tool.is_like_clang() {
  "libc++.a"
} else {
  // Don't link to c++ statically on windows.
  return;
};

// ...

// remove lib prefix and .a postfix.
println!(
  "cargo:rustc-link-lib=static={}",
  &stdlib[3..stdlib.len() - 2]
);
```

This means that during building, when we reach building of rocksdb,
we import a number of symbols from libc++ (like [__muloti4][2])
that end up in the associated `.rlib` (rust obj file).

These symbols interestingly do not exist in libstdc++ which is used by gcc.
This is important because on linux (unlike mac), the rust toolchain is compiled with gcc.
So these intrinsics are not present in the linux rust toolchain,
and have been redeclared in the [compiler-builtins][3] crate.

So here is the problem:

* rust toolchain's defines these intrinsics functions
* libc++ defines these intrinsics functions

And the recipe for disaster:

* libc++ is statically linked in rocksdb, which means all the symbols are imported
* symbols in rocksdb's produced `.rlib` are colliding with the symbols from the rust toolchain `.rlib`

To fix this. Maybe we could have compiled the stuff with libstdc++?
But instead we:

1. removed the static linking
2. we linked libc++ at the very last moment via:
  ```rust
  RUSTFLAGS="-C link-arg=-L/usr/local/lib -C link-arg=-lc++"
  ```

At final linking time, the linker sees that the intrinsics are already defined in one of the `.rlib`
(produced by compiler-builtins) and so does not import these functions from libc++.
Actually, at this point it only statically link the functions that need to be linked.

It seems to work.

[1]: c79d2c2ac6/librocksdb_sys/build.rs (L115)
[2]: https://github.com/llvm-mirror/libcxx/blob/master/src/filesystem/int128_builtins.cpp
[3]: e578d47247/src/int/mul.rs (L107)
2020-04-02 14:28:09 -07:00
David Wong a4f67e3023
trying a distribution list as CC for libra (#3536) 2020-03-24 12:25:13 -07:00
David Wong 3cae7f6513
[libra] adding additional CC (#3514) 2020-03-16 15:31:47 -07:00
David Wong daa9523fee
[libra] build fuzzers in release mode (#3511) 2020-03-16 14:21:45 -07:00
David Wong 0a6e93ad77
[libra] adding fuzzers for libra (#3472) 2020-03-06 21:09:10 -08:00
David Wong 48a907ef68
adding libra to list of projects (#3382) 2020-02-13 10:59:08 -08:00