Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 2002612

Summary: wasm target libraries have no index
Product: [Fedora] Fedora Reporter: Jesus Checa <jchecahi>
Component: rustAssignee: Josh Stone <jistone>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: amulhern, igor.raits, jistone, rust-sig, TicoTimo
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rust-1.55.0-1.fc36 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-09-10 15:38:47 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jesus Checa 2021-09-09 10:59:18 UTC
Description of problem:
Rust wasm target libraries are missing archive indexes. This causes failures during the linkage of the wasm object.

Version-Release number of selected component (if applicable):
lld-13.0.0~rc1-1.fc36.x86_64.rpm
lld-libs-13.0.0~rc1-1.fc36.x86_64.rpm
llvm12-libs-12.0.1-2.fc35.x86_64.rpm
llvm-libs-13.0.0~rc1-1.fc35.x86_64.rpm
rust-1.54.0-2.fc36.x86_64
rust-std-static-1.54.0-2.fc36.x86_64
rust-std-static-wasm32-unknown-unknown-1.54.0-2.fc36.noarch

How reproducible:
Tested only on x86_64 - 100%

Steps to Reproduce:
1. dnf install -y rust-std-static-wasm32-unknown-unknown
2. echo '#[no_mangle] pub fn hello() { println!("hello"); }' > lib.rs
3. rustc --target wasm32-unknown-unknown --crate-type=cdylib lib.rs -o hello.wasm

Actual results:
# rustc --target wasm32-unknown-unknown --crate-type=cdylib lib.rs -o hello.wasm
error: linking with `lld` failed: exit status: 1
  |
  = note: "lld" "-flavor" "wasm" "--rsp-quoting=posix" "--export" "hello" "--export=__heap_base" "--export=__data_end" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--fatal-warnings" "--no-demangle" "--no-entry" "--export-dynamic" "hello.lib.3a1fbbbh-cgu.0.rcgu.o" "hello.lib.3a1fbbbh-cgu.1.rcgu.o" "hello.3gblaopztxau25i3.rcgu.o" "-L" "/usr/lib/rustlib/wasm32-unknown-unknown/lib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libstd-e82f9624e23759e5.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libpanic_abort-e659f06d6f710dcd.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libdlmalloc-d4db3cb062e50a05.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libstd_detect-18938fdda033ffac.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/librustc_demangle-f84000261c9c9a43.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libhashbrown-7c0e6f9fb708c7e7.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_alloc-046a8829873dcf5a.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-2a120aaf015a334c.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libcfg_if-79e302e273dcca73.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-6df430a6aef263fc.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-2abe73d6a802385b.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_core-0999390a3297da80.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libcore-9a8632e8dc147a5a.rlib" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-69a4dc158deb0bc7.rlib" "-L" "/usr/lib/rustlib/wasm32-unknown-unknown/lib" "-L" "/usr/lib/rustlib/wasm32-unknown-unknown/lib/self-contained" "-o" "hello.wasm" "--gc-sections" "--no-entry" "-O0"
  = note: lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libstd-e82f9624e23759e5.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libpanic_abort-e659f06d6f710dcd.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libdlmalloc-d4db3cb062e50a05.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libstd_detect-18938fdda033ffac.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/librustc_demangle-f84000261c9c9a43.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libhashbrown-7c0e6f9fb708c7e7.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_alloc-046a8829873dcf5a.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libunwind-2a120aaf015a334c.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libcfg_if-79e302e273dcca73.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/liblibc-6df430a6aef263fc.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/liballoc-2abe73d6a802385b.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/librustc_std_workspace_core-0999390a3297da80.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libcore-9a8632e8dc147a5a.rlib: archive has no index; run ranlib to add one
          lld: error: /usr/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-69a4dc158deb0bc7.rlib: archive has no index; run ranlib to add one
          

error: aborting due to previous error


Expected results:
Successful linkage

Additional info:
There is a section in the spec file that is supposed to rebuild the archive indexes:
%if %defined cross_targets
# brp-strip-static-archive breaks the archive index for wasm
%global __os_install_post \
%__os_install_post \
find %{buildroot}%{rustlibdir} -type f -path '*/wasm*/lib/*.rlib' -exec ranlib '{}' ';' \
%{nil}
%endif

I think this is not being applied for some reason. I verified that running `ranlib` on all wasm rlibs and compiling again succeeds:

# rustc --target wasm32-unknown-unknown --crate-type=cdylib lib.rs -o hello.wasm
# ls hello.wasm 
hello.wasm

Comment 1 Josh Stone 2021-09-09 16:51:39 UTC
Strange! That "find" command is there in build.log, but I guess I could make that more verbose to be sure it really finds and modifies those files. And as you say, manually running rawhide's ranlib still fixes it, so it doesn't look like binutils changed here.

My scratch build of 1.55 the other day also has this issue though:
https://koji.fedoraproject.org/koji/taskinfo?taskID=75314113

Downgrading everything to rust-1.54.0-1.fc35 still works on rawhide.

Comment 2 Fedora Update System 2021-09-10 06:56:22 UTC
FEDORA-2021-4b659cb2b1 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2021-4b659cb2b1

Comment 3 Fedora Update System 2021-09-10 15:38:47 UTC
FEDORA-2021-4b659cb2b1 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.