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

rustc fails to link with clang (undefined reference to __muloti4) #126

Open
elichai opened this issue Nov 13, 2019 · 2 comments
Open

rustc fails to link with clang (undefined reference to __muloti4) #126

elichai opened this issue Nov 13, 2019 · 2 comments
Labels
I-ccompiler A bug in the downstream C compiler

Comments

@elichai
Copy link
Contributor

elichai commented Nov 13, 2019

Clang version: 9.0.0.

$ CC=clang CXX=clang++ make -f minicargo.mk

make -f Makefile all
make[1]: Entering directory '/home/elichai2/gits/mrustc'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/elichai2/gits/mrustc'
test -e bin/mrustc
make -C tools/minicargo/
make[1]: Entering directory '/home/elichai2/gits/mrustc/tools/minicargo'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/elichai2/gits/mrustc/tools/minicargo'
test -e tools/bin/minicargo
tools/bin/minicargo rustc-1.29.0-src/src/libstd --script-overrides script-overrides/stable-1.29.0-linux/ --output-dir output/ 
test -e output/libstd.rlib
tools/bin/minicargo rustc-1.29.0-src/src/libpanic_unwind --script-overrides script-overrides/stable-1.29.0-linux/ --output-dir output/ 
test -e output/libpanic_unwind.rlib
tools/bin/minicargo rustc-1.29.0-src/src/libtest --vendor-dir rustc-1.29.0-src/src/vendor --output-dir output/ 
test -e output/libtest.rlib
tools/bin/minicargo lib/libproc_macro --output-dir output/ 
test -e output/libproc_macro.rlib
mkdir -p output/rustc-build
CFG_COMPILER_HOST_TRIPLE=x86_64-unknown-linux-gnu LLVM_CONFIG=/home/elichai2/gits/mrustc/rustc-1.29.0-src/build/bin/llvm-config CFG_RELEASE= CFG_RELEASE_CHANNEL=stable CFG_VERSION=1.29.0-stable-mrustc CFG_PREFIX=mrustc CFG_LIBDIR_RELATIVE=lib LD_LIBRARY_PATH=/home/elichai
2/gits/mrustc/output tools/bin/minicargo rustc-1.29.0-src/src/rustc --vendor-dir rustc-1.29.0-src/src/vendor --output-dir output/rustc-build -L output/ 
BUILDING rustc_binary from rustc-main v0.0.0
> /home/elichai2/gits/mrustc/bin/mrustc rustc-1.29.0-src/src/rustc/rustc.rs -o output/rustc-build/rustc_binary --crate-name rustc_binary --crate-type bin -C emit-depfile=output/rustc-build/rustc_binary.d -g --cfg debug_assertions -O -L output -L output/rustc-build --exter
n rustc_target=output/rustc-build/librustc_target.rlib --extern rustc_driver=output/rustc-build/librustc_driver.rlib
/usr/bin/ld: output/rustc-build/librustc_mir.rlib.o: in function `ZRICj15overflowing_mul0g':
/home/elichai2/gits/mrustc/output/rustc-build/librustc_mir.rlib.c:1058314: undefined reference to `__muloti4'
clang-9: error: linker command failed with exit code 1 (use -v to see invocation)
C Compiler failed to execute - error code 256
Process exited with non-zero exit status 1
BUILD FAILED
make: *** [minicargo.mk:102: output/rustc] Error 1
@thepowersgang
Copy link
Owner

This appears to be a clang-level issue. mrustc emits __builtin_mul_overflow at that line, which clang has converted into a call to __muloti4, which doesn't exist in the default-linked libgcc (reportedly it's in compiler-builtins)

For reference, that mangled symbol is <i128>::overflowing_mul

@thepowersgang thepowersgang changed the title Fail building with clang rustc fails to link with clang (undefined reference to __muloti4) Nov 16, 2019
@thepowersgang
Copy link
Owner

https://bugs.llvm.org/show_bug.cgi?id=16404
It appears that clang has an issue where it emits calls to helper methods, but doesn't add a link to compiler-rt to ensure that they're present.

You may need to force the use of compiler-rt somehow (since this is specific to using clang, I'm not sure how it could be handled in mrustc)

@thepowersgang thepowersgang added the I-ccompiler A bug in the downstream C compiler label Jun 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ccompiler A bug in the downstream C compiler
Projects
None yet
Development

No branches or pull requests

2 participants