-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Allow cross-compiling with mingw64. #10578
Conversation
Removing the r+ because I have questions and reservations about this that I would like to clear up. |
CFG_LIB_NAME_x86_64-w64-mingw32=$(1).dll | ||
CFG_STATIC_LIB_NAME_x86_64-w64-mingw32=$(1).lib | ||
CFG_LIB_GLOB_x86_64-w64-mingw32=$(1)-*.dll | ||
CFG_LIB_DSYM_GLOB_x86_64-w64-mingw32=$(1)-*.dylib.dSYM | ||
CFG_GCCISH_CFLAGS_x86_64-w64-mingw32 := -Wall -Werror -g -m64 -D_WIN32_WINNT=0x0600 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using -Werror
in a released Makefile
is not a good idea, because new compiler versions add new errors and extend the scope of existing ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libuv has some warnings (like unused function) and I don't think the whole build should fail because of that. Reason why this wasn't a problem before is because we weren't passing these flags to the libuv build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that we leave -Werror
on at least for the code in src/rt
I would like to discuss a path forward for getting the snapshot integrated before landing this. It sounds like we need to install a cross compiler on the linux bots and possibly create a builder which uses that to upload a w64 snapshot. I'd like to confirm this with @brson to make sure that we can do this "soon". This configuration looks like it can bitrot fairly easily, and it'd be nice to get this done all in one go. |
I'm not sure what the usual way of making snapshots for new targets is but I've been playing around with making my own snapshots for arm targets. So the plan of action I was thinking would be to trigger a regular snapshot with this commit and then also make a 'snapshot' for |
I don't understand why we have to stick with cross-build to provide mingw64 snapshot. |
@@ -462,6 +495,7 @@ CFG_PATH_MUNGE_x86_64-w64-mingw32 := | |||
CFG_LDPATH_x86_64-w64-mingw32 :=$(CFG_LDPATH_x86_64-w64-mingw32):$(PATH) | |||
CFG_RUN_x86_64-w64-mingw32=PATH="$(CFG_LDPATH_x86_64-w64-mingw32):$(1)" $(2) | |||
CFG_RUN_TARG_x86_64-w64-mingw32=$(call CFG_RUN_x86_64-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2)) | |||
RUSTC_CROSS_FLAGS_x86_64-w64-mingw32 := --linker=$(CROSS_PREFIX_x86_64-w64-mingw32)$(CC_x86_64-w64-mingw32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this RUSTC_CROSS_FLAGS_*
idea, but I also think this is only meaningful for cross-builds. (Well, the real problem is that platform.mk describes cross-build for some platforms and native-build for some others.) Should we remove this when mingw-w64 get bootstrapped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, but that's why it has CROSS in the name. If you look a bit further down you'll notice it only applies when the build triple is different than the target triple (i.e when you're cross compiling).
You had mentioned that the build scripts don't really allow for multiple host builds, so you had to perform some manual steps in order to build a toolchain? If the steps were simple enough, it'd be great to encode those in the makefile! |
Well the only reason I'd call it simple is because I already expended the effort to figure it out before :p https://gist.github.com/86a6943fa7feab4c2a14 That's the script I used after building rustc with --target=i686-w64-mingw32 and building llvm manually to package it all up into a zip file. |
@@ -499,6 +534,16 @@ ifdef CFG_CCACHE_BASEDIR | |||
endif | |||
|
|||
define CFG_MAKE_TOOLCHAIN | |||
# Prepend the tools with their prefix if cross compiling | |||
ifneq ($(CFG_BUILD_TRIPLE),$(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CFG_BUILD_TRIPLE
-> CFG_BUILD
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right! thanks for catching that.
CFG_LDPATH_i686-w64-mingw32 :=$(CFG_LDPATH_i686-w64-mingw32):$(PATH) | ||
CFG_RUN_i686-w64-mingw32=PATH="$(CFG_LDPATH_i686-w64-mingw32):$(1)" $(2) | ||
CFG_RUN_TARG_i686-w64-mingw32=$(call CFG_RUN_i686-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2)) | ||
RUSTC_CROSS_FLAGS_i686-w64-mingw32 := --linker=$(CROSS_PREFIX_i686-w64-mingw32)$(CC_i686-w64-mingw32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be $(CXX_i686-w64-mingw32)
instead of $(CC..)
on windows because it affects unwinding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, thanks!
With these changes I was able to cross compile for windows from a linux box. (Using the mingw-w64 package on Debian Testing). Fixed a bug where the `target_family` cfg would be wrong when targeting something with a different value than the host. (i.e windows -> unix or unix -> windows). Also, removed `LIBUV_FLAGS` in `mk/rt.mk` because of the redundancy between it and `CFG_GCCISH_CFLAGS_(target)`. After this we can create a snapshot and migrate to mingw64 instead of mingw32.
Add `items_after_test_module` lint Resolves task *3* of rust-lang#10506, alongside *1* resolved at rust-lang#10543 in an effort to help standarize a little bit more testing modules. --- changelog:[`items_after_test_module`]: Added the lint.
With these changes I was able to cross compile for windows from a linux box. (Using the mingw-w64 package on Debian Testing).
Fixed a bug where the
target_family
cfg would be wrong when targeting something with a different value than the host. (i.e windows -> unix or unix -> windows).Also, removed
LIBUV_FLAGS
inmk/rt.mk
because of the redundancy between it andCFG_GCCISH_CFLAGS_(target)
.After this we can create a snapshot and migrate to mingw64 instead of mingw32.