valyala / gozstd

go wrapper for zstd
MIT License
434 stars 63 forks source link

Issue building in docker #57

Open Devil-sir opened 1 year ago

Devil-sir commented 1 year ago

Having trouble using this library in a new docker image:

Jenkinsfile: sh 'go get -d github.com/valyala/gozstd' sh 'cd ${GOPATH}/src/github.com/valyala/gozstd && MOREFLAGS=-fPIC make clean libzstd.a && go install' sh 'cd ${GOPATH} && docker run -v ${GOPATH}:/go build:0.0.1 go install -buildmode=c-shared -ldflags "-s -w -extldflags=-fPIC" ${SRC}

Error output: # github.com/valyala/gozstd /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.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/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_compress.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_compress_sequences.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_compress_superblock.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_lazy.o): relocation R_X86_64_32 against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_ldm.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_opt.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_decompress.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_decompress_block.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.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/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.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/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(fse_decompress.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_v05.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_v06.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(zstd_v07.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(fse_compress.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(huf_compress.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(huf_decompress.o): relocation R_X86_64_32S against .rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(divsufsort.o): relocation R_X86_64_32S against.rodata' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(fastcover.o): relocation R_X86_64_32 against undefined symbol __iob' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(pool.o): relocation R_X86_64_32 against.bss' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: /go/src/github.com/valyala/gozstd/libzstd_illumos_amd64.a(cover.o): relocation R_X86_64_32 against .text' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-alpine-linux-musl/6.4.0/../../../../x86_64-alpine-linux-musl/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status script returned exit code 2

@valyala Please help on the issue

f41gh7 commented 1 year ago

Hello, currently new builder - ziglang compiler doesn't support freebsd and illumos as targets.

It should be possible to compile it manually at native OS without docker:

    cd zstd/lib && ZSTD_LEGACY_SUPPORT=0 MOREFLAGS=$(MOREFLAGS) make clean libzstd.a
        # replace  LIBZSTD_NAME with target name
    mv zstd/lib/libzstd.a $(LIBZSTD_NAME)