Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building standard library with LLD fails on Windows with "undefined symbol" errors #54190

Open
michaelwoerister opened this Issue Sep 13, 2018 · 16 comments

Comments

Projects
None yet
3 participants
@michaelwoerister
Copy link
Contributor

michaelwoerister commented Sep 13, 2018

Currently it's not possible to cross-compile the standard library for aarch64-pc-windows-msvc. To reproduce, install the MSVC's ARM64 toolchain (I used MSVC 15.8.3) and configure Rust as follows:

./configure --host=x86_64-pc-windows-msvc --target=aarch64-pc-windows-msvc --set rust.lld

Running ./x.py build will abort with linker errors (error log provided by @froydnj):

 rust-lld: error: undefined symbol: _ZN47_$LT$std..fs..File$u20$as$u20$std..io..Read$GT$4read17h278f0b774c14e76aE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.11.rcgu.o:(_ZN71_$LT$std..io..buffered..BufReader$LT$R$GT$$u20$as$u20$std..io..Read$GT$4read17he17302c0375fd14cE)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.11.rcgu.o:(_ZN71_$LT$std..io..buffered..BufReader$LT$R$GT$$u20$as$u20$std..io..Read$GT$4read17he17302c0375fd14cE)
complete error log
error: linking with `rust-lld` failed: exit code: 1
  |
  = note: "rust-lld" "-flavor" "link" "/LIBPATH:C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\aarch64-pc-windows-msvc\\lib" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.0.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.1.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.10.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.11.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.14.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.15.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.2.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.3.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.4.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.5.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.6.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.7.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.8.rcgu.o" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.term.brlane49-cgu.9.rcgu.o" "/OUT:C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.dll" "/DEF:C:\\Users\\froyd\\AppData\\Local\\Temp\\rustcr7cV5j\\lib.def" "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.2ubmzgze4ttlfqh0.rcgu.o" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps" "/LIBPATH:C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\release\\deps" "/LIBPATH:C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\aarch64-pc-windows-msvc\\lib" "kernel32.lib" "/LIBPATH:C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2\\lib\\rustlib\\aarch64-pc-windows-msvc\\lib" "std-9e897034a22da8f8.dll.lib" "C:\\Users\\froyd\\AppData\\Local\\Temp\\rustcr7cV5j\\libcompiler_builtins-aa78be22f43afdbb.rlib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "libcmt.lib" "/DLL" "/IMPLIB:C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage2-test\\aarch64-pc-windows-msvc\\release\\deps\\term-2c32649037e8f914.dll.lib"
  = note: rust-lld: error: undefined symbol: _ZN73_$LT$core..fmt..Arguments$LT$$u27$a$GT$$u20$as$u20$core..fmt..Display$GT$3fmt17h2a972b9cd14c0b34E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.10.rcgu.o:(_ZN4core5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$15copy_from_slice17h84c3d20285d3797dE)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.10.rcgu.o:(_ZN4core5slice29_$LT$impl$u20$$u5b$T$u5d$$GT$15copy_from_slice17h84c3d20285d3797dE)

          rust-lld: error: undefined symbol: _ZN3std5error221_$LT$impl$u20$core..convert..From$LT$$RF$$u27$b$u20$str$GT$$u20$for$u20$alloc..boxed..Box$LT$$LP$dyn$u20$std..error..Error$u20$$u2b$$u20$core..marker..Sync$u20$$u2b$$u20$core..marker..Send$u20$$u2b$$u20$$u27$a$RP$$GT$$GT$4from17h9eeab4eb33fac824E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.11.rcgu.o:(_ZN3std2io4Read10read_exact17h54ee1715c74e9886E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.11.rcgu.o:(_ZN79_$LT$std..io..buffered..BufWriter$LT$W$GT$$u20$as$u20$core..ops..drop..Drop$GT$4drop17h0a2a4eb954c6a297E)

          rust-lld: error: undefined symbol: _ZN47_$LT$std..fs..File$u20$as$u20$std..io..Read$GT$4read17h278f0b774c14e76aE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.11.rcgu.o:(_ZN71_$LT$std..io..buffered..BufReader$LT$R$GT$$u20$as$u20$std..io..Read$GT$4read17he17302c0375fd14cE)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.11.rcgu.o:(_ZN71_$LT$std..io..buffered..BufReader$LT$R$GT$$u20$as$u20$std..io..Read$GT$4read17he17302c0375fd14cE)

          rust-lld: error: undefined symbol: _ZN79_$LT$std..path..Path$u20$as$u20$core..convert..AsRef$LT$std..path..Path$GT$$GT$6as_ref17he945222ff32fd726E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN3std2fs4File4open17h17da0bceedbdeefbE)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN3std2fs4File4open17h17da0bceedbdeefbE)

          rust-lld: error: undefined symbol: _ZN82_$LT$std..path..PathBuf$u20$as$u20$core..convert..AsRef$LT$std..path..Path$GT$$GT$6as_ref17he10fff899ec3ba9aE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN3std2fs8metadata17h0fa7f67ccea52baeE)

          rust-lld: error: undefined symbol: _ZN3std3ffi6os_str85_$LT$impl$u20$core..convert..AsRef$LT$std..ffi..os_str..OsStr$GT$$u20$for$u20$str$GT$6as_ref17h4fff6be7d583afb5E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN3std3env3var17h443aa255a44023c3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN3std3env6var_os17hdf78d67fb86bc31aE)

          rust-lld: error: undefined symbol: _ZN60_$LT$alloc..string..String$u20$as$u20$core..clone..Clone$GT$5clone17h4b24dcf27e218542E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN44_$LT$T$u20$as$u20$alloc..borrow..ToOwned$GT$8to_owned17he1b1c763f42eb1b9E)

          rust-lld: error: undefined symbol: _ZN3std5error229_$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$$LP$dyn$u20$std..error..Error$u20$$u2b$$u20$core..marker..Sync$u20$$u2b$$u20$core..marker..Send$u20$$u2b$$u20$$u27$static$RP$$GT$$GT$4from17h6a7d84947f47f853E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN50_$LT$T$u20$as$u20$core..convert..Into$LT$U$GT$$GT$4into17had9622a930073bdcE)

          rust-lld: error: undefined symbol: _ZN40_$LT$str$u20$as$u20$core..fmt..Debug$GT$3fmt17hbe61a3430dd2168dE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN53_$LT$$RF$$u27$a$u20$T$u20$as$u20$core..fmt..Debug$GT$3fmt17h19e4b58322a0debfE)

          rust-lld: error: undefined symbol: _ZN60_$LT$std..io..stdio..StdoutRaw$u20$as$u20$std..io..Write$GT$5write17hf039c99cc25f3872E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN65_$LT$std..io..stdio..Maybe$LT$W$GT$$u20$as$u20$std..io..Write$GT$5write17h36c941d8633c1a65E)

          rust-lld: error: undefined symbol: _ZN3std4path95_$LT$impl$u20$core..convert..AsRef$LT$std..path..Path$GT$$u20$for$u20$alloc..string..String$GT$6as_ref17hb5273f3d4d5c62ceE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.12.rcgu.o:(_ZN66_$LT$$RF$$u27$a$u20$T$u20$as$u20$core..convert..AsRef$LT$U$GT$$GT$6as_ref17h88469db36cd005bbE)

          rust-lld: error: undefined symbol: _ZN3std3ffi6os_str85_$LT$impl$u20$core..convert..AsRef$LT$std..ffi..os_str..OsStr$GT$$u20$for$u20$str$GT$6as_ref17h4fff6be7d583afb5E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)

          rust-lld: error: undefined symbol: _ZN92_$LT$std..path..PathBuf$u20$as$u20$core..convert..From$LT$std..ffi..os_str..OsString$GT$$GT$4from17hd32fe85aee6e7f6bE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)

          rust-lld: error: undefined symbol: _ZN3std4path77_$LT$impl$u20$core..convert..AsRef$LT$std..path..Path$GT$$u20$for$u20$str$GT$6as_ref17h0ca87727d4f1f137E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)

          rust-lld: error: undefined symbol: _ZN82_$LT$std..path..PathBuf$u20$as$u20$core..convert..AsRef$LT$std..path..Path$GT$$GT$6as_ref17he10fff899ec3ba9aE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)

          rust-lld: error: undefined symbol: _ZN3std4path95_$LT$impl$u20$core..convert..AsRef$LT$std..path..Path$GT$$u20$for$u20$alloc..string..String$GT$6as_ref17hb5273f3d4d5c62ceE
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)

          rust-lld: error: undefined symbol: _ZN4core3fmt3num55_$LT$impl$u20$core..fmt..LowerHex$u20$for$u20$usize$GT$3fmt17h167a3950eded3036E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.13.rcgu.o:(_ZN4term8terminfo8searcher19get_dbpath_for_term17hf8fd73e6c94258f3E)

          rust-lld: error: undefined symbol: _ZN3std5error221_$LT$impl$u20$core..convert..From$LT$$RF$$u27$b$u20$str$GT$$u20$for$u20$alloc..boxed..Box$LT$$LP$dyn$u20$std..error..Error$u20$$u2b$$u20$core..marker..Sync$u20$$u2b$$u20$core..marker..Send$u20$$u2b$$u20$$u27$a$RP$$GT$$GT$4from17h9eeab4eb33fac824E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.15.rcgu.o:(_ZN3std2io5error5Error3new17h2e9937565e5a4accE)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.15.rcgu.o:(_ZN75_$LT$$RF$$u27$a$u20$mut$u20$I$u20$as$u20$core..iter..iterator..Iterator$GT$4next17h4d0546aa6657129fE)

          rust-lld: error: undefined symbol: _ZN3std5error229_$LT$impl$u20$core..convert..From$LT$alloc..string..String$GT$$u20$for$u20$alloc..boxed..Box$LT$$LP$dyn$u20$std..error..Error$u20$$u2b$$u20$core..marker..Sync$u20$$u2b$$u20$core..marker..Send$u20$$u2b$$u20$$u27$static$RP$$GT$$GT$4from17h6a7d84947f47f853E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.15.rcgu.o:(_ZN3std2io5error5Error3new17h4abe32e5817d446fE)

          rust-lld: error: undefined symbol: _ZN3std4path77_$LT$impl$u20$core..convert..AsRef$LT$std..path..Path$GT$$u20$for$u20$str$GT$6as_ref17h0ca87727d4f1f137E
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.15.rcgu.o:(_ZN3std4path7PathBuf4push17h0ae214a74ebc332bE)
          >>> referenced by C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps\term-2c32649037e8f914.term.brlane49-cgu.15.rcgu.o:(_ZN3std4path7PathBuf4push17h401dc332b52f3a78E)

          rust-lld: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)


