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

Broken binary with lto=fat when static linking on latest Rust 1.59+ #363

Closed
cipriancraciun opened this issue Feb 25, 2022 · 2 comments
Closed

Comments

@cipriancraciun
Copy link

The following simple Rust program fails to correctly read the env::args when built with the following compile arguments:

cat >| ./main.rs << 'EOS'

pub fn main () {
        eprintln!("{:?}", ::std::env::args ());
        eprintln!("{:?}", ::std::env::args_os ());
}

EOS
 ~/.cargo/bin/rustc +stable --version
rustc 1.59.0 (9d1b2106e 2022-02-23)
env \
        -i \
        PATH=/usr/bin \
        TMPDIR=/tmp \
\
~/.cargo/bin/rustc \
        \
        +stable \
        \
        -C lto=fat \
        -C target-feature=+crt-static \
        -C relocation-model=static  \
        -C linker=clang \
        -C link-arg=-fuse-ld=mold \
        \
        -o ./main \
        -- \
        ./main.rs \
#
./main 1 2 3
Args { inner: [] }
ArgsOs { inner: [] }
clang --version
clang version 13.0.1

mold --version
mold 1.1 (compatible with GNU ld)
@rui314
Copy link
Owner

rui314 commented Feb 25, 2022

Thank you for your report. It looks like something is wrong when -C relocation-model=static is given. Investigating...

@rui314 rui314 closed this as completed in 4198627 Feb 25, 2022
@rui314
Copy link
Owner

rui314 commented Feb 25, 2022

I think the issue has been fixed in the above patch.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants