Liballoc.rlib has __imp___ (three underscores) but rustc is looking for __imp__ (2 underscores)

This is the same question I posted at https://github.com/rust-lang/rust/issues/60866, I figured I could get more traction here, apologize for reposting.

I managed to build out thumbv7a-pc-windows-msvc target (i.e. ARM32 for windows) using x86_64_pc-windows-msvc tools, based on rust-lang/rust master, with some local patches

  1. patched compiler-builtins with this PR https://github.com/rust-lang-nursery/compiler-builtins/pull/293
  2. handle panic_unwind for thumbv7a the same as what we have for aarch64, https://github.com/rust-lang/rust/blob/master/src/libtest/lib.rs#L45

I was able to build rustc successfully: c:\python27\python.exe x.py build --host x86_64-pc-windows-msvc --build x86_64-pc-windows-msvc --target thumbv7a-pc-windows-msvc --verbose

However, once I use the private arm32 rustc to build iotedge-eventlog-messages in azure/iotedge, cargo build --release --target thumbv7a-pc-windows-msvc, I got below error

   Compiling iotedged-eventlog-messages v0.1.0 (D:\git\iotedge\edgelet\iotedged-eventlog-messages)
     Running `rustc --edition=2018 --crate-name iotedged_eventlog_messages iotedged-eventlog-messages\src\lib.rs --color always --crate-type cdylib --emit=dep-info,link -C opt-level=3 -C metadata=7b3a2d69b8dc278f --out-dir D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\deps --target thumbv7a-pc-windows-msvc -L dependency=D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\deps -L dependency=D:\git\iotedge\edgelet\target\release\deps -L all=D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\build\iotedged-eventlog-messages-7acc25993b93c4f2\out -l event_messages.res`
error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX64\\arm\\link.exe" "/NOLOGO" "/NXCOMPAT" "/OPT:NOLBR" "/LIBPATH:E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib" "D:\\git\\iotedge\\edgelet\\target\\thumbv7a-pc-windows-msvc\\release\\deps\\iotedged_eventlog_messages.iotedged_eventlog_messages.cr16zstb-cgu.0.rcgu.o" "/OUT:D:\\git\\iotedge\\edgelet\\target\\thumbv7a-pc-windows-msvc\\release\\deps\\iotedged_eventlog_messages.dll" "/DEF:C:\\Users\\chandde\\AppData\\Local\\Temp\\rustcLXLSml\\lib.def" "D:\\git\\iotedge\\edgelet\\target\\thumbv7a-pc-windows-msvc\\release\\deps\\iotedged_eventlog_messages.28a4ogesychbfxh1.rcgu.o" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:D:\\git\\iotedge\\edgelet\\target\\thumbv7a-pc-windows-msvc\\release\\deps" "/LIBPATH:D:\\git\\iotedge\\edgelet\\target\\release\\deps" "/LIBPATH:D:\\git\\iotedge\\edgelet\\target\\thumbv7a-pc-windows-msvc\\release\\build\\iotedged-eventlog-messages-7acc25993b93c4f2\\out" "/LIBPATH:E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib" "event_messages.res.lib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\libstd-67da064321eabc9f.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\libpanic_abort-9adb8660ecc33a7a.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\librustc_demangle-df85f75ef53673fc.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\libhashbrown-9bd3a3fbf8f3ed5e.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\librustc_std_workspace_alloc-edfd9642cc94109d.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\libunwind-3ac22205e93ddd40.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\liblibc-1287bf1fe4191b4b.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\liballoc-822d54421becb1c7.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\librustc_std_workspace_core-d51e26897332c0c9.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\libcore-1fdb51d4e6dfea00.rlib" "E:\\rustc\\mixed2\\lib\\rustlib\\thumbv7a-pc-windows-msvc\\lib\\libcompiler_builtins-32eb33d96a637274.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "msvcrt.lib" "/DLL" "/IMPLIB:D:\\git\\iotedge\\edgelet\\target\\thumbv7a-pc-windows-msvc\\release\\deps\\iotedged_eventlog_messages.dll.lib"
  = note:    Creating library D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\deps\iotedged_eventlog_messages.dll.lib and object D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\deps\iotedged_eventlog_messages.dll.exp
          libstd-67da064321eabc9f.rlib(std-67da064321eabc9f.std.38mh430v-cgu.5.rcgu.o) : error LNK2019: unresolved external symbol __imp__ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E referenced in function _ZN3std3sys7windows7process7Command3new17hc990fb56302414eaE
          libstd-67da064321eabc9f.rlib(std-67da064321eabc9f.std.38mh430v-cgu.12.rcgu.o) : error LNK2001: unresolved external symbol __imp__ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E
          libstd-67da064321eabc9f.rlib(std-67da064321eabc9f.std.38mh430v-cgu.14.rcgu.o) : error LNK2001: unresolved external symbol __imp__ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E
          libstd-67da064321eabc9f.rlib(std-67da064321eabc9f.std.38mh430v-cgu.0.rcgu.o) : error LNK2001: unresolved external symbol __imp__ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E
          D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\deps\iotedged_eventlog_messages.dll : fatal error LNK1120: 1 unresolved externals


error: aborting due to previous error

error: Could not compile `iotedged-eventlog-messages`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name iotedged_eventlog_messages iotedged-eventlog-messages\src\lib.rs --color always --crate-type cdylib --emit=dep-info,link -C opt-level=3 -C metadata=7b3a2d69b8dc278f --out-dir D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\deps --target thumbv7a-pc-windows-msvc -L dependency=D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\deps -L dependency=D:\git\iotedge\edgelet\target\release\deps -L all=D:\git\iotedge\edgelet\target\thumbv7a-pc-windows-msvc\release\build\iotedged-eventlog-messages-7acc25993b93c4f2\out -l event_messages.res` (exit code: 1)

After a closer look in the thumbv7a rlibs I built locally, what I have in liballoc.rlib is

__imp___ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E

however the compiler error above is complaining about this symbol cannot be resolved,

__imp__ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E

Note there is one underscore missing in the wanted but missing symbol. I have this symbol which has a prefixed underscore in liballoc.lib, which implies the 3 underscore version symbol for imp is correct, that compiler is looking for a wrong symbol.

_ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E

When I look at other symbols in liballoc.rlib, no symbol has prefix underscore, they all look like this, anon.6bd877021c225a724ec59609200b96d6.6.llvm.13430696783672607638 and __imp__anon.6bd877021c225a724ec59609200b96d6.2.llvm.13430696783672607638 . So there is no problem to find these symbols.

So, who’s doing wrong here? any pointer would be much appreciated

Thanks, Chandler.

1 Like

Two more data points

Below two symbols are found in liballoc.rlib, the 3 underscore version _ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E __imp___ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E

however, only below one is found in libstd.rlib, the two underscore version __imp__ZN5alloc11collections5btree4node15EMPTY_ROOT_NODE17h486b4088caeaa846E

Actually it does not matter what I build, even as simple as cargo new hello, it would also fail “cargo build --release --target thumbv7a-pc-windows-msvc”, with the same unresolved symbol.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.