openethereum / parity-ethereum

The fast, light, and robust client for Ethereum-like networks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

static binaries, description of building/testing environments

alkorang opened this issue · comments

  • OpenEthereum version: since 2.5.13 (maybe older)
  • Operating system: Linux (CentOS 7)
  • Installation: one-line installer, built from source
  • Fully synchronized: -
  • Network: -
  • Restarted: -

When I downloaded parity 2.5.13 for Linux and started them in CentOS 7, it returned error that some dynamic libraries are not in the expected paths:

./parity: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./parity)
./parity: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./parity)
./parity: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./parity)
./parity: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by ./parity)

I got the same error when I downloaded and started openethereum 3.0.1:

./openethereum: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./openethereum)
./openethereum: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by ./openethereum)
./openethereum: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./openethereum)
./openethereum: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by ./openethereum)

So I decided to build parity from source code in CentOS 7. I first installed latest stable rustc (1.46.0) with rustup and all packages listed in README (gcc, g++, ...) with yum package manager. I tried to build parity 2.5.13, then building failed because of too old cmake:

--- stderr
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
  CMake 3.1 or higher is required.  You are running version 2.8.12.2

After I found cmake 3.17.1 and added it to PATH, building failed again, probably due to change in language specification:

error: unexpected string literal
   --> rpc/src/tests/http_client.rs:117:4
    |
116 |             headers.iter().any(|header| header.as_str() == "X-Frame-Options: SAMEORIGIN")
    |                                                                                          - help: try adding a comma
117 |             "X-Frame-Options: SAMEORIGIN missing: {:?}", headers
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unexpected string literal
   --> rpc/src/tests/http_client.rs:122:3
    |
121 |         headers.iter().any(|header| header.as_str() == "X-XSS-Protection: 1; mode=block")
    |                                                                                          - help: try adding a comma
122 |         "X-XSS-Protection missing: {:?}", headers
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unexpected string literal
   --> rpc/src/tests/http_client.rs:126:3
    |
125 |         headers.iter().any(|header|  header.as_str() == "X-Content-Type-Options: nosniff")
    |                                                                                           - help: try adding a comma
126 |         "X-Content-Type-Options missing: {:?}", headers
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unexpected string literal
   --> rpc/src/tests/http_client.rs:130:3
    |
129 |         headers.iter().any(|header| header.starts_with("Content-Security-Policy: "))
    |                                                                                     - help: try adding a comma
130 |         "Content-Security-Policy missing: {:?}", headers
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...... warnings ......

error: aborting due to 4 previous errors; 43 warnings emitted

error: could not compile `parity-rpc`.

To learn more, run the command again with --verbose.

From Rust Blog I found the latest stable rustc when 2.5.13 was released (Dec 31) is 1.40.0 (Dec 19). After I changed default rustc to 1.40.0 by running rustup default 1.40.0, I could build parity 2.5.13.

In the next release, it'd be better if static binaries are provided so that openethereum can be run on any Linux distributions, or at least information of building and testing environments (Linux distributions, versions of build tools) is provided in README.

PS.

The issue template refers SECURITY.md which does not exist anymore.

You can find mode info on the reporting process in SECURITY.md

From Rust Blog I found the latest stable rustc when 2.5.13 was released (Dec 31) is 1.40.0 (Dec 19). After I changed default rustc to 1.40.0 by running rustup default 1.40.0, I could build parity 2.5.13.

@alkorang thank you for for the heads-up! Worked for me after the initial problems with unexpected string literal when trying to compile from the 2.5 branch. I found it very helpful in regard to https://github.com/openethereum/openethereum/issues/11858

Just wanted to put this somewhere.

It's non-trivially difficult to build static binaries of Parity because of the RocksDB dependency, it doesn't like linking against the musl libc. But in rust 'the supported way' to do static binaries is to build against musl.

While it's not impossible to build a static binary linked against glibc, neither is it well supported and even if you manage to manipulate the build flags to do a new rust version could make it dynamic again.

The best that can be done is have release builds built in a docker container against the oldest verson of glibc possible at any given time. Since this is the only dynamic linking performed by the resulting binary you would would essentially make a universally portable binary that way.

I've got a quick debian docker container doing this locally for my own purposes and it works on Centos8 which is all I need. But I think if you really wanted to run such a script for releases you would want to base the docker container on Centos6 as the oldest version of glibc that's still even kinda maintained.

Ubuntu 16.04 will be used to build the binary.
openethereum/openethereum#73