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

LNK1223 error when building rustc with custom LLVM under windows #109927

Closed
Escapingbug opened this issue Apr 4, 2023 · 1 comment
Closed

LNK1223 error when building rustc with custom LLVM under windows #109927

Escapingbug opened this issue Apr 4, 2023 · 1 comment
Labels
C-bug Category: This is a bug.

Comments

@Escapingbug
Copy link

Escapingbug commented Apr 4, 2023

I am currently trying to experiment with a llvm patch under windows, and needing a way to build rustc with that patched LLVM.
What I am tring is:

  1. build my own llvm, install that to some dir, command:
cmake -G "Ninja" ../llvm -DCMAKE_INSTALL_PREFIX=~/myllvm -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lld;" -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_INSTALL_UTILS=ON -DLLVM_INCLUDE_TESTS=OFF -DLLVM_BUILD_TESTS=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_BUILD_BENCHMARKS=OFF 
  1. clone the rustc repo, copy the config.example.toml to config.toml, and change:
  • set debug to false
  • target from target.x86_64-unknown-linux-gnu to target.x86_64-pc-windows
  • uncomment llvm-config and set that to my installed llvm's llvm-config
  • change the channel from "dev" to "nightly"
  1. python3 x.py build

The next thing I encounter is something like in this issue.

The author mentioned a possible workaround by crt-static=true and LLVM_USE_CRT sets to MT.
So I did that and set LLVM_USE_CRT_RELEASE to MT (also, LLVM is built under release) by adding -DLLVM_USE_CRT_RELEASE=MT, and build again.

Then I got this problem:

C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX64\\x64\\link.exe" "/DEF:C:\\Users\\anciety\\AppData\\Local\\Temp\\rustc0SuoXn\\lib.def" "/NOLOGO" "C:\\Users\\anciety\\AppData\\Local\\Temp\\rustc0SuoXn\\symbols.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.0.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.1.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.10.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.11.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.12.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.13.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.14.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.15.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.2.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.3.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.4.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.5.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.6.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.7.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.8.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.std.c912c465-cgu.9.rcgu.o" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.vkfgxdag4tpv3nl.rcgu.rmeta" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.1zvn7bwchgkkuqxu.rcgu.o" "/LIBPATH:C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps" "/LIBPATH:C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\release\\deps" "/LIBPATH:C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\build\\compiler_builtins-592565ba788e8799\\out" "/LIBPATH:C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "kernel32.lib" "advapi32.lib" "userenv.lib" "kernel32.lib" "ws2_32.lib" "bcrypt.lib" "ntdll.lib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libpanic_unwind-cf7c52c8541247c8.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\librustc_demangle-67cc44dcafd2d2f4.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libstd_detect-9c65bbe3cdbe5411.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libhashbrown-a2bb50a6fd9e49f8.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libminiz_oxide-1c79f89a19e72a0a.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libadler-b3c29514229011f3.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\librustc_std_workspace_alloc-2392fa0dadf20a4d.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libunwind-a075aa5d3b38968b.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libcfg_if-2ad7fd5fa547498a.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\liblibc-76a3007190d3f3fd.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\liballoc-053b41ffcfb63338.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\librustc_std_workspace_core-f9a15394bd813ed9.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libcore-28c478c35cb147ba.rlib" "C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\libcompiler_builtins-c0705f95d29d72f6.rlib" "libcmt.lib" "legacy_stdio_definitions.lib" "/NXCOMPAT" "/LIBPATH:C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "/OUT:C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.dll" "/OPT:REF,ICF" "/DLL" "/IMPLIB:C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.dll.lib" "/DEBUG"\n  = note: Non-UTF-8 output:   正在创建库 C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.dll.lib 和对象 C:\\Users\\anciety\\Code\\rust\\build\\x86_64-pc-windows-msvc\\stage1-std\\x86_64-pc-windows-msvc\\release\\deps\\std-d383a381ab4a5870.dll.exp\r\nstd-d383a381ab4a5870.std.c912c465-cgu.9.rcgu.o : fatal error LNK1223: 无效或损坏的文件: 文件包含无效的 .pdata 基值\r\n\n'

It says the file contains invalid .pdata base value.

@Escapingbug Escapingbug added the C-bug Category: This is a bug. label Apr 4, 2023
@Escapingbug
Copy link
Author

Escapingbug commented Apr 4, 2023

Nevermind, it seems to be related to my patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant