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

Look for crates in LIBDIR, provided by --libdir option #16552

Closed
wants to merge 1 commit into from

Conversation

jauhien
Copy link
Contributor

@jauhien jauhien commented Aug 17, 2014

Fixies #11671

This commit changes default relative libdir 'lib' to a relative libdir calculated using LIBDIR provided by --libdir configuration option. In case if no option was provided behavior does not change.

@jauhien
Copy link
Contributor Author

jauhien commented Aug 17, 2014

Oooops, it fails.

What syntax version of bash/other shell should be used in configure?

@huonw
Copy link
Member

huonw commented Aug 17, 2014

configure uses plain sh.

@jauhien
Copy link
Contributor Author

jauhien commented Aug 17, 2014

@huonw, thanks, will fix commit appropriately

@jauhien
Copy link
Contributor Author

jauhien commented Aug 17, 2014

Still stuff in install to be fixed.

@jauhien
Copy link
Contributor Author

jauhien commented Aug 17, 2014

Now it is runnable by plain shell.

btw, checkbashisms configure shows other possible problems with configure:

jauhien@zcj rust % checkbashisms configure 
possible bashism in configure line 696 (should be 'b = a'):
    if [ -z "$CC" ] || [[ $CC == *clang ]]
possible bashism in configure line 696 (alternative test command ([[ foo ]] should be [ foo ])):
    if [ -z "$CC" ] || [[ $CC == *clang ]]

@jauhien
Copy link
Contributor Author

jauhien commented Aug 17, 2014

Travis CI fails now because of issues urelated to this commit.

return secondary_libdir_name();
},

Some(libdir) => return libdir.to_string()
Copy link
Member

Choose a reason for hiding this comment

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

What was the goal of this change? It doesn't look like CFG_LIBDIR_RELATIVE is put into the environment anywhere at build time here.

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 is put there. In main.mk you have a bunch of exports. I have tested it and it works. )

@jauhien
Copy link
Contributor Author

jauhien commented Aug 19, 2014

So I would remove support for libdir for Windows as it does not make much sense for this OS and for unix stay with my changes. As with them everything works well. I have tested it.

@jauhien
Copy link
Contributor Author

jauhien commented Aug 19, 2014

If you are interested what --libdir can be usefull for, you can have a look at https://github.com/Heather/gentoo-rust/pull/28.

tl;dr: this change allows to have different versions of rust installed simultaneously.

@jauhien
Copy link
Contributor Author

jauhien commented Sep 21, 2014

So, what is wrong with this PR? It already perfectly works in Gentoo rust installation (https://github.com/Heather/gentoo-rust/tree/master/dev-lang/rust) and I can not see where in the original isue (#11671) libdir is changed between configuration and installation?

What should be fixed for this PR to be accepted?

@aturon
Copy link
Member

aturon commented Oct 17, 2014

Ping @alexcrichton, what's the next step on this PR?

@alexcrichton
Copy link
Member

@jauhien oh dear I'm sorry sorry this sat for so long, this completely slipped my mind!

Having re-read everything I think I understand a little better what's going on here, but there's two changes I think that need making:

  • On windows, we still need to have libdir point at bin instead of lib
  • In the compiler, the find_libdir function unconditionally returns CFG_LIBDIR_RELATIVE if its defined. This is always defined for a make-based compile, so the None branch is never taken. If --libdir is specified then the environment variable should take precedence, but if not specified then the same fallbacks as today should be used. As written I think it will ignore lib32/lib64 which may end up breaking some BSD flavor.

Does that sound ok to you?

@Gankra
Copy link
Contributor

Gankra commented Nov 8, 2014

@jauhien What's your status?

@jauhien
Copy link
Contributor Author

jauhien commented Nov 8, 2014

I'll look at it when I'll have time. It should be in the nearest days.

@jauhien
Copy link
Contributor Author

jauhien commented Nov 15, 2014

@alexcrichton: your proposition looks ok for me. I will change the PR appropriately. To summarize and be sure that I understand it the right way:

  • we ignore --libdir on windows
  • we use old mechamism when no --libdir is specified
  • we use my current solution when --libdir is specified
  • we do not care about different --libdir in the install script as it is broken anyway (also it is broken now)

not in hardcoded libdir path. If there was no LIBDIR provided
during configuration fallback to hardcoded paths.

Thanks to Jan Niklas Hasse for solution and to Alex Crichton for improvements.

Closes rust-lang#11671
@jauhien
Copy link
Contributor Author

jauhien commented Nov 16, 2014

Changes pushed. As I have said: it ignores --libdir for windows and determines the libdir in the old way if relative libdir is lib.

@alexcrichton: please, review this new version.

@jauhien
Copy link
Contributor Author

jauhien commented Nov 16, 2014

@alexcrichton: also, please, test this change on windows, as I have no machine with this OS here.

return primary_libdir_name();
} else {
return secondary_libdir_name();
}
Copy link
Member

Choose a reason for hiding this comment

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

This may not be quite right because this environment variable is always set during a normal make which means the fallback case will never actually get hit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note if libdir != "lib", so env variable will be used only if it was set to something not default. And if it was set, user defenetely wants rustc use it, not the fallback.

Copy link
Member

Choose a reason for hiding this comment

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

Ack sorry about that! I was skimming too quickly :(.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

np. )

What I really would ask you to do -- test it on windows if you have no other complains. As I am really not sure whether I did not break something on this system.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just always ensure CFG_LIBDIR_RELATIVE is set an use it? This allows us to move the defaults out of rustc and keep them all in configure.

Copy link
Member

Choose a reason for hiding this comment

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

The reasoning is the same as this comment I believe (I'll reply in a just a bit).

@alexcrichton
Copy link
Member

Ok @jauhien, I think this is good to go. I'd like to confirm though, have you run a full build yet with --libdir to ensure that everything works as expected?

else
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
endif
endif
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified by using:

ifeq ($$(CFG_WINDOWSY_$(3))-$(1),0-0)
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/lib
else
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR_RELATIVE)
endif

@jauhien
Copy link
Contributor Author

jauhien commented Nov 20, 2014

@alexcrichton: yes, I have run a full build with those changes and tested it works. But I will add simplification changes from @jmesmon and test again, so, please, do not merge at the moment. I will push changes and comment here if everything works.

@jmesmon: afaik on windows libdir changing does not work correctly. They store libraries in the same bin directory that binaries. I will not change this.

@jauhien
Copy link
Contributor Author

jauhien commented Nov 20, 2014

@alexcrichton: this change from @jmesmon did not work for me. I guess, I can fix it, but it is fragile and adds additional problems for the future maintainance of those build scripts (the easier scripts are the better). So you can merge my changes if you have no objections.

The only thing: I have tested them only on GNU/Linux, if you need to test it on any other platform, please, do it before merging.

@codyps
Copy link
Contributor

codyps commented Nov 20, 2014

I'm not asking you to change the use of bin on windows (which is currently only the default when libdir is not supplied), I'm asking that you avoid disabling --libdir based on OSTYPE.

Even if windows can't support it, I'd rather keep logic around OS specifics in the configure script to a minimum.

@alexcrichton
Copy link
Member

@jmesmon currently the libdir logic is special for windows because Rust doesn't actually work out-of-the-box if the dlls for librustc and such aren't next to rustc.exe. We basically mandate that bindir == libdir for the installation process right now.

@alexcrichton
Copy link
Member

@jauhien ok, thanks so much for being patient on this!

bors added a commit that referenced this pull request Nov 21, 2014
Fixies #11671

This commit changes default relative libdir 'lib' to a relative libdir calculated using LIBDIR provided by --libdir configuration option. In case if no option was provided behavior does not change.
@bors bors closed this Nov 21, 2014
@jauhien
Copy link
Contributor Author

jauhien commented Nov 21, 2014

@alexcrichton: thanks )

@retep998
Copy link
Member

I just tried to make install a build of Rust that has this change on Windows 8.1 x64 using MSYS2 and the only flags I passed to configure were --prefix and I get the following error.

$ make install
cfg: build triple x86_64-pc-windows-gnu
cfg: host triples x86_64-pc-windows-gnu
cfg: target triples x86_64-pc-windows-gnu
cfg: enabling more debugging (CFG_ENABLE_DEBUG)
cfg: host for x86_64-pc-windows-gnu is x86_64
cfg: os for x86_64-pc-windows-gnu is pc-windows-gnu
cfg: good valgrind for x86_64-pc-windows-gnu is
cfg: using CC=gcc (CFG_CC)
cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS)
cfg: no lualatex found, deferring to xelatex
cfg: no xelatex found, deferring to pdflatex
cfg: no pdflatex found, disabling LaTeX docs
cfg: no pandoc found, omitting PDF and EPUB docs
cfg: no llnextgen found, omitting grammar-verification
cfg: including prepare rules
cfg: including dist rules
cfg: including install rules
make[1]: Entering directory '/home/retep998/rust'
cfg: build triple x86_64-pc-windows-gnu
cfg: host triples x86_64-pc-windows-gnu
cfg: target triples x86_64-pc-windows-gnu
cfg: enabling more debugging (CFG_ENABLE_DEBUG)
cfg: host for x86_64-pc-windows-gnu is x86_64
cfg: os for x86_64-pc-windows-gnu is pc-windows-gnu
cfg: good valgrind for x86_64-pc-windows-gnu is
cfg: using CC=gcc (CFG_CC)
cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS)
cfg: no lualatex found, deferring to xelatex
cfg: no xelatex found, deferring to pdflatex
cfg: no pdflatex found, disabling LaTeX docs
cfg: no pandoc found, omitting PDF and EPUB docs
cfg: no llnextgen found, omitting grammar-verification
cfg: including prepare rules
cfg: including dist rules
cfg: including install rules
cleaning destination tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/share/man/man1
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustrt-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/sync-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/std-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/regex-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/log-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/term-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/serialize-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/fmt_macros-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/arena-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/syntax-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/flate-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/getopts-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rbml-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/time-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/graphviz-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustc_llvm-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustc_back-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustc-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustc_trans-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/test-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustdoc-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustdoc.exe
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/share/man/man1/rustdoc.1
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustc.exe
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/share/man/man1/rustc.1
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/liblibc-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/std-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libstd-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/flate-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libflate-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/arena-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libarena-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/term-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libterm-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/serialize-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libserialize-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/sync-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libsync-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/getopts-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libgetopts-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libcollections-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/test-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libtest-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/time-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libtime-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/librand-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/log-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/liblog-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/regex-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libregex-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/graphviz-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libgraphviz-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libcore-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/rbml-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/librbml-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/liballoc-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/rustrt-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/librustrt-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libunicode-*.rlib
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/syntax-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/rustc-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/rustc_trans-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/rustdoc-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/regex_macros-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/fmt_macros-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/rustc_llvm-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/rustc_back-*.dll
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libmorestack.a
prepare: tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/bin/rustlib/x86_64-pc-windows-gnu/lib/libcompiler-rt.a
make[1]: Leaving directory '/home/retep998/rust'
install: looking for install programs
install: found mkdir
install: found printf
install: found cut
install: found grep
install: found uname
install: found tr
install: found sed
install:
install: processing ../../tmp/dist/rust-0.13.0-dev-x86_64-pc-windows-gnu/install.sh args
install:
install: CFG_PREFIX           := /a/rust64
install: CFG_LIBDIR           :=
install: error: libdir must begin with the prefix. Use --prefix to set it accordingly.
/home/retep998/rust/mk/install.mk:22: recipe for target 'install' failed
make: *** [install] Error 1

Do I have to explicitly pass --libdir now?

@jauhien
Copy link
Contributor Author

jauhien commented Nov 23, 2014

Mmm, strange, as it should set CFG_LIBDIR on windows. @alexcrichton: have you tested this change on this platform?

@jauhien
Copy link
Contributor Author

jauhien commented Nov 23, 2014

Yes, I know what was the problem: just ignoring

valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries"

on windows was a bad idea, as it does not write info to configured variables. I will make a PR with fix in some time.

@jauhien
Copy link
Contributor Author

jauhien commented Nov 23, 2014

See #19239 for fix.

@retep998, please, test if it solves the problem for you.

vivo75 pushed a commit to vivo75/vivovl that referenced this pull request Sep 6, 2017
These slots are added:
(major.minor) rust release
(nightly) nightly version
(git) git master branch

eselect module was added, that allows switching between different rust versions

To make all this work, proper support of --libdir option in rust build
system was implemented (previous version did not work), see
rust-lang/rust#16552
Until upstream accepts it, it will be maintained downstream
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

Successfully merging this pull request may close these issues.

8 participants