Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geth 4.2.0 doesn't start on amazon linux #454

Closed
constb opened this Issue Jan 4, 2018 · 20 comments

Comments

Projects
None yet
5 participants
@constb
Copy link

constb commented Jan 4, 2018

as far as I know amazon linux is based on centos 6 to some extent. I'm trying to run 4.2.0 linux build I downloaded from releases section and all I get is ./geth: /lib64/libc.so.6: version 'GLIBC_2.18' not found (required by ./geth)

so I checked which versions are exposed by installed glibc with strings /lib64/libc.so.6 | grep GLIBC | sort and what I see is:

…
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_2.15
GLIBC_2.16
GLIBC_2.17
…

(other lines omitted for clarity)

so, you see my problem, right? is it possible to rebuild 4.2.0 in a more compatible way or something? like 4.1.2 was compiled?

@constb constb changed the title get 4.2.0 doesn't start on amazon linux geth 4.2.0 doesn't start on amazon linux Jan 4, 2018

@splix splix added Bug URGENT labels Jan 4, 2018

@splix

This comment has been minimized.

Copy link
Member

splix commented Jan 4, 2018

It's probably related to SputnikVM inclusion

@tzdybal tzdybal self-assigned this Jan 4, 2018

@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 4, 2018

What version of Amazon Linux? Quick googling shows that last version with glibc <= 2.18 is 2014.09. (it seems that all major distributions updated glibc to 2.18 or later in 2015 because of GHOST vulnerability).

@constb

This comment has been minimized.

Copy link
Author

constb commented Jan 4, 2018

Amazon Linux AMI release 2017.09 as it is shipped in the AMI they offer when creating new machine. with all updates of course.

@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 4, 2018

My fault, some distros just patch glibc, including Amazon Linux.

@sorpaas - what do you think about this? What I found is: https://internals.rust-lang.org/t/compile-a-static-binary-for-deployment-on-cluster/3353/2 - presented solutions are following - use old system to build, use musl instead of glibc (second seems better for me).

@sorpaas

This comment has been minimized.

Copy link
Contributor

sorpaas commented Jan 4, 2018

@tzdybal I'm thinking about building SputnikVM as no_std, so it doesn't need glibc.

SputnikVM runs on Rux anyway so this shouldn't be a problem, but I need to check the details first.

@sorpaas

This comment has been minimized.

Copy link
Contributor

sorpaas commented Jan 4, 2018

Nope. It still needs linking with GLIBC.

@sorpaas

This comment has been minimized.

Copy link
Contributor

sorpaas commented Jan 4, 2018

@tzdybal I build geth without SputnikVM, and it still requires glibc. So I would say that using musl might not help much fixing the problem -- Go part still depends on glibc either way. Better use an older Ubuntu version on Travis.

@whilei

This comment has been minimized.

Copy link
Contributor

whilei commented Jan 4, 2018

Just a quick google for installing glibc on SO -- is it possible to (temporarily at least?) solve with

for centos as mentioned here ->

sudo yum groupinstall 'Development Tools'
# or 
yum install gcc gcc-c++ make openssl-devel

for other linux:

sudo apt-get install build-essential

I ran into a kind-of-similar problem on a Debian fork about missing header files, and installing build-essential solved it for me.

@constb

This comment has been minimized.

Copy link
Author

constb commented Jan 4, 2018

amazon linux actually ships with 3 versions of gcc available: 4.4, 4.8 and 6.4. unfortunately, I found that I already have 6.4 installed.

unlike gcc, glibc is only available in a single variant:

ec2-user@test-host:~$ yum info glibc
Loaded plugins: priorities, update-motd, upgrade-helper
8 packages excluded due to repository priority protections
Installed Packages
Name        : glibc
Arch        : x86_64
Version     : 2.17
Release     : 196.172.amzn1
Size        : 13 M
Repo        : installed
From repo   : amzn-updates
Summary     : The GNU libc libraries
URL         : http://www.gnu.org/software/glibc/
License     : LGPLv2+ and LGPLv2+ with exceptions and GPLv2+
Description : …
@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 4, 2018

@sorpaas binary build without SputnikVM, requires only "old" glibc, but after turning on -tags=sputnikvm during build, 2.18 version is needed.

Without --tags:

$ readelf --version-info geth
...
Version needs section '.gnu.version_r' contains 2 entries:
 Addr: 0x0000000000402b78  Offset: 0x002b78  Link: 7 (.dynstr)
  000000: Version: 1  File: libpthread.so.0  Cnt: 2
  0x0010:   Name: GLIBC_2.3.2  Flags: none  Version: 4
  0x0020:   Name: GLIBC_2.2.5  Flags: none  Version: 3
  0x0030: Version: 1  File: libc.so.6  Cnt: 3
  0x0040:   Name: GLIBC_2.14  Flags: none  Version: 6
  0x0050:   Name: GLIBC_2.4  Flags: none  Version: 5
  0x0060:   Name: GLIBC_2.2.5  Flags: none  Version: 2

With --tags=sputnikvm:

$ readelf --version-info geth
...
Version needs section '.gnu.version_r' contains 5 entries:
 Addr: 0x0000000000458740  Offset: 0x058740  Link: 7 (.dynstr)
  000000: Version: 1  File: libdl.so.2  Cnt: 1
  0x0010:   Name: GLIBC_2.2.5  Flags: none  Version: 14
  0x0020: Version: 1  File: ld-linux-x86-64.so.2  Cnt: 1
  0x0030:   Name: GLIBC_2.3  Flags: none  Version: 9
  0x0040: Version: 1  File: libgcc_s.so.1  Cnt: 3
  0x0050:   Name: GCC_4.2.0  Flags: none  Version: 11
  0x0060:   Name: GCC_3.3  Flags: none  Version: 10
  0x0070:   Name: GCC_3.0  Flags: none  Version: 5
  0x0080: Version: 1  File: libpthread.so.0  Cnt: 3
  0x0090:   Name: GLIBC_2.3.3  Flags: none  Version: 13
  0x00a0:   Name: GLIBC_2.3.2  Flags: none  Version: 4
  0x00b0:   Name: GLIBC_2.2.5  Flags: none  Version: 3
  0x00c0: Version: 1  File: libc.so.6  Cnt: 7
  0x00d0:   Name: GLIBC_2.14  Flags: none  Version: 16
  0x00e0:   Name: GLIBC_2.3.4  Flags: none  Version: 15
  0x00f0:   Name: GLIBC_2.4  Flags: none  Version: 12
  0x0100:   Name: GLIBC_2.3  Flags: none  Version: 8
  0x0110:   Name: GLIBC_2.18  Flags: none  Version: 7
  0x0120:   Name: GLIBC_2.17  Flags: none  Version: 6
  0x0130:   Name: GLIBC_2.2.5  Flags: none  Version: 2
@sorpaas

This comment has been minimized.

Copy link
Contributor

sorpaas commented Jan 5, 2018

If this is the case, then we can simply build it using musl.

alias rust-musl-builder='docker run --rm -it -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder'
(
  cd sputnikvm-ffi/c/ffi
  rust-musl-builder cargo build --release
)
cp sputnikvm-ffi/c/ffi/target/x86_64-unknown-linux-musl/release/libsputnikvm_ffi.a sputnikvm-ffi/c/libsputnikvm.a

And then continue the build process as normal.

@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 5, 2018

After building like you posted, problem still exists, but readelf output is a bit different:

Version needs section '.gnu.version_r' contains 2 entries:
 Addr: 0x000000000045ab18  Offset: 0x05ab18  Link: 7 (.dynstr)
  000000: Version: 1  File: libc.so.6  Cnt: 1
  0x0010:   Name: GLIBC_2.18  Flags: none  Version: 3
  0x0020: Version: 1  File: libm.so.6  Cnt: 1
  0x0030:   Name: GLIBC_2.2.5  Flags: none  Version: 2

And this still doesn't work on Amazon Linux. Maybe I have to check for some cached/old build files, or something.

@sorpaas

This comment has been minimized.

Copy link
Contributor

sorpaas commented Jan 5, 2018

I don't think there would be glibc references in the FFI. Is there a way to check only the libsputnikvm.a file?

The problem might be that cgo used the system gcc and linked glibc. Is there a way to check that?

@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 5, 2018

Maybe it's -ldl releated? I'll check the .a file with plain strings or something like that.

@sorpaas

This comment has been minimized.

Copy link
Contributor

sorpaas commented Jan 5, 2018

Yeah building with musl doesn't require -ldl any more. It can be removed. But GLIBC_2.18 is still there.

Version needs section '.gnu.version_r' contains 1 entries:
 Addr: 0x000000000045bb48  Offset: 0x05bb48  Link: 6 (.dynstr)
  000000: Version: 1  File: libc.so.6  Cnt: 2
  0x0010:   Name: GLIBC_2.18  Flags: none  Version: 3
  0x0020:   Name: GLIBC_2.3.4  Flags: none  Version: 2
@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 5, 2018

I'll try to use musl for go/cgo instead of glibc.

@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 5, 2018

Problem is following - when cgo is in use, glibc always is in use. I tried to add -ldflags "-extldflags=-nostdlib" compile flags. It removed GLIBC_2.18 dependency, but binary is not runnable.

go build -tags=sputnikvm -ldflags "-extldflags=-nostdlib -X main.Version="`janus version -format TAG_OR_NIGHTLY`
# github.com/ethereumproject/go-ethereum/cmd/geth
/usr/bin/ld: warning: cannot find entry symbol _start; defaulting to 000000000045a980
Version needs section '.gnu.version_r' contains 1 entries:
 Addr: 0x000000000045a898  Offset: 0x05a898  Link: 6 (.dynstr)
  000000: Version: 1  File: libm.so.6  Cnt: 1
  0x0010:   Name: GLIBC_2.2.5  Flags: none  Version: 2

Idea: create default Linux entry point (_start) in C code and call go main function from there.

Note for myself (and anyone interested):

@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 10, 2018

Building with -extldflags=-static:

go build -tags=sputnikvm -ldflags "-extldflags=-static -X main.Version="`janus version -format TAG_OR_NIGHTLY`

resolves the problem - generated executable is completely static, and no glibc is required. Binary is running on Amazon Linux without problems, and SputnikVM can be compiled as usual, without musl (and actually it should be built like that to avoid musl/malloc + glibc/free cases). I'll prepare a PR to get a proper build from Travis.

@tzdybal

This comment has been minimized.

Copy link
Member

tzdybal commented Jan 11, 2018

@constb, you can download a fully&truly static binary from: http://builds.etcdevteam.com/go-ethereum/v4.2.x/geth-classic-linux-v4.2.0-static-def345c.tar.gz - I tested it on Amazon Linux AMI release 2017.09.

@whilei - can you check the static binary on Mac?

@constb

This comment has been minimized.

Copy link
Author

constb commented Jan 12, 2018

@tzdybal it works, thank you

@whilei whilei closed this in #465 Jan 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.