Last Comment Bug 672024 - Mingw build error: undefined reference to `WinMain@16' in nsinstall_win.c
: Mingw build error: undefined reference to `WinMain@16' in nsinstall_win.c
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Build Config (show other bugs)
: Trunk
: All All
: -- normal (vote)
: mozilla9
Assigned To: nospam.kotarou.dono
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-07-16 02:57 PDT by nospam.kotarou.dono
Modified: 2011-08-22 10:56 PDT (History)
5 users (show)
mounir: in‑testsuite-
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Wrapper main (2.29 KB, patch)
2011-07-16 02:58 PDT, nospam.kotarou.dono
no flags Details | Diff | Review
LocalFree now frees the correct variable (2.29 KB, patch)
2011-07-16 03:05 PDT, nospam.kotarou.dono
no flags Details | Diff | Review
Attempted to fix up the patch format (2.30 KB, patch)
2011-07-16 03:09 PDT, nospam.kotarou.dono
no flags Details | Diff | Review
text/plain version of the same patch (2.30 KB, text/plain)
2011-07-16 03:12 PDT, nospam.kotarou.dono
no flags Details
Another try (2.42 KB, patch)
2011-07-17 03:23 PDT, nospam.kotarou.dono
khuey: review+
Details | Diff | Review

Description nospam.kotarou.dono 2011-07-16 02:57:42 PDT
I get this build error on attempting to build config/nsinstall_win.c on MinGW:

c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../libmingw32.a(main.o):main
.c:(.text+0x106): undefined reference to `WinMain@16'

From Bug #411826, I have worked out that it is because MinGW does not support wide mains and have created a patch, based on the other bug's patch, to create a "normal" main and have it wrap around the wide main
Comment 1 nospam.kotarou.dono 2011-07-16 02:58:20 PDT
Created attachment 546295 [details] [diff] [review]
Wrapper main
Comment 2 nospam.kotarou.dono 2011-07-16 03:00:25 PDT
Oh, I forgot to mention that I did a rgrep of he source tree, looking for more files using wide mains without a "normal" main counterpart and found that the file at js/src/config/nsinstal_win.c (Which has the exact same contents as the other nsinstall_win.c) also needed to be patched
Comment 3 nospam.kotarou.dono 2011-07-16 03:05:22 PDT
Created attachment 546296 [details] [diff] [review]
LocalFree now frees the correct variable

I just noticed that I made LocalFree free the wrong variable. Fixed it up
Comment 4 nospam.kotarou.dono 2011-07-16 03:09:55 PDT
Created attachment 546297 [details] [diff] [review]
Attempted to fix up the patch format

Bugzilla did something funny to my patch and made the diffs of two separate files merge in to one. Maybe it was because it didn't have any whitespace between the two. Let me try adding some in
Comment 5 nospam.kotarou.dono 2011-07-16 03:11:59 PDT
-Sigh-

Bugzilla messed it up again. I'll just attach it as a regular text file then...
Comment 6 nospam.kotarou.dono 2011-07-16 03:12:49 PDT
Created attachment 546298 [details]
text/plain version of the same patch
Comment 7 Ed Morley [:emorley] 2011-07-16 11:41:28 PDT
Welcome to contributing! :-)

(In reply to comment #4)
> Bugzilla did something funny to my patch and made the diffs of two separate
> files merge in to one. Maybe it was because it didn't have any whitespace
> between the two. Let me try adding some in

The reason Bugzilla is getting confused is that the patch isn't in the correct format, eg it's using:
--- js/src/config/nsinstall_win.c
+++ js/src/config/nsinstall_win.c.new

rather than:
--- a/js/src/config/nsinstall_win.c
+++ b/js/src/config/nsinstall_win.c

To get mercurial to export patches in the most appropriate format, this should help you out:
https://developer.mozilla.org/en/Mercurial_FAQ#How_can_I_generate_a_patch_for_somebody_else_to_check-in_for_me.3f

When attaching the patch, make sure to pick a reviewer, so that the patch doesn't get missed. You'll need to set the review field to "?" and the email address to whomever you want to ask to review.

The best way to pick who to ask is to either look at the hg log and see what r=zzz entries are present (http://hg.mozilla.org/mozilla-central/filelog/tip/config/nsinstall_win.c) or else look at the modules page here: https://wiki.mozilla.org/Modules

Hope that helps! :-)
Comment 8 nospam.kotarou.dono 2011-07-17 01:49:21 PDT
Comment on attachment 546297 [details] [diff] [review]
Attempted to fix up the patch format

Review of attachment 546297 [details] [diff] [review]:
-----------------------------------------------------------------
Comment 9 nospam.kotarou.dono 2011-07-17 01:51:37 PDT
Eh. Guess that didn't work. Could someone give me some more detailed instructions?
Comment 10 Ed Morley [:emorley] 2011-07-17 01:54:01 PDT
That set the reviewer fine - but it was on the old patch, that isn't in the right format. 

I can manually edit the patch and reupload if you like - but it won't resolve the problem long term. If you take a look at https://developer.mozilla.org/en/Mercurial_FAQ#How_can_I_generate_a_patch_for_somebody_else_to_check-in_for_me.3f and post back if there is anything specific that isn't working :-)
Comment 11 nospam.kotarou.dono 2011-07-17 03:23:10 PDT
Created attachment 546407 [details] [diff] [review]
Another try

The thing is, I'm not using Mercurial. I don't have Mercurial and I don't really want to install it. What I'm doing right now is just downloading the "problem" files manually and diffing it against my edited version.

I've hand edited it a bit, trying to follow the format of another diff on bugzilla. Hopefully this time it works
Comment 12 Jacek Caban 2011-07-18 03:25:18 PDT
(In reply to comment #0)
> From Bug #411826, I have worked out that it is because MinGW does not
> support wide mains and have created a patch, based on the other bug's patch,
> to create a "normal" main and have it wrap around the wide main

Things have changed in mingw (BTW, mingw-w64, a fork of mingw, is the right choice for Mozilla compilation). All GCC version that we care about already support wmain. The thing is that it requires -municode switch in linker invocation. It would be great if you could patch Makefile.in to use that switch instead, since we will probably want to remove wrapper hacks anyways.
Comment 13 Kyle Huey [:khuey] (khuey@mozilla.com) 2011-07-18 09:05:08 PDT
Comment on attachment 546407 [details] [diff] [review]
Another try

Assuming it works for you, r=me
Comment 14 Jacek Caban 2011-08-22 05:24:50 PDT
Pushed to m-i:

http://hg.mozilla.org/integration/mozilla-inbound/rev/92b574170b33
Comment 15 Mounir Lamouri (:mounir) 2011-08-22 10:56:18 PDT
Pushed to m-c:
http://hg.mozilla.org/mozilla-central/rev/92b574170b33

Note You need to log in before you can comment on or make changes to this bug.