Skip to content

Compiler fails unpredictably #18718

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

Closed
manuels opened this issue Nov 6, 2014 · 3 comments
Closed

Compiler fails unpredictably #18718

manuels opened this issue Nov 6, 2014 · 3 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries

Comments

@manuels
Copy link

manuels commented Nov 6, 2014

I have two rust source files and one c source code file (see this gist).

I compile the code like this:

$ gcc -c function_arg.c -o /tmp/libcxx.a
# clang -c function_arg.c -o /tmp/libcxx.a
# using clang instead of gcc doesn't resolve the issue
$ rustc -o /tmp/libfoo.rlib function_arg.rs
$ rustc -L /tmp/ function_arg_run.rs -o /tmp/main

Most of the times I get this error:

$ rustc -L /tmp/ ././tests/function_arg_run.rs -o /tmp/main
tests/function_arg_run.rs:7:26: 7:36 error: unresolved name `foo::apply`.
tests/function_arg_run.rs:7     unsafe { println!("{}", foo::apply(double, 2)) }
                                                        ^~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:23: 2:77 note: expansion site
<std macros>:1:1: 3:2 note: in expansion of println!
tests/function_arg_run.rs:7:11: 7:50 note: expansion site

But sometimes the code compiles just fine.

The reason seems to lie in the rustc -o /tmp/libfoo.rlib function_arg.rs command.
When I run into the "unresolved name" error, the /tmp/libfoo.rlib has a size of 11012 bytes and does not contain the string "apply".
In the case where everything just compiles fine, /tmp/libfoo.rlib is 4828 bytes and contains "apply" three times:

$ grep apply /tmp/libfoo.rlib --text --only-matching | wc -l
3

I do not change a single line in the source code but the compiler sometimes results in different output files, which is really strange.

I use these versions:

$ rustc -v
rustc 0.13.0-nightly (63c4f22f2 2014-11-05 22:31:44 +0000)
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5) 
$ clang -v
Debian clang version 3.5.0-1~exp1 (trunk) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/i486-linux-gnu/4.7
Found candidate GCC installation: /usr/bin/../lib/gcc/i486-linux-gnu/4.7.2
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6.3
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7.2
Found candidate GCC installation: /usr/lib/gcc/i486-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/i486-linux-gnu/4.7.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.7.2
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.7
Candidate multilib: .;@m64
Selected multilib: .;@m64
@steveklabnik steveklabnik added the A-linkage Area: linking into static, shared libraries and binaries label Jan 27, 2015
@steveklabnik
Copy link
Member

I'm going to tag this 'linkage', but I'm not 100% sure that's appropriate. No idea what's going on here, though.

@steveklabnik
Copy link
Member

@manuels This bug is extremely old, and nobody has reported anything similar since you've opened it. With some minor updates, your sample compiles fine for me every time, but so much has changed since you filed this bug that I think I'm going to give it a close.

If you're still seeing this, please let me know and we can try to get something that reproduces. Thanks!

@manuels
Copy link
Author

manuels commented Feb 8, 2016

Agreed, thanks!

lnicola pushed a commit to lnicola/rust that referenced this issue Jan 7, 2025
…-intoiterator

internal: Standardize how we take iterator parameters in `SyntaxFactory`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries
Projects
None yet
Development

No branches or pull requests

2 participants