valyala / gozstd

go wrapper for zstd
MIT License
421 stars 60 forks source link

Issue building in docker #1

Closed hobbs closed 5 years ago

hobbs commented 6 years ago

Having trouble using this library in a new docker image:

Dockerfile

FROM golang:1.10-stretch

RUN apt-get install gcc git make

RUN go get -u github.com/valyala/gozstd

Error output:

Step 1/9 : FROM golang:1.10-stretch
 ---> 6fe15d4cbc64
Step 2/9 : RUN apt-get install gcc git make
 ---> Using cache
 ---> b5f3a286c946
Step 3/9 : RUN go get -u github.com/valyala/gozstd
 ---> Running in 603c8d4e6a82
# github.com/valyala/gozstd
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(zstd_common.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(zstd_compress.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(zstd_opt.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(zstd_decompress.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(zdict.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(error_private.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(fse_decompress.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(fse_compress.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(huf_decompress.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(cover.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(divsufsort.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: src/github.com/valyala/gozstd/libzstd.a(pool.o): relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
The command '/bin/sh -c go get -u github.com/valyala/gozstd' returned a non-zero code: 2
valyala commented 6 years ago

@hobbs, try substituting

RUN go get -u github.com/valyala/gozstd

with

RUN go get -d github.com/valyala/gozstd
RUN cd $GOPATH/src/github.com/valyala/gozstd && make clean libzstd.a && go install

It should fetch gozstd sources, re-build libzstd.a from sources and then build gozstd package.

valyala commented 5 years ago

The issue has been fixed by rebuilding libzstd_linux.a on ubuntu 18.04. Previously the file has been built on ubuntu 16.04 .