fix(r): build the Windows import library without objdump - #392
Merged
Conversation
R CMD INSTALL failed on Windows/arm64 in configure.win. The export list was
dumped from the staged wickra_abi.dll with objdump, but the objdump that
resolves there is the runner image's x86_64 mingw copy at C:\mingw64, which
carries no aarch64 PE backend and rejects the DLL with "file format not
recognized". Asking the compiler for a matching tool via -print-prog-name
returned that same x64 copy, so the previous attempt did not help.
Take the export list from the staged cbindgen header instead. The header
declares exactly the exported symbols -- it and the PE export table agree on
all 3951 entries, for both the x86_64 and the aarch64 release artifact -- so
producing the .def needs no binutils at all.
dlltool is still required for the import library itself and has the same blind
spot, so pass the target machine explicitly and try the candidates R can point
at (BINPREF, llvm-dlltool) ahead of the bare name. A binutils build without the
requested PE backend fails outright ("invalid bfd target") rather than quietly
emitting a wrong-architecture archive, so the first candidate that succeeds is
by construction one that can target this architecture; if none can, the build
stops with the full list of attempts. On x86_64 the resulting import library is
unchanged: same 3951 symbols, same referenced DLL.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
r-universe/wickra-lib/wickra/deployhas been failing onmainsince 2026-08-01. The R-devel and R-release jobs for Windows arm64 fail inconfigure.win; every other platform (Linux x86_64/arm64, macOS x86_64/arm64, Windows x86_64, Wasm) passes.configure.windumped the export list out of the stagedwickra_abi.dllwithobjdump. Theobjdumpthat resolves on that runner is the image's x86_64 mingw copy atC:\mingw64— not Rtools45-aarch64 — and it carries no aarch64 PE backend, so it cannot read an arm64 DLL. Resolving the tool through${CC} -print-prog-name=objdumpreturned the same x64 copy, which is why the previous attempt did not fix it.Change
Derive the
.deffrom the staged header instead of dumping the DLL. The cbindgen header declares exactly the exported symbols, so no binutils is involved in building the export list at all. Verified against the v0.9.9 release artifacts by parsing the PE export tables directly:wickra.h(header-derived)wickra-c-x86_64-pc-windows-msvc/lib/wickra.dllexport tablewickra-c-aarch64-pc-windows-msvc/lib/wickra.dllexport tableobjdump-generated.defAll four sets are identical — no symbol in one and not the others, in either direction.
Pass the target machine to
dlltoolexplicitly and try the tools R can point at first.dlltoolis still needed for the import library and has the same blind spot. A binutils build without the requested PE backend fails outright rather than silently emitting a wrong-architecture archive:That loud failure is what makes an ordered candidate list safe: the first candidate that succeeds is by construction one that can target this architecture. The list is
$WICKRA_DLLTOOL,${BINPREF}llvm-dlltool,${BINPREF}dlltool,llvm-dlltool,dlltool—BINPREFis R's own pointer at the matching Rtools toolchain, and the clang-based aarch64 Rtools shipsllvm-dlltool, which carries every backend. If no candidate works the build stops and prints every attempt with its error, instead of failing later at link time.Architecture detection moved above the dev-override branch, since the target machine is now needed on both paths.
Verification
Exercised locally on x86_64 against the real header and the released DLLs:
objdumpoutput (3951/3951, both directions).dlltool→ import library: same size, same 3951 symbols, same referenced DLL (wickra_abi.dll) as the one the old script produced. Only the archive member timestamps differ.dlltool: every candidate fails, the diagnostic lists all attempts,configure.winexits 1.sh -n/bash -nclean; no bashisms.The repo's own CI cannot cover this — it has no Windows arm64 R job, which is why
1444a379went green on all 98 checks while r-universe stayed red. The r-universe rebuild triggered by merging this is the real check.