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

Cannot build "backtrace" with locally-compiled rustc on macOS: expected enum std::os::raw::c_void, found enum libc::c_void #768

Closed
alexreg opened this issue Jun 13, 2019 · 30 comments
Labels
A-mac Area: Affects only macOS targets C-bug Category: This is a bug.

Comments

@alexreg
Copy link
Contributor

alexreg commented Jun 13, 2019

I locally built rustc master and linked stage2 using rustup, set the override in the miri subdir, but I'm getting this when running cargo build:

$ cargo build
   Compiling backtrace v0.3.29
   Compiling serde v1.0.92
error[E0308]: mismatched types
   --> /Users/alex/.cargo/registry/src/github.lhy31512.workers.dev-1ecc6299db9ec823/backtrace-0.3.29/src/symbolize/coresymbolication.rs:155:32
    |
155 |                       self.dll = libc::dlopen(lib.as_ptr() as *const _, libc::RTLD_LAZY);
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::os::raw::c_void`, found enum `libc::c_void`
...
186 | / coresymbolication! {
187 | |     #[load_path = "/System/Library/PrivateFrameworks/CoreSymbolication.framework\
188 | |                  /Versions/A/CoreSymbolication"]
189 | |     extern "C" {
...   |
202 | |     }
203 | | }
    | |_- in this macro invocation
    |
    = note: expected type `*mut std::os::raw::c_void`
               found type `*mut libc::c_void`

error[E0308]: mismatched types
   --> /Users/alex/.cargo/registry/src/github.lhy31512.workers.dev-1ecc6299db9ec823/backtrace-0.3.29/src/symbolize/coresymbolication.rs:176:39
    |
176 |                       match libc::dlsym(self.dll, symbol.as_ptr() as *const _) as usize {
    |                                         ^^^^^^^^ expected enum `libc::c_void`, found enum `std::os::raw::c_void`
...
186 | / coresymbolication! {
187 | |     #[load_path = "/System/Library/PrivateFrameworks/CoreSymbolication.framework\
188 | |                  /Versions/A/CoreSymbolication"]
189 | |     extern "C" {
...   |
202 | |     }
203 | | }
    | |_- in this macro invocation
    |
    = note: expected type `*mut libc::c_void`
               found type `*mut std::os::raw::c_void`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `backtrace`.
warning: build failed, waiting for other jobs to finish...

Note that ./x.py build src/tools/miri works just fine.

I've discussed this a bit with @RalfJung on chat but not had much luck, so I thought I'd post it here so we can treat it as a proper issue.

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

(Actually, I get errors like error: use of deprecated item 'libc::mach_timebase_info::numer': Use the mach crate instead when I try to build using x.py today, but that looks like a separate issue; it worked before.)

@RalfJung
Copy link
Member

Yeah we are seeing those deprecation warnings on CI as well. They do not originate from within Miri though.

The issue you are having looks like some kind of libc version mismatch. I have no idea where that might come from. It only seems to happen on macOS.

@RalfJung RalfJung changed the title Cannot build against locally-compiled rustc doesn't work Cannot build against locally-compiled rustc on macOS: expected enum std::os::raw::c_void, found enum libc::c_void Jun 13, 2019
@RalfJung RalfJung added A-mac Area: Affects only macOS targets C-bug Category: This is a bug. labels Jun 13, 2019
@RalfJung
Copy link
Member

But also your build failure is not in Miri, it is in backtrace, so it looks to me that's where the bug is. Miri can't do anything about its dependencies failing to build...

Cc @alexcrichton any idea why backtrace might fail to build against a locally built rustc on macOS?

@RalfJung RalfJung changed the title Cannot build against locally-compiled rustc on macOS: expected enum std::os::raw::c_void, found enum libc::c_void Cannot build "backtrace" with locally-compiled rustc on macOS: expected enum std::os::raw::c_void, found enum libc::c_void Jun 13, 2019
@RalfJung
Copy link
Member

RalfJung commented Jun 13, 2019

Maybe #427 (not having a Cargo.lock in the Miri repo) is a problem after all. But the way rustc gets build, we currently just cannot have a lockfile.

Also, which exact rustc commit did you try? Please make sure it is 8e948df707ea8a3c88c65bf2ffdcb2f1cf5491be (the current commit is always given in the rust-version file).

@RalfJung
Copy link
Member

RalfJung commented Jun 13, 2019

(Sorry for the spam, each time I am done writing I have a new idea.^^)

So according to our CI, the macOS build works fine with backtrace v0.3.30. Your build failure seems to be with an outdated version of the backtrace crate. Did you try cargo update (or just rm Cargo.lock, which is the closest you can get to what our CI tests)? If yes, please use cargo tree or so to figure out where this outdated version is coming from.

@alexcrichton
Copy link
Member

Yes, this was fixed in rust-lang/backtrace-rs#196

@RalfJung
Copy link
Member

Thanks, closing as fixed-upstream.

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

miri v0.1.0 (/Users/alex/Software/rust-devel/src/tools/miri)
├── byteorder v1.2.7
├── cargo_metadata v0.8.0
│   ├── failure v0.1.5
│   │   ├── backtrace v0.3.29
│   │   │   ├── backtrace-sys v0.1.27
│   │   │   │   └── libc v0.2.54
│   │   │   │   [build-dependencies]
│   │   │   │   └── cc v1.0.35
│   │   │   ├── cfg-if v0.1.8
│   │   │   ├── libc v0.2.54 (*)
│   │   │   └── rustc-demangle v0.1.15
│   │   │   [build-dependencies]
│   │   │   └── autocfg v0.1.4
│   │   └── failure_derive v0.1.5
│   │       ├── proc-macro2 v0.4.24
│   │       │   └── unicode-xid v0.1.0
│   │       ├── quote v0.6.10
│   │       │   └── proc-macro2 v0.4.24 (*)
│   │       ├── syn v0.15.22
│   │       │   ├── proc-macro2 v0.4.24 (*)
│   │       │   ├── quote v0.6.10 (*)
│   │       │   └── unicode-xid v0.1.0 (*)
│   │       └── synstructure v0.10.2
│   │           ├── proc-macro2 v0.4.24 (*)
│   │           ├── quote v0.6.10 (*)
│   │           ├── syn v0.15.22 (*)
│   │           └── unicode-xid v0.1.0 (*)
│   ├── semver v0.9.0
│   │   ├── semver-parser v0.7.0
│   │   └── serde v1.0.82
│   │       └── serde_derive v1.0.81
│   │           ├── proc-macro2 v0.4.24 (*)
│   │           ├── quote v0.6.10 (*)
│   │           └── syn v0.15.22 (*)
│   │       [dev-dependencies]
│   │       └── serde_derive v1.0.81 (*)
│   ├── serde v1.0.82 (*)
│   ├── serde_derive v1.0.81 (*)
│   └── serde_json v1.0.33
│       ├── itoa v0.4.3
│       ├── ryu v0.2.7
│       └── serde v1.0.82 (*)
├── directories v2.0.1
│   ├── cfg-if v0.1.8 (*)
│   └── dirs-sys v0.3.3
│       ├── cfg-if v0.1.8 (*)
│       └── libc v0.2.54 (*)
├── env_logger v0.6.0
│   ├── atty v0.2.11
│   │   └── libc v0.2.54 (*)
│   ├── humantime v1.2.0
│   │   └── quick-error v1.2.2
│   ├── log v0.4.6
│   │   └── cfg-if v0.1.8 (*)
│   ├── regex v1.1.6
│   │   ├── aho-corasick v0.7.3
│   │   │   └── memchr v2.2.0
│   │   ├── memchr v2.2.0 (*)
│   │   ├── regex-syntax v0.6.6
│   │   │   └── ucd-util v0.1.3
│   │   ├── thread_local v0.3.6
│   │   │   └── lazy_static v1.3.0
│   │   └── utf8-ranges v1.0.2
│   └── termcolor v1.0.4
├── hex v0.3.2
├── log v0.4.6 (*)
├── num-traits v0.2.6
├── rand v0.6.1
│   ├── libc v0.2.54 (*)
│   ├── rand_chacha v0.1.0
│   │   └── rand_core v0.3.0
│   │   [build-dependencies]
│   │   └── rustc_version v0.2.3
│   │       └── semver v0.9.0 (*)
│   ├── rand_core v0.3.0 (*)
│   ├── rand_hc v0.1.0
│   │   └── rand_core v0.3.0 (*)
│   ├── rand_isaac v0.1.1
│   │   └── rand_core v0.3.0 (*)
│   ├── rand_pcg v0.1.1
│   │   └── rand_core v0.3.0 (*)
│   │   [build-dependencies]
│   │   └── rustc_version v0.2.3 (*)
│   └── rand_xorshift v0.1.0
│       └── rand_core v0.3.0 (*)
│   [build-dependencies]
│   └── rustc_version v0.2.3 (*)
├── rustc-workspace-hack v1.0.0 (/Users/alex/Software/rust-devel/src/tools/rustc-workspace-hack)
│   ├── byteorder v1.2.7 (*)
│   ├── parking_lot v0.7.1
│   │   ├── lock_api v0.1.3
│   │   │   ├── owning_ref v0.3.3
│   │   │   │   └── stable_deref_trait v1.1.0
│   │   │   └── scopeguard v0.3.3
│   │   └── parking_lot_core v0.4.0
│   │       ├── libc v0.2.54 (*)
│   │       ├── rand v0.6.1 (*)
│   │       └── smallvec v0.6.7
│   │           └── unreachable v1.0.0
│   │               └── void v1.0.2
│   │       [build-dependencies]
│   │       └── rustc_version v0.2.3 (*)
│   ├── rand v0.6.1 (*)
│   ├── scopeguard v0.3.3 (*)
│   ├── serde v1.0.82 (*)
│   ├── serde_json v1.0.33 (*)
│   └── smallvec v0.6.7 (*)
│   [build-dependencies]
│   └── syn v0.15.22 (*)
├── rustc_version v0.2.3 (*)
└── shell-escape v0.1.4
[build-dependencies]
└── vergen v3.0.4
    ├── bitflags v1.0.4
    ├── chrono v0.4.6
    │   ├── num-integer v0.1.39
    │   │   └── num-traits v0.2.6 (*)
    │   ├── num-traits v0.2.6 (*)
    │   └── time v0.1.40
    │       └── libc v0.2.54 (*)
    │       [dev-dependencies]
    │       └── winapi v0.3.6
    └── failure v0.1.5 (*)
    [build-dependencies]
    └── chrono v0.4.6 (*)
[dev-dependencies]
├── colored v1.6.0
│   └── lazy_static v0.2.11
└── compiletest_rs v0.3.22
    ├── diff v0.1.11
    ├── filetime v0.2.4
    │   ├── cfg-if v0.1.8 (*)
    │   └── libc v0.2.54 (*)
    ├── getopts v0.2.19
    │   └── unicode-width v0.1.5
    ├── libc v0.2.54 (*)
    ├── log v0.4.6 (*)
    ├── regex v1.1.6 (*)
    ├── rustfix v0.4.4
    │   ├── failure v0.1.5 (*)
    │   ├── log v0.4.6 (*)
    │   ├── serde v1.0.82 (*)
    │   ├── serde_derive v1.0.81 (*)
    │   └── serde_json v1.0.33 (*)
    │   [dev-dependencies]
    │   └── log v0.4.6 (*)
    ├── serde v1.0.82 (*)
    ├── serde_derive v1.0.81 (*)
    ├── serde_json v1.0.33 (*)
    ├── tempfile v3.0.5
    │   ├── cfg-if v0.1.8 (*)
    │   ├── libc v0.2.54 (*)
    │   ├── rand v0.6.1 (*)
    │   └── remove_dir_all v0.5.1
    └── tester v0.5.0
        ├── getopts v0.2.19 (*)
        ├── libc v0.2.54 (*)
        └── term v0.4.6

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Looks like some other crates are referencing the outdated version of backtrace then...

@RalfJung
Copy link
Member

No, this is a patch upgrade which should be used automatically by Cargo.

The only thing depending on backtrace is failure v0.1.5, which is the same version as on our CI -- so it does clearly not hard-code an earlier version.

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Just checked, and yes, it seems you're right. Why is the old version being used despite running cargo update then?

@RalfJung
Copy link
Member

I don't know. What does cargo update -p backtrace say?

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Literally just this:

$ cargo update -p backtrace
    Updating crates.io index

@RalfJung
Copy link
Member

RalfJung commented Jun 13, 2019

Oh, from reading your original text it sounds like you are literally working inside src/tools/miri in the rustc sources? Maybe cargo doesn't like that. I recommend a separate checkout of Miri.

Did you try rm Cargo.lock as I suggested?

But anyway this is definitely not a bug in Miri. Seems more like cargo is acting up, so maybe report it there.

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Good suggestion. Oddly, now I'm getting the same error but with the newer version of backtrace:

error[E0308]: mismatched types
   --> /Users/alex/.cargo/registry/src/github.lhy31512.workers.dev-1ecc6299db9ec823/backtrace-0.3.30/src/symbolize/coresymbolication.rs:155:32

And yes, I tried rm Cargo.lock.

@RalfJung
Copy link
Member

That error is with a standalone checkout? (It's not clear what you are referring to with "good suggestion".)

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Yes, the suggestion of a separate checkout. That's the error I got in that case.

@RalfJung
Copy link
Member

What does rustc --version say?

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Okay, rustc 1.29.0-dev... WTF? rustup override clearly shows it is using my local build.

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Oh, that was just because I was mid-build. Never mind.

rustc 1.37.0-nightly (02564de47 2019-06-10)

@RalfJung
Copy link
Member

How does the rustc version change when you are mid-build...?

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

@RalfJung I think it removes the build artefacts, and so rustup "falls back" on another version of rustc (not sure why such an old one though!).

@RalfJung
Copy link
Member

That's not how rustup works... what should be happening is that you get an error saying that there is no rustc or so. At least that's what happens here.

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Okay, that's a bit worrying then...

Anyway, the good news is that building from a "standalone" checkout of Miri seems to work. (The crucial point is probably that this Miri is outside of the Rustc Cargo workspace.)

cc @rust-lang/cargo You may want to investigate whether this is a bug?

@ehuss
Copy link
Contributor

ehuss commented Jun 13, 2019

Rustup does have a fallback for cargo if it doesn't exist. It falls back to nightly, beta, then stable if any of those toolchains exist. However, if you have an override (or +toolchain), I don't think it has a fallback for rustc, so there should have been an error if rustc doesn't exist.

As for the backtrace issue, I'm having a hard time understanding exactly what's wrong. I went to src/tools/miri and ran cargo +stage2 build and it seemed OK. Can you explain more what the issue is and how to reproduce it?

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

I can reproduce the issue just using that (well, more precisely linking the toolchain and then overriding). Maybe because I'm on macOS...

@ehuss
Copy link
Contributor

ehuss commented Jun 13, 2019

I'm on macos, so I don't think that's the issue. Did you run cargo clean? The only thing I can think of is if there were old artifacts in the target directory that were linked against an older version of libstd (which cargo doesn't track).

Also, the reason cargo update -p backtrace doesn't do anything in the rust repo is because libstd specifies some features that only exist in 0.3.29 and cargo won't update to a newer version that is missing those features (0.3.30 doesn't have the rustc-dep-of-std feature). It should probably print a note why it can't update.

@alexreg
Copy link
Contributor Author

alexreg commented Jun 13, 2019

Hmm, possible. I blew away the build/ dir but not that.

@RalfJung
Copy link
Member

Also, the reason cargo update -p backtrace doesn't do anything in the rust repo is because libstd specifies some features that only exist in 0.3.29 and cargo won't update to a newer version that is missing those features (0.3.30 doesn't have the rustc-dep-of-std feature). It should probably print a note why it can't update.

So that means that I could accidentally be stuck on an old version of a crate if the author removes a feature? Wow, I had no idea. I guess authors shouldn't remove features anyway, but still this is somewhat surprising.

@Eh2406
Copy link

Eh2406 commented Jun 14, 2019

Yes, removing a feature is a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mac Area: Affects only macOS targets C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants