Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-21698

Cannot define SONAME in C library build by rust

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Undefined Undefined
    • None
    • None
    • rust-toolset
    • None
    • None
    • None
    • sst_pt_llvm_rust_go
    • ssg_platform_tools
    • None
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • None

      What were you trying to do that didn't work?

      Due to bug of cargo https://github.com/rust-lang/cargo/issues/5045, by default, the cargo will not set SONAME for C library build from rust code.

      Previously, we are using `.cargo/config.toml` and merge it to `.cargo/config` like:

      [target.'cfg(target_os="linux")']
      rustflags = "-Clink-arg=-Wl,-soname=libnmstate.so.2"
      

      But with rust-toolset-1.75.0-1.el9.noarch changed the %cargo_build to use `RUSTFLAGS` which override any changes to `.cargo/config` regarding `rustflags`.

      I found a workaround by using

      %if 0%{?rhel}
      # RHEL does not have patchelf, hence we need to solve the SONAME problem
      # by ourselves: https://github.com/rust-lang/cargo/issues/5045
      %define _package_note_status 1
      %define _package_note_flags -Wl,-soname=libnmstate.so.2
      %endif
      

      Please provide the package NVR for which bug is seen:

      rust-toolset-1.75.0-1.el9.noarch

      How reproducible:

      100%

      Steps to reproduce

      1. rebuild nmstate-2.2.22-1.el9
      2. try to install its produced `nmstate-devel` rpm along with `nmstate-libs`

      Expected results

      No failure

      Actual results

      error: Failed dependencies:
      libnmstate.so()(64bit) is needed by nmstate-2.2.22-1.el9.x86_64

            jistone@redhat.com Josh Stone
            fge@redhat.com Gris Ge
            Josh Stone Josh Stone
            qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com qe-baseos-tools-bugs@redhat.com
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: