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

Allow cross-compiling with mingw64. #10578

Merged
merged 4 commits into from
Nov 24, 2013
Merged

Allow cross-compiling with mingw64. #10578

merged 4 commits into from
Nov 24, 2013

Conversation

luqmana
Copy link
Member

@luqmana luqmana commented Nov 20, 2013

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.

@alexcrichton
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

why was this removed?

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member

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

@alexcrichton
Copy link
Member

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.

@luqmana
Copy link
Member Author

luqmana commented Nov 20, 2013

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 i686-w64-mingw64 manually (which basically involves building llvm, arranging some files in a certain way and then just running the python script to package it up). Then we could just upload it and register it along with all the other snapshots.

@klutzy klutzy mentioned this pull request Nov 20, 2013
@klutzy
Copy link
Contributor

klutzy commented Nov 20, 2013

I don't understand why we have to stick with cross-build to provide mingw64 snapshot. ../configure && make check already works on mingw-w64 although it is not a "real" cross-build.
I think there is only runtime differences between i686-pc-mingw32 (mingw) and i686-w64-mingw32 (mingw64 32-bit), and we already bundle dlls so it just works. Here is more details.

@@ -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)
Copy link
Contributor

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?

Copy link
Member Author

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).

@alexcrichton
Copy link
Member

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!

@luqmana
Copy link
Member Author

luqmana commented Nov 21, 2013

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))
Copy link
Contributor

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?

Copy link
Member Author

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)
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, thanks!

bors added a commit that referenced this pull request Nov 24, 2013
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.
@bors bors closed this Nov 24, 2013
@bors bors merged commit ae5a13d into rust-lang:master Nov 24, 2013
@luqmana luqmana deleted the mingw64 branch November 25, 2013 19:20
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 23, 2023
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.
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.

5 participants