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

Start using serde_derive in a couple places in the compiler #56795

Closed
wants to merge 10 commits into from

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Dec 13, 2018

This is #56447 with the build changes in #56462

r? @alexcrichton

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 13, 2018
@rust-highfive

This comment has been minimized.

@alexcrichton
Copy link
Member

@bors: r+

Once this is green on Travis feel free to p=1 since this is blocking other work

@bors
Copy link
Contributor

bors commented Dec 13, 2018

📌 Commit 7bd36fb has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 13, 2018
@Zoxc
Copy link
Contributor Author

Zoxc commented Dec 14, 2018

@bors r=alexcrichton

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@Zoxc
Copy link
Contributor Author

Zoxc commented Dec 14, 2018

@bors p=1

@bors

This comment has been minimized.

@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 14, 2018
@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 14, 2018
@rust-highfive

This comment has been minimized.

@Zoxc
Copy link
Contributor Author

Zoxc commented Dec 14, 2018

I've changed the approach here to something that requires no build system changes. I made #[no_link] cause extern crate to no longer be reexported, so using a crate won't also require the proc macro used to build it. I should also check for pub extern crate and #[no_link], since that combination is an error. I think that doing this is a breaking change though, so I should probably make a new unstable attribute for this.

I also added a serde_derive dependency to rustc_codegen_llvm so we won't get errors building the stage1 compiler.

@alexcrichton
Copy link
Member

To understand why this is a breaking change, is #[no_link] synthesized by the compiler on dependencies to procedural macros? Or is it a stable attribute we're worried about breaking?

FWIW I think it's worthwhile to get this working without a special attribute because we'll ideally want to pull in crates.io crates that have their own procedural macros, and we wouldn't necessarily want them to annotate imports.

Also I'm not sure I quite understand why rustc_codegen_llvm changes are needed, is it just to prove it out or to fix a bug?

FWIW though I do agree that not requiring procedural macros when depending on a crate is the behavior we want!

@rust-highfive

This comment has been minimized.

@Zoxc
Copy link
Contributor Author

Zoxc commented Dec 15, 2018

#[no_link] is already stable, and I think it's used to use a crate while not linking to any code. I don't think it does anything when applied to proc macros, but it can certainly appear on stable code importing proc macro crates. I'm co-opting it here to also mean no metadata linking to the crate, so it won't be needed when dependencies builds against the current crate.

In the general case for crates.io we need to build proc macros twice when cross compiling libraries which also export the macros / crates (which is the default currently). We need to build them once for the host and then again for the target. We also need to change the built libraries to refer to the target proc macros instead of the host proc macros used to compile them.

The rustc_codegen_llvm changes is needed because the bootstrap compiler doesn't have the #[no_link] change, so it requires serde_derive around. That won't cause problems for cross-compilation though as that only applies to later stages.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@Zoxc
Copy link
Contributor Author

Zoxc commented Jan 24, 2019

I'll have to change the approach taken to enabled proc macros in rustc. Consider this blocked on #57626 for now

@Zoxc Zoxc force-pushed the serde-poc branch 2 times, most recently from 8648d76 to 152ca75 Compare January 28, 2019 15:07
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:34100700:start=1548689157290046396,finish=1548689160027264021,duration=2737217625
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:01:36] 
######################################################################## 100.0%
[00:01:36] extracting /checkout/obj/build/cache/2019-01-18/cargo-beta-x86_64-unknown-linux-gnu.tar.gz
[00:01:37]     Updating crates.io index
[00:01:47] error: the lock file /checkout/Cargo.lock needs to be updated but --locked was passed to prevent this
[00:01:47] Build completed unsuccessfully in 0:00:23
[00:01:47] make: *** [prepare] Error 1
[00:01:47] Makefile:70: recipe for target 'prepare' failed
[00:01:48] Command failed. Attempt 2/5:
[00:01:48] Command failed. Attempt 2/5:
[00:01:48] error: the lock file /checkout/Cargo.lock needs to be updated but --locked was passed to prevent this
[00:01:48] Build completed unsuccessfully in 0:00:00
[00:01:48] make: *** [prepare] Error 1
[00:01:48] Makefile:70: recipe for target 'prepare' failed
[00:01:50] Command failed. Attempt 3/5:
[00:01:50] Command failed. Attempt 3/5:
[00:01:51] error: the lock file /checkout/Cargo.lock needs to be updated but --locked was passed to prevent this
[00:01:51] Build completed unsuccessfully in 0:00:00
[00:01:51] Makefile:70: recipe for target 'prepare' failed
[00:01:51] make: *** [prepare] Error 1
[00:01:54] Command failed. Attempt 4/5:
[00:01:54] Command failed. Attempt 4/5:
[00:01:54] error: the lock file /checkout/Cargo.lock needs to be updated but --locked was passed to prevent this
[00:01:54] Build completed unsuccessfully in 0:00:00
[00:01:54] make: *** [prepare] Error 1
[00:01:54] Makefile:70: recipe for target 'prepare' failed
[00:01:58] Command failed. Attempt 5/5:
[00:01:58] Command failed. Attempt 5/5:
[00:01:58] error: the lock file /checkout/Cargo.lock needs to be updated but --locked was passed to prevent this
[00:01:58] Build completed unsuccessfully in 0:00:00
[00:01:58] Makefile:70: recipe for target 'prepare' failed
[00:01:58] make: *** [prepare] Error 1
[00:01:58] The command has failed after 5 attempts.
---
travis_time:end:117b5e44:start=1548689292583454401,finish=1548689292588397507,duration=4943106
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0ed9e820
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:085d6508
travis_time:start:085d6508
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:04464afd
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:152e9680:start=1548691347493915922,finish=1548691349962113442,duration=2468197520
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---

[00:08:16] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:08:16] tidy error: /checkout/src/librustc_metadata/creader.rs:371: tab character
[00:08:16] tidy error: /checkout/src/librustc_metadata/creader.rs:371: trailing whitespace
[00:08:18] some tidy checks failed
[00:08:18] 
[00:08:18] 
[00:08:18] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:08:18] 
[00:08:18] 
[00:08:18] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:08:18] Build completed unsuccessfully in 0:00:50
[00:08:18] Build completed unsuccessfully in 0:00:50
[00:08:18] make: *** [tidy] Error 1
[00:08:18] Makefile:68: recipe for target 'tidy' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:1887fce5
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Jan 28 16:11:01 UTC 2019
---
travis_time:end:0fd38408:start=1548691861993747489,finish=1548691861998381449,duration=4633960
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:09fd9b99
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:106d7370
travis_time:start:106d7370
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:159f27b8
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:end:106e5dd0:start=1548713318013727339,finish=1548713321167929911,duration=3154202572
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:06:12]    Compiling rustc_data_structures v0.0.0 (/checkout/src/librustc_data_structures)
[00:06:12]    Compiling rustc_apfloat v0.0.0 (/checkout/src/librustc_apfloat)
[00:06:15]    Compiling arena v0.0.0 (/checkout/src/libarena)
[00:06:15]    Compiling syntax_pos v0.0.0 (/checkout/src/libsyntax_pos)
[00:06:15] error: internal compiler error: src/librustc/middle/stability.rs:751: encountered unmarked API: DefId(49/1:9 ~ serde_derive[774e]::Serialize[0])
[00:06:15]    |
[00:06:15]    |
[00:06:15] 40 | use serde::{Serialize, Deserialize};
[00:06:15] 
[00:06:15] thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:526:9
[00:06:15] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[00:06:15] error: aborting due to previous error
---
[00:06:15] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[00:06:15] 
[00:06:15] note: rustc 1.33.0-beta.1 (d1add9723 2019-01-17) running on x86_64-unknown-linux-gnu
[00:06:15] 
[00:06:15] note: compiler flags: -Z force-unstable-if-unmarked -C prefer-dynamic -C opt-level=2 -C prefer-dynamic -C debug-assertions=y -C link-args=-Wl,-rpath,$ORIGIN/../lib --crate-type dylib
[00:06:15] note: some of the compiler flags provided by cargo are hidden
[00:06:15] 
[00:06:15] error: Could not compile `syntax_pos`.
[00:06:15] warning: build failed, waiting for other jobs to finish...

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors
Copy link
Contributor

bors commented Jan 29, 2019

☔ The latest upstream changes (presumably #57948) made this pull request unmergeable. Please resolve the merge conflicts.

@Zoxc Zoxc closed this Jan 30, 2019
bors added a commit that referenced this pull request Mar 8, 2019
Create a derive macro for HashStable and allow proc macros in rustc

A combination of #56864 and #56795. There were complications with using `serde_derive` as rustc doesn't know which crate to use for the host when there is a serde_derive in the sysroot and cargo passes another on the command line built from crates.io.

r? @eddyb (for proc macro changes) @alexcrichton (for rustbuild changes) @michaelwoerister (for the macro itself)
bors added a commit that referenced this pull request Mar 13, 2019
Use derive macro for HashStable

Blocked on #56795
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants