SpriteOvO/spdlog-rs

Can't build with 0.3.9 - undefined reference to `gettid'

alex-lavriv opened this issue · 5 comments

Hello,
The build fails with the latest release 0.3.9 with the following error:

 note: /home/alex/development/sdk-coreagent/target/debug/deps/libspdlog-6f3a8729f365763c.rlib(spdlog-6f3a8729f365763c.spdlog.cca83b2da12e547f-cgu.00.rcgu.o): In function `spdlog::record::get_current_tid::get_current_tid_inner':
          /home/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spdlog-rs-0.3.9/src/record.rs:264: undefined reference to `gettid'

OS ubuntu 18.04
Had to force cargo to work with the previous release:

spdlog-rs = {version = "=0.3.8", features = ["source-location", "log"]}

Hmm, I can't reproduce the problem, can you retry a clean build by running cargo clean before cargo build?

If the error still occurs, please consider providing a minimal reproducible code.

It seems like a dependency issue

main.rs

use spdlog::Logger;
use spdlog::prelude::*;
use std::sync::Arc;
fn main() {
    spdlog::init_log_crate_proxy()
        .expect("users should only call `init_log_crate_proxy` function once");
    let custom_logger: Arc<Logger> = spdlog::default_logger();
    let proxy: &'static spdlog::LogCrateProxy = spdlog::log_crate_proxy();
    proxy.set_logger(Some(custom_logger));
    info!("Test");
}

Cargo.toml

[package]
name = "spdlog_min"
version = "0.1.0"
edition = "2021"


[dependencies]
log = "0.4.19"

spdlog-rs = {version = "0.3.9", features = ["source-location", "log"]}

Dockerfile

FROM phusion/baseimage:18.04-1.0.0
RUN apt update && apt install --no-install-recommends -y \
  build-essential \
  awscli \
  curl \
  gcc \
  libssl-dev \
  libsystemd-dev \
  make \
  pkg-config \
  rsync \
  && ldconfig
COPY ./src ./src
COPY ./Cargo.toml .
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y
RUN ls /home/
RUN ~/.cargo/bin/cargo --version
RUN ~/.cargo/bin/cargo build --release --verbose
ENTRYPOINT ["top", "-b"]

Run

docker build .

set

spdlog-rs = {version = "0.3.9", features = ["source-location", "log"]}

to

spdlog-rs = {version = "=0.3.8", features = ["source-location", "log"]}

To see it builds.

Thanks! I have reproduced the problem from the Dockerfile you give.

It's a bit strange, for Docker, the error only occurs on phusion/baseimage:18.04-1.0.0 but works fine on phusion/baseimage:jammy-1.0.1 (Ubuntu 22.04), I'm trying to figure out why.

The reason of this error is earlier glibc versions (before v2.30) did not provide a wrapper for gettid, and your environment still on Ubuntu 18.04, which is a little old.

I have replaced gettid() with direct syscall(SYS_gettid) in #32, the problem should be fixed now. We will release a new version after #33 gets merged or closed.

Thanks for your bug report again!

Fix released in v0.3.10.