Repository navigation
Invalid bitcast error when building rustc (rustc-std-workspace-core) #110472
Copy link
Copy link
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Description
I'm building rustc on an Amazon Linux 2 (m5.24xlarge) machine. This has worked for me the last 5 months, but currently, HEAD is giving me an error when running ./x.py build library.
I thought that it was maybe something I had caused, so I spun up a brand new instance, but I'm still able to reproduce.
Meta
uname -a:
Linux <redacted> <redacted>.amzn2int.x86_64 #1 SMP Sat Mar 11 23:51:58 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
rust HEAD
7908a1d65496b88626e4b7c193c81d777005d6f3
Error output
Assembling stage1 compiler
Building stage1 library artifacts (x86_64-unknown-linux-gnu)
Compiling compiler_builtins v0.1.91
Compiling core v0.0.0 (/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/library/core)
Compiling libc v0.2.140
Compiling cc v1.0.77
Compiling memchr v2.5.0
Compiling std v0.0.0 (/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/library/std)
Compiling unwind v0.0.0 (/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/library/unwind)
Compiling rustc-std-workspace-core v1.99.0 (/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/library/rustc-std-workspace-core)
Invalid bitcast
ptr bitcast (ptr addrspace(14979816) @anon.0dd304449d08a524feadd4cd33e8bcb6.1 to ptr)
LLVM ERROR: Broken module found, compilation aborted!
error: could not compile `core`
warning: build failed, waiting for other jobs to finish...
huge alignment values are unsupported
%15 = load i64, ptr %9, align 70368744177664
huge alignment values are unsupported
%16 = load i64, ptr %8, align 70368744177664
huge alignment values are unsupported
%26 = load i32, ptr %20, align 70368744177664
huge alignment values are unsupported
%27 = load i32, ptr %19, align 70368744177664
huge alignment values are unsupported
%37 = load i16, ptr %31, align 70368744177664
huge alignment values are unsupported
%38 = load i16, ptr %30, align 70368744177664
huge alignment values are unsupported
%146 = load i128, ptr %144, align 70368744177664
huge alignment values are unsupported
%147 = load i128, ptr %145, align 70368744177664
in function _ZN17compiler_builtins3mem6memcmp17h39b65de6ac43991cE
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `compiler_builtins`
huge alignment values are unsupported
%2 = load i32, huge alignment values are unsupportedptr
%0, align %703687441776643 = load i
64, ptr %2, align 70368744177664
in function in function _ZN70_$LT$libc..unix..linux_like..in_addr$u20$as$u20$core..clone..Clone$GT$5clone17h3189a06ce16fa8eaE_ZN4libc4unix10linux_like5linux3gnu76_$LT$impl$u20$libc..unix..linux_like..linux..gnu..b64..x86_64..siginfo_t$GT$8si_value17h7c477f7ca72cc0a2E
LLVM ERROR: Broken function found, compilation aborted!LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `libc`
Build completed unsuccessfully in 0:03:28
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
nikic commentedon Apr 18, 2023
Could you please rerun the last rustc command (maybe you need to pass
-vto get it) with-C save-tempsand zip the*.bcfiles it produces?bryangarza commentedon Apr 18, 2023
Here it is:
save-temps.zip
the command I ran
(I actually ran it twice because the first time I wasn't sure if it was working and then I later found where the
*.bcfiles are stored.)cd "/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2" && AR_x86_64_unknown_linux_gnu="ar" CARGO_INCREMENTAL="1" CARGO_PROFILE_RELEASE_DEBUG="0" CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS="false" CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS="false" CARGO_TARGET_DIR="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/stage1-std" CC_x86_64_unknown_linux_gnu="cc" CFG_COMPILER_HOST_TRIPLE="x86_64-unknown-linux-gnu" CFG_RELEASE_CHANNEL="dev" CFLAGS_x86_64_unknown_linux_gnu="-ffunction-sections -fdata-sections -fPIC -m64" CXXFLAGS_x86_64_unknown_linux_gnu="-ffunction-sections -fdata-sections -fPIC -m64" CXX_x86_64_unknown_linux_gnu="c++" LIBC_CHECK_CFG="1" RANLIB_x86_64_unknown_linux_gnu="ar s" REAL_LIBRARY_PATH_VAR="LD_LIBRARY_PATH" RUSTBUILD_NATIVE_DIR="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/native" RUSTC="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/bootstrap/debug/rustc" RUSTC_BACKTRACE_ON_ICE="1" RUSTC_BOOTSTRAP="1" RUSTC_BREAK_ON_ICE="1" RUSTC_ERROR_METADATA_DST="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/tmp/extended-error-metadata" RUSTC_FORCE_UNSTABLE="1" RUSTC_INSTALL_BINDIR="bin" RUSTC_LIBDIR="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/stage1/lib" RUSTC_LINT_FLAGS="-Wrust_2018_idioms -Wunused_lifetimes -Wsemicolon_in_expressions_from_macros -Dwarnings" RUSTC_REAL="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" RUSTC_SNAPSHOT="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/stage0/bin/rustc" RUSTC_SNAPSHOT_LIBDIR="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/stage0/lib" RUSTC_STAGE="1" RUSTC_SYSROOT="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/stage1" RUSTC_VERBOSE="1" RUSTDOC="/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/bootstrap/debug/rustdoc" RUSTDOCFLAGS="-Csymbol-mangling-version=legacy -Zunstable-options -Zunstable-options --check-cfg=values(bootstrap) --check-cfg=values(stdarch_intel_sde) --check-cfg=values(no_fp_fmt_parse) --check-cfg=values(no_global_oom_handling) --check-cfg=values(no_rc) --check-cfg=values(no_sync) --check-cfg=values(freebsd12) --check-cfg=values(freebsd13) --check-cfg=values(backtrace_in_libstd) --check-cfg=values(target_env,"libnx") --check-cfg=values(target_arch,"asmjs","spirv","nvptx","xtensa","loongarch64") --check-cfg=values(target_env,"ohos") -Dwarnings -Wrustdoc::invalid_codeblock_attributes --crate-version 1.71.0-dev -Zcrate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/\")" RUSTDOC_REAL="/path/to/nowhere/rustdoc/not/required" RUSTFLAGS="-Csymbol-mangling-version=legacy -Zunstable-options -Zunstable-options --check-cfg=values(bootstrap) --check-cfg=values(stdarch_intel_sde) --check-cfg=values(no_fp_fmt_parse) --check-cfg=values(no_global_oom_handling) --check-cfg=values(no_rc) --check-cfg=values(no_sync) --check-cfg=values(freebsd12) --check-cfg=values(freebsd13) --check-cfg=values(backtrace_in_libstd) --check-cfg=values(target_env,"libnx") --check-cfg=values(target_arch,"asmjs","spirv","nvptx","xtensa","loongarch64") --check-cfg=values(target_env,"ohos") -Zmacro-backtrace -Clink-args=-Wl,-z,origin -Clink-args=-Wl,-rpath,$ORIGIN/../lib -Csplit-debuginfo=off -Cprefer-dynamic -Cllvm-args=-import-instr-limit=10 -Zinline-mir -Cembed-bitcode=yes -Clto=off -Csave-temps=yes -Zcrate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/\")" RUST_TEST_THREADS="96" WINAPI_NO_BUNDLED_LIBRARIES="1" __CARGO_DEFAULT_LIB_METADATA="devstd" "/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "--release" "-Zcheck-cfg=names,values,output" "-Zbinary-dep-depinfo" "-j" "96" "-v" "--features" " panic-unwind backtrace" "--manifest-path" "/local/home/garzbrya/projects/rustc/issue-110467-safe-transmute2/library/test/Cargo.toml" "--message-format" "json-render-diagnostics"
nikic commentedon Apr 19, 2023
Some of the optimized bitcode files do contain invalid alignments, but I did not manage to produce such corrupted files from the unoptimized bitcodes files.
bryangarza commentedon May 3, 2023
Update: I used git bisect -- the LLVM 16 commit seems to be the one causing the error #109474
bryangarza commentedon May 3, 2023
Seems setting
download-ci-llvm = falsein the config.toml allows the build to succeed without errorspnkfelix commentedon May 3, 2023
I did some reduction of the
libcinput and got things down to this, which reproduces the problem but only with the rustc that is built withdownload-ci-llvm=true:Invocation:
Output:
veera-sivarajan commentedon Dec 20, 2023
Running into this on commit
f704f3b93b1543cf504ecca0052f9f8531b1f61fas well.nikic commentedon Dec 20, 2023
Per https://pkgs.org/search/?q=libstdc%2B%2B it looks like Amazon Linux 2 uses libstdc++ 7, which is ABI incompatible with the libLLVM.so for download-ci-llvm. I believe you need at least libstdc++ 8.
Possibly the build system should check the version.
onur-ozkan commentedon May 22, 2024
#125411 would catch this problem.
onur-ozkan commentedon Jun 6, 2024
Closing this as #125411 is merged and now the build system is capable of checking
libstdc++version. Feel free to re-open if needed.