Skip to content

Compiler doesn't actually write output if rerun quickly #18913

@alexcrichton

Description

@alexcrichton
Member

I have a suspicion that we're not calling ar correctly if an rlib previously existed. This script, for example, prints 0 both times:

echo 'extern crate foo; fn main() { println!("{}", foo::foo()); }' > bar.rs
echo 'pub fn foo() -> int { 0 }' > foo.rs
rustc foo.rs --crate-type lib
rustc bar.rs -L .
./bar

echo 'pub fn foo() -> int { 1 }' > foo.rs
rustc foo.rs --crate-type lib
rustc bar.rs -L .
./bar

If I insert sleep 1 in the middle, this prints 0/1 always, and when run repeatedly it will intermittently print 0/1. I'm currently running this on linux.

Activity

added
A-linkageArea: linking into static, shared libraries and binaries
on Nov 13, 2014
nodakai

nodakai commented on Nov 13, 2014

@nodakai
Contributor

I think the u option given to ar doesn't examine timestamps with sub-second accuracy and thus sometimes ignores the new object file.

echo 'extern crate foo; fn main() { println!("{}", foo::foo()); }' > bar.rs
echo 'pub fn foo() -> int { 0 }' > foo.rs
strace -f -s 200 -e process -e open rustc foo.rs --crate-type lib
stat libfoo.rlib
rustc bar.rs -L .
./bar

echo 'pub fn foo() -> int { 1 }' > foo.rs
strace -f -s 200 -e process -e open rustc foo.rs --crate-type lib
stat libfoo.rlib
rustc bar.rs -L .
./bar

sleep 1
strace -f -s 200 -e process -e open rustc foo.rs --crate-type lib
stat libfoo.rlib
rustc bar.rs -L .
./bar
added a commit that references this issue on May 14, 2015
ae13436
added a commit that references this issue on May 26, 2015
fa0834d
added a commit that references this issue on May 26, 2015
a83201f
added a commit that references this issue on May 29, 2015
2d664b0
added a commit that references this issue on Jan 20, 2025
f00e5ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binaries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @alexcrichton@nodakai

      Issue actions

        Compiler doesn't actually write output if rerun quickly · Issue #18913 · rust-lang/rust