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

Fails to link -no-pie executable that depends on a proc macro #5115

Open
dtolnay opened this issue Mar 3, 2018 · 5 comments
Open

Fails to link -no-pie executable that depends on a proc macro #5115

dtolnay opened this issue Mar 3, 2018 · 5 comments
Labels
A-linkage Area: linker issues, dylib, cdylib, shared libraries, so A-rustflags Area: rustflags S-triage Status: This issue is waiting on initial triage.

Comments

@dtolnay
Copy link
Member

dtolnay commented Mar 3, 2018

The following script reproduces the issue. We create a library mac which is a procedural macro (an empty one is sufficient) and a binary repro which depends on mac.

#!/bin/sh

cargo new mac
echo >>mac/Cargo.toml '
[lib]
proc-macro = true
'

cargo new repro --bin
echo >>repro/Cargo.toml '
mac = { path = "../mac" }
'

RUSTFLAGS='-C link-args=-no-pie' cargo run --manifest-path repro/Cargo.toml

The link step fails with:

error: linking with `cc` failed: exit code: 1
  = note: /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start':
          (.text+0x20): undefined reference to `main'
          collect2: error: ld returned 1 exit status

Originally reported in serde-rs/serde#1166. @fintelia

@alexcrichton
Copy link
Member

This is unfortunately sort of expected, RUSTFLAGS is quite dangerous for precisely the reason, that it can't be targeted to particular crates causing things like link flags to go awry.

I'm not really sure if this can be fixed per se, but this is likely related to a new feature like rust-lang/rust#48683

@stale
Copy link

stale bot commented Sep 16, 2018

As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it.

I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect?

The team would be especially grateful if such a comment included details such as:

  • Is this still relevant?
  • If so, what is blocking it?
  • Is it known what could be done to help move this forward?

Thank you for contributing!

If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!

@stale stale bot added the stale label Sep 16, 2018
@AregevDev
Copy link

It is still relevant by now, I am facing the same issue

@stale stale bot removed the stale label Sep 29, 2018
@AregevDev
Copy link

Any news regaurding that?

@ehuss ehuss added A-linkage Area: linker issues, dylib, cdylib, shared libraries, so A-rustflags Area: rustflags labels Apr 6, 2020
@Yuri6037
Copy link

That's a huge issue: currently this prevents the creation of double-click to run type softwares

@epage epage added the S-triage Status: This issue is waiting on initial triage. label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linker issues, dylib, cdylib, shared libraries, so A-rustflags Area: rustflags S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

6 participants