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

Error when cargo build to nanomsg.rs #168

Closed
gokhandincer opened this issue May 4, 2016 · 3 comments
Closed

Error when cargo build to nanomsg.rs #168

gokhandincer opened this issue May 4, 2016 · 3 comments
Labels

Comments

@gokhandincer
Copy link

Hi Everyone,
I got an error when I use rust cargo build to nanomsg.rs

/tmp/nanomsg.rs # cargo build --release
   Compiling nanomsg-sys v0.5.0 (file:///tmp/nanomsg.rs)
error: linking with `cc` failed: exit code: 1
note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/nanomsg.rs/target/release/build/nanomsg-sys-84127a369e3dc8a2/build_script_build.0.o" "-o" "/tmp/nanomsg.rs/target/release/build/nanomsg-sys-84127a369e3dc8a2/build_script_build" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/tmp/nanomsg.rs/target/release/deps" "-L" "/tmp/nanomsg.rs/target/release/deps" "-L" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-4fda350b.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-4fda350b.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_unicode-4fda350b.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-4fda350b.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-4fda350b.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-4fda350b.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-4fda350b.rlib" "/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-4fda350b.rlib" "-l" "dl" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "compiler-rt"
note: /usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-4fda350b.rlib(ctl.pic.o): In function `ctl_lookup':
ctl.c:(.text.ctl_lookup+0x448): undefined reference to `__rawmemchr'
ctl.c:(.text.ctl_lookup+0x488): undefined reference to `__rawmemchr'
collect2: error: ld returned 1 exit status

error: aborting due to previous error
Could not compile `nanomsg-sys

Any advice
Thanks.

@andyshinn
Copy link
Contributor

This smells like #11. How can I reproduce this? How was cargo and rust installed? I don't see any Alpine packages for them.

@gokhandincer
Copy link
Author

Sorry, I attached as blow

FROM gliderlabs/alpine

ENV NN_VERSION 0.8-beta
ENV RUST_VERSION 1.8.0
ENV LANG=C.UTF-8

RUN apk update && \
    apk add --no-cache --virtual=\
    ca-certificates \
    libc-dev \
    curl \
    tar \
    gcc \
    git \
    tar \
    make \
    wget

RUN ALPINE_GLIBC_BASE_URL="https://github.com/andyshinn/alpine-pkg-glibc/releases/download" && \
    ALPINE_GLIBC_PACKAGE_VERSION="2.23-r1" && \
    ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
    ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
    ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
    apk add --no-cache --virtual=build-dependencies wget ca-certificates && \
    wget \
        "https://raw.githubusercontent.com/andyshinn/alpine-pkg-glibc/master/andyshinn.rsa.pub" \
        -O "/etc/apk/keys/andyshinn.rsa.pub" && \
    wget \
        "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
    apk add --no-cache \
        "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
    \
    rm "/etc/apk/keys/andyshinn.rsa.pub" && \
    /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true && \
    echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
    \
    apk del glibc-i18n && \
    \
    apk del build-dependencies && \
    rm \
        "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
        "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"
#install Rust
RUN curl -sO https://static.rust-lang.org/dist/rust-$RUST_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
  tar -xzf rust-$RUST_VERSION-x86_64-unknown-linux-gnu.tar.gz && \
  ./rust-$RUST_VERSION-x86_64-unknown-linux-gnu/install.sh --without=rust-docs && \
  rm -rf \
    rust-$RUST_VERSION-x86_64-unknown-linux-gnu \
    rust-$RUST_VERSION-x86_64-unknown-linux-gnu.tar.gz \
    /var/lib/apt/lists/* \
    /tmp/* \
    /var/tmp/*
#install nanomsg for nanomsg.rs and build nanomsg.rs
RUN cd /tmp/ && \
    wget https://github.com/nanomsg/nanomsg/releases/download/$NN_VERSION/nanomsg-$NN_VERSION.tar.gz && \
    tar xvf nanomsg-$NN_VERSION.tar.gz && mv nanomsg-$NN_VERSION nanomsg && \
    cd /tmp/nanomsg && ./configure && make && make install && \
    cd .. && \
    git clone https://github.com/thehydroimpulse/nanomsg.rs.git && \
    cd  nanomsg.rs && \
    cargo build --release

RUN rm -rf /var/cache/apk/*
RUN rm -rf /tmp/*

@andyshinn
Copy link
Contributor

The glibc package isn't supported. You also won't likely be able to mix native and glibc (you are compiling nanomsg against musl but using rust and cargo over glibc). I'd follow andrew-d/docker-rust-musl#7 to see when rust can actually work on musl and has an Alpine package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants