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

Fix 45345 #46592

Merged
merged 7 commits into from
Jan 13, 2018
Merged

Fix 45345 #46592

merged 7 commits into from
Jan 13, 2018

Conversation

o01eg
Copy link
Contributor

@o01eg o01eg commented Dec 8, 2017

There is a fix for #45345

It re-introduces CFG_LIBDIR_RELATIVE which was broken when migration from configure script to x.py.

Other commits fix errors which happen after rustbuild cleanups.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@kennytm kennytm added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 9, 2017
@aidanhs
Copy link
Member

aidanhs commented Dec 14, 2017

Thanks for the PR @o01eg! We'll check in now and again to make sure this gets reviewed soon.

r? @Mark-Simulacrum

@Mark-Simulacrum
Copy link
Member

Changes seem fine, but I'd like to r? @alexcrichton since I'm not entirely familiar with what the flag is meant to do.

@@ -416,6 +416,7 @@ impl Config {
config.docdir = install.docdir.clone().map(PathBuf::from);
config.bindir = install.bindir.clone().map(PathBuf::from);
config.libdir = install.libdir.clone().map(PathBuf::from);
config.libdir_relative = install.libdir.clone().map(PathBuf::from);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm so actually I think this may be an old vestige that just hasn't actually been removed. Could the libdir-relative key get removed in favor of inferring it from libdir?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed libdir_relative from Config struct.

@@ -500,7 +500,7 @@ impl Step for Rustc {

/// Same as `std_cargo`, but for libtest
pub fn rustc_cargo(build: &Build,
compiler: &Compiler,
_compiler: &Compiler,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this argument remains unused, could it be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I've added commit to remove unused argument.

let compiler = if build.force_use_stage1(compiler, target) {
dylib_path.push(builder.rustc_libdir(compiler));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm could you detail a bit why this (and the above one) is needed? Shouldn't the rpath configuration cover this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It builds with rpath disabled because with rpath enabled it ends up with long library path with .. directories.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm when you say "it" in "it builds with rpath disabled" what is that referring to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean Rust installation script which builds Rust from source.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the rpath should be configured here and IIRC that's enabled by default, but are you disabling that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, its just change path to libdir but there need to be stage1 libdir to generate docs and stage2 libdir for rustdoc stage2 executable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to set RUSTC_LIBDIR to stage2 libdir but https://github.com/rust-lang/rust/blob/master/src/bootstrap/doc.rs#L445 use stage1 rustc so it fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it is better to send libdir for stage2 in environment variable RUSTDOC_LIBDIR or so instead set it with add_lib_path?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure yeah adding RUSTDOC_LIBDIR sounds good! I think it'd be best to reuse what's already in the shim executables instead of adding more paths here, but hopefully isn't too bad to add!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reimplemented this with RUSTDOC_LIBDIR.

@o01eg
Copy link
Contributor Author

o01eg commented Dec 16, 2017

Rebased and removed unused data.

@o01eg
Copy link
Contributor Author

o01eg commented Dec 20, 2017

Rebased. Introduce environment variable RUSTDOC_LIBDIR to generate rustc documentation instead of putting original libdir path to libdir in library path.

@o01eg
Copy link
Contributor Author

o01eg commented Dec 21, 2017

Looks like issue with doctest was fixed.

@alexcrichton
Copy link
Member

Nice! Could the rustdoc_cargo function get folded directly into the cargo function perhaps?

@o01eg
Copy link
Contributor Author

o01eg commented Dec 21, 2017

I did it when tried different solutions for library path issue and reject it because it needs additional optional argument for Builder::cargo which would be used for small subset of Builder::cargo usages.

@alexcrichton
Copy link
Member

Do things break if the function is folded in? Functions like this are notoriously hard to get right because there's very little testing, so having the build system be as non-surprising as possible is often best for long-term maintenance.

@o01eg
Copy link
Contributor Author

o01eg commented Dec 23, 2017

Do things break if the function is folded in?

No, things don't break but I decided it is simple to add call to additional function in some places than add additional argument in all places. I could change a way if it looks better.

@alexcrichton
Copy link
Member

Yeah if it's ok let's fold it in to reduce the amount of boilerplate at callsites.

@o01eg
Copy link
Contributor Author

o01eg commented Dec 26, 2017

Ok, I've rewritten to additional argument.

@@ -437,7 +437,8 @@ impl<'a> Builder<'a> {
compiler: Compiler,
mode: Mode,
target: Interned<String>,
cmd: &str) -> Command {
cmd: &str,
rustdoc_libdir: Option<PathBuf>) -> Command {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm isn't this argument always builder.rustc_libdir(compiler); basically? If so, could this avoid being passed as an argument and just be set internally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, compiler here could be stage1 if Build::force_use_stage1 returns true but real launched compiler will be from stage2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed yeah but rustdoc doesn't work at all in stage 1, so I think this is always the stage2 version for rustdoc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so real stage2 rustdoc binary is choosen with REAL_RUSTDOC environment variable while all other parameters from stage1.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er so my point is that this argument is a constant, it's always generated from a stage2 compiler. In that case we can just inline it here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to do it with

cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));

but it fails with error:

thread 'main' panicked at '

Cycle in build detected when adding Assemble { target_compiler: Compiler { stage: 2, host: "x86_64-unknown-linux-gnu" } }
        Any
        Any
        Any
        Any
        Any
', bootstrap/builder.rs:673:17

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, does the same error happen if you only set this env var when the command is "doc"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure yeah, maybe set it for everything that's not "build"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it helped.

@carols10cents
Copy link
Member

r? @alexcrichton

Looks like there's some outstanding questions for you, @alexcrichton !

@rust-highfive rust-highfive assigned alexcrichton and unassigned aturon Jan 9, 2018
@o01eg
Copy link
Contributor Author

o01eg commented Jan 12, 2018

Rebased. Generate RUSTDOC_LIBDIR for stage 2 only.

@alexcrichton
Copy link
Member

@bors: r+

Thanks!

@bors
Copy link
Contributor

bors commented Jan 12, 2018

📌 Commit 472f4e1 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Jan 12, 2018

⌛ Testing commit 472f4e1 with merge 58ecb4753c7dd25cc51cd630f25e2d5fe0b296a5...

@bors
Copy link
Contributor

bors commented Jan 12, 2018

💔 Test failed - status-appveyor

@kennytm
Copy link
Member

kennytm commented Jan 13, 2018

@bors retry

@bors
Copy link
Contributor

bors commented Jan 13, 2018

⌛ Testing commit 472f4e1 with merge 6cf081c...

bors added a commit that referenced this pull request Jan 13, 2018
Fix 45345

There is a fix for #45345

It re-introduces `CFG_LIBDIR_RELATIVE` which was broken when migration from `configure` script to `x.py`.

Other commits fix errors which happen after rustbuild cleanups.
@bors
Copy link
Contributor

bors commented Jan 13, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 6cf081c to master...

@bors bors merged commit 472f4e1 into rust-lang:master Jan 13, 2018
@o01eg o01eg deleted the fix-45345 branch January 13, 2018 07:55
@o01eg
Copy link
Contributor Author

o01eg commented Jan 13, 2018

Could it be backported to beta due it closes regression-from-stable-to-stable?

@kennytm kennytm added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 13, 2018
@kennytm
Copy link
Member

kennytm commented Jan 13, 2018

I've nominated it, but personally I won't assign a high priority in backporting this since the bug is not regression-from-stable-to-{beta,nightly}.

@nikomatsakis
Copy link
Contributor

@o01eg are you using this as part of some packaging scheme? Is it possible to simply apply the patch locally?

@nikomatsakis
Copy link
Contributor

We don't usually backport stable-to-stable regressions unless there is a strong need (just because everybackport adds risk).

@nikomatsakis
Copy link
Contributor

But it depends also on how recently the regression occurred.

@o01eg
Copy link
Contributor Author

o01eg commented Jan 18, 2018

@nikomatsakis Yes, it parts of packaging scheme so it possible to make a patch to fix releases without this PR.

@alexcrichton
Copy link
Member

Ok thanks for the info @o01eg! In that case I'm going to remove the beta nomination

@alexcrichton alexcrichton removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 18, 2018
cuviper added a commit to cuviper/rust that referenced this pull request Feb 19, 2018
This re-introduces a `Config.libdir_relative` field, now derived from
`libdir` and made relative to `prefix` if necessary.

This fixes a regression from rust-lang#46592 when `--libdir` is given an absolute
path.  `Builder::sysroot_libdir` should always use a relative path so
its callers don't clobber system locations, and `librustc` also asserts
that `CFG_LIBDIR_RELATIVE` is really relative.
kennytm added a commit to kennytm/rust that referenced this pull request Feb 25, 2018
…ulacrum

rustbuild: Restore Config.libdir_relative

This re-introduces a `Config.libdir_relative` field, now derived from
`libdir` and made relative to `prefix` if necessary.

This fixes a regression from rust-lang#46592 when `--libdir` is given an absolute
path.  `Builder::sysroot_libdir` should always use a relative path so
its callers don't clobber system locations, and `librustc` also asserts
that `CFG_LIBDIR_RELATIVE` is really relative.
cuviper added a commit to cuviper/rust that referenced this pull request Mar 6, 2018
This re-introduces a `Config.libdir_relative` field, now derived from
`libdir` and made relative to `prefix` if necessary.

This fixes a regression from rust-lang#46592 when `--libdir` is given an absolute
path.  `Builder::sysroot_libdir` should always use a relative path so
its callers don't clobber system locations, and `librustc` also asserts
that `CFG_LIBDIR_RELATIVE` is really relative.
@devurandom
Copy link
Contributor

Is this already in Rust 1.24.1 or will it first appear in Rust 1.25?

@Mark-Simulacrum
Copy link
Member

I believe this will appear in 1.25.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.