Mingw build error: undefined reference to `WinMain@16' in nsinstall_win.c

RESOLVED FIXED in mozilla9

Status

()

Core
Build Config
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: nospam.kotarou.dono, Assigned: nospam.kotarou.dono)

Tracking

Trunk
mozilla9
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 4 obsolete attachments)

(Assignee)

Description

6 years ago
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
(Assignee)

Comment 1

6 years ago
Created attachment 546295 [details] [diff] [review]
Wrapper main
(Assignee)

Comment 2

6 years ago
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
(Assignee)

Comment 3

6 years ago
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
Attachment #546295 - Attachment is obsolete: true
(Assignee)

Comment 4

6 years ago
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
Attachment #546296 - Attachment is obsolete: true
(Assignee)

Comment 5

6 years ago
-Sigh-

Bugzilla messed it up again. I'll just attach it as a regular text file then...
(Assignee)

Comment 6

6 years ago
Created attachment 546298 [details]
text/plain version of the same patch

Updated

6 years ago
Attachment #546298 - Attachment is obsolete: true

Comment 7

6 years ago
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! :-)

Updated

6 years ago
Assignee: nobody → nospam.kotarou.dono
Status: UNCONFIRMED → ASSIGNED
Component: General → Build Config
Ever confirmed: true
QA Contact: general → build-config
(Assignee)

Comment 8

6 years ago
Comment on attachment 546297 [details] [diff] [review]
Attempted to fix up the patch format

Review of attachment 546297 [details] [diff] [review]:
-----------------------------------------------------------------
Attachment #546297 - Flags: review?(khuey)
(Assignee)

Comment 9

6 years ago
Eh. Guess that didn't work. Could someone give me some more detailed instructions?
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 :-)
(Assignee)

Comment 11

6 years ago
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
Attachment #546297 - Attachment is obsolete: true
Attachment #546407 - Flags: review?(khuey)
Attachment #546297 - Flags: review?(khuey)

Comment 12

6 years ago
(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 on attachment 546407 [details] [diff] [review]
Another try

Assuming it works for you, r=me
Attachment #546407 - Flags: review?(khuey) → review+

Updated

6 years ago
Keywords: checkin-needed

Comment 14

6 years ago
Pushed to m-i:

http://hg.mozilla.org/integration/mozilla-inbound/rev/92b574170b33
Keywords: checkin-needed
Whiteboard: [inbound]
Pushed to m-c:
http://hg.mozilla.org/mozilla-central/rev/92b574170b33
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite-
OS: Windows XP → All
Hardware: x86 → All
Resolution: --- → FIXED
Whiteboard: [inbound]
Target Milestone: --- → mozilla9
You need to log in before you can comment on or make changes to this bug.