error: aborting due to previous error

error: Could not compile `term`.

Caused by:
  process didn't exit successfully: `C:\Users\froyd\rust\build\bootstrap/debug/rustc --crate-name term libterm\lib.rs --error-format json --crate-type dylib --crate-type rlib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=2c32649037e8f914 -C extra-filename=-2c32649037e8f914 --out-dir C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps --target aarch64-pc-windows-msvc -L dependency=C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\aarch64-pc-windows-msvc\release\deps -L dependency=C:\Users\froyd\rust\build\x86_64-pc-windows-msvc\stage2-test\release\deps` (exit code: 1)
command did not execute successfully: "C:\\Users\\froyd\\rust\\build\\x86_64-pc-windows-msvc\\stage0\\bin\\cargo.exe" "build" "--target" "aarch64-pc-windows-msvc" "-j" "12" "--release" "--manifest-path" "C:\\Users\\froyd\\rust\\src/libtest/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101
thread 'main' panicked at 'cargo must succeed', bootstrap\compile.rs:1155:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failed to run: C:\Users\froyd\rust\build\bootstrap\debug\bootstrap build
Build completed unsuccessfully in 0:39:29
@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 14, 2018

So it turns out that linking with LLD does not work on Windows in general. At least I get the same linker errors for i686-pc-windows-msvc too. The culprit is the following piece of logic in LLD's handling of .def files:

    // In simple cases, only Name is set. Renamed exports are parsed
    // and set as "ExtName = Name". If Name has the form "OtherDll.Func",
    // it shouldn't be a normal exported function but a forward to another
    // DLL instead. This is supported by both MS and GNU linkers.
    if (E1.ExtName != E1.Name && StringRef(E1.Name).contains('.')) {
      E2.Name = Saver.save(E1.ExtName);
      E2.ForwardTo = Saver.save(E1.Name);
      Config->Exports.push_back(E2);
      continue;
    }

LLD interprets every symbol with a dot in it as a re-export from another DLLs. And it will find plenty of dots in our symbols :)

I don't know yet what the best strategy to solve this is. We'll probably have to avoid dots in our symbol names entirely.

@michaelwoerister michaelwoerister changed the title Building standard library for "aarch64-pc-windows-msvc" fails with "undefined symbol" errors Building standard library with LLD fails on Windows with "undefined symbol" errors Sep 14, 2018

@michaelwoerister michaelwoerister added O-windows and removed O-ARM labels Sep 14, 2018

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 14, 2018

cc @alexcrichton, who did the initial work for supporting aarch64 in Windows.

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 14, 2018

A few thoughts on fixing this:

  • Fixing this on the Rust side by not including . in symbol names anymore will break demangling in various external tools like Valgrind (cc @nnethercote). If we have to break tools, we should also clean up symbol name generation at the same time to avoid churn.
  • Fixing this in LLD might be possible but somewhat brittle. I experimented with a fix of the logic linked above but then it failed somewhere down the line, where another piece of code worked under the assumption that . has a special meaning in symbol names. I don't think we want to go down that road.
@froydnj

This comment has been minimized.

Copy link
Contributor

froydnj commented Sep 14, 2018

I cargo-culted the configuration to use lld from @alexcrichton ...is there some reason that Microsoft's linker won't work correctly here?

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 14, 2018

The original PR mentions LLD being less buggy than the MSVC linker.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 14, 2018

Oh dear, thanks for tracking that down @michaelwoerister! I recall that LLD worked for building MSVC binaries, but I think that must have been simple binaries, I've never bootstrapped with it. It may also be the case now that LLVM and/or link.exe has progressed to being "less buggy" so it may work for aarch64 (haven't check it recently myself)

We could perhaps as a temporary interim measure have different mangling on each platform?

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 14, 2018

We could perhaps as a temporary interim measure have different mangling on each platform?

Yeah, Windows might be a good testing ground for a new mangling scheme as there are probably fewer tools that depend on the current scheme.

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 14, 2018

I'll give the MSVC linker a try after the weekend.

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 17, 2018

So it seems that MSVC has received some Aarch64 fixes meanwhile: When using link.exe instead of LLD, the dots in the symbols don't seem to pose a problem. Instead the build fails with the following error:

Building stage2 test artifacts (x86_64-pc-windows-msvc -> aarch64-pc-windows-msvc)
   Compiling term v0.0.0 (file:///C:/msys64/home/mw/2-rust/src/libterm)
   Compiling getopts v0.2.17
   Compiling test v0.0.0 (file:///C:/msys64/home/mw/2-rust/src/libtest)
error: cannot link together two panic runtimes: panic_abort and panic_unwind

error: aborting due to previous error

error: Could not compile `test`.

This is the same error I get when compiling with LLD and a rustc with a fix for the symbol name issue.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 17, 2018

Hm that error is... curious! That shouldn't happen because we're compiling everything with -C panic=abort because that's the default panic strategy (as specified in the custom target spec).

For example wasm defaults to panic=abort and doesn't hit an error like that when bootstrapping. Thinking about this though... that may be related to dynamic libraries. None of our other panic=abort-by-default targets support dynamic libraries, so this error hasn't shown up before.

To fix that error we'll likely need to update the panic_unwind crate to not inform that it's a panic runtime (cfg_attr the attribute) and disable that attribute on aarch64-msvc. Does that make sense? For a local build commenting out this line should fix the bootstrap.

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 18, 2018

I thought this might be the problem:

let mut features = "panic-unwind".to_string();

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 18, 2018

Yeah I guess what I mean is that this isn't the first target to default to panic=abort, but we haven't run into this issue yet. That's just because all those targets don't support dylibs, so there's a number of solutions we could do here. I'm not really sure which is best, but so long as something works I'm sure it'll be fine :)

If changing that line in rustbuild works, that sounds great!

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Sep 19, 2018

If changing that line in rustbuild works, that sounds great!

It does not, unfortunately. The workaround suggested by you does though:

// in src/libpanic_unwind/lib.rs
#![cfg_attr(not(all(windows, target_arch = "aarch64")), panic_runtime)]

so there's a number of solutions we could do here

I don't really understand the problem yet, I think. I need to read up on panic runtime handling first...

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 19, 2018

Oh sorry, I should explain more too! So both the panic_abort and panic_unwind crates have the #![panic_runtime] attribute, and the general problem is that they can't be both linked into a program. For MSVC we build test.dll which links to std.dll. The std.dll file, however, needs to be linked, and currently it's linked with panic_abort because on aarch64 that's the default. The test.dll file, however, unconditionally links to panic_unwind to indicate that it isn't compatible with panic=abort (on other targets).

The easiest fix here actually is probably just adding a #[cfg] annotation to extern crate panic_unwind; in src/libtest/lib.rs

kennytm added a commit to kennytm/rust that referenced this issue Sep 20, 2018

Rollup merge of rust-lang#54290 - michaelwoerister:aarch64-back-to-ms…
…vc, r=alexcrichton

Switch linker for aarch64-pc-windows-msvc from LLD to MSVC

The MSVC linker does not seem to have the same problems with Rust symbols that LLD currently has on Windows (see rust-lang#54190 (comment)). This PR makes MSVC the default linker for `aarch64-pc-windows-msvc`.

r? @alexcrichton

pietroalbini added a commit to pietroalbini/rust that referenced this issue Sep 25, 2018

Rollup merge of rust-lang#54529 - michaelwoerister:dont-unwind-test, …
…r=alexcrichton

aarch64-pc-windows-msvc: Don't link libpanic_unwind to libtest.

This implements the suggestion from rust-lang#54190 (comment) in order to unbreak bootstrapping for the `aarch64-pc-windows-msvc` target. With this applied and using MSVC 15.8.3 for linking the bootstrap actually works and I can cross-compile a hello-world program.

r? @alexcrichton
@froydnj

This comment has been minimized.

Copy link
Contributor

froydnj commented Oct 1, 2018

Since #54529 was merged, we can close this issue, correct? Or is it being kept open for a "proper" fix?

@michaelwoerister

This comment has been minimized.

Copy link
Contributor Author

michaelwoerister commented Oct 1, 2018

@froydnj That fix/workaround is for a different issue (#54291). It's still not possible to link certain rustc generated code with LLD because of the dots in symbol names. We work around that for now by using MSVC's linker instead of LLD. The proper fix for this will be a new mangling scheme that does not generate symbols that confuse LLD. See https://internals.rust-lang.org/t/pre-rfc-a-new-symbol-mangling-scheme/8501 for my proposed scheme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.