Add support for cross-compiling to mingw (win32)

RESOLVED FIXED in mozilla1.7final

Status

SeaMonkey
Build Config
--
enhancement
RESOLVED FIXED
15 years ago
13 years ago

People

(Reporter: cls, Assigned: cls)

Tracking

({fixed1.7})

Trunk
mozilla1.7final
x86
Linux
fixed1.7

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 8 obsolete attachments)

(Assignee)

Description

15 years ago
There are a number of places in the code where we make assumptions where
OS_ARCH=WINNT.  These assumptions are incorrect when cross-compiling for win32
(via mingw).  These patches should fix those assumptions.  They also make other
subtle changes to the build:
* nsinstall is only built for mozilla. nspr, ldap & coreconf should use
mozilla's copy rather than constantly rebuilding it
* Added HOST_BIN_SUFFIX for binaries that need to run on the build machine
(Assignee)

Comment 1

15 years ago
Created attachment 133197 [details] [diff] [review]
cross-mingw-ldap v1.0 (checked in)
(Assignee)

Comment 2

15 years ago
Created attachment 133198 [details] [diff] [review]
cross-mingw-nspr v1.0
(Assignee)

Comment 3

15 years ago
Created attachment 133199 [details] [diff] [review]
cross-mingw-moz v1.0

Forgot to mention that the changes needed to cross-compile NSS are in bug
104541.
(Assignee)

Comment 4

15 years ago
Oh, these changes need to be tested against a MSVC build.
Severity: normal → enhancement
(Assignee)

Updated

14 years ago
Attachment #133197 - Flags: review?(dmose)
(Assignee)

Updated

14 years ago
Attachment #133198 - Flags: review?(wchang0222)
(Assignee)

Comment 5

14 years ago
Created attachment 140336 [details] [diff] [review]
cross-mingw-moz v1.1

The following mozconfig settings should be used when cross-compiling to
mingw32:
CROSS_COMPILE=1
HOST_LIBIDL_CONFIG=/usr/bin/libIDL-config
GLIB_PREFIX=/usr/i386-mingw32/moztools
LIBIDL_PREFIX=/usr/i386-mingw32/moztools
CXXFLAGS="-fshort-wchar -DHAVE_CPP_2BYTE_WCHAR_T=1"
ac_add_options	--target=i386-mingw32
ac_add_options	--enable-win32-target=WIN95
ac_add_options	--disable-accessibility
ac_add_options	--disable-activex
ac_add_options	--disable-activex-scripting

# /usr/i386-mingw32/moztools is a direct copy of the %MOZ_TOOLS% installation
from a win32 box.
# -fwchar-short is needed because the runtime test isn't performed when
cross-compiling
(Assignee)

Updated

14 years ago
Attachment #133199 - Attachment is obsolete: true
(Assignee)

Comment 6

14 years ago
Created attachment 140337 [details] [diff] [review]
cross-mingw-moz v1.2

Forgot the _AS_PERL change.
Attachment #140336 - Attachment is obsolete: true
(Assignee)

Updated

14 years ago
Attachment #140337 - Attachment description: v1.2 → cross-mingw-moz v1.2
Attachment #140337 - Flags: review?(bryner)
> ------- Additional Comment #4 From cls  2003-10-13 09:00 PST  [reply] -------
>
>Oh, these changes need to be tested against a MSVC build.

Has this been done yet?
(Assignee)

Comment 8

14 years ago
I tested a native mingw win32 build but I don't have access to MSVC.
Well, the patch looks ok in theory, but I'd like to know that it won't break MSVC.
(Assignee)

Comment 10

14 years ago
Isn't that what tinderboxes are for? ;)

When the original patch was written, I didn't even have a win32 partition
available.  I had to get timeless to verify that a cross-compiled build even
ran.  The moz-1.1 patch fixed the native win32 build problems.  There shouldn't
be anything in the changes that should break because you're using MSVC but we
can wait.
(Assignee)

Comment 11

14 years ago
Created attachment 140909 [details] [diff] [review]
cross-mingw-moz v1.3
(Assignee)

Updated

14 years ago
Attachment #140337 - Attachment is obsolete: true
(Assignee)

Updated

14 years ago
Attachment #140337 - Flags: review?(bryner)
(Assignee)

Updated

14 years ago
Attachment #140909 - Attachment description: cross-mngw-moz v1.3 → cross-mingw-moz v1.3

Comment 12

14 years ago
All three patches build and run with VC7.1.
(Assignee)

Updated

14 years ago
Attachment #140909 - Flags: review?(bryner)
Attachment #140909 - Flags: review?(bryner) → review+
(Assignee)

Comment 13

14 years ago
Created attachment 141729 [details] [diff] [review]
cross-mingw-moz v1.4 (checked in)

make-jars.pl & add-chrome.pl grab the platform setting from perl which is wrong
when cross-compiling.  I added an '-o OS' option to both scripts which allows
us to pass OS_ARCH to the script when cross-compiling.
(Assignee)

Updated

14 years ago
Attachment #140909 - Attachment is obsolete: true
(Assignee)

Updated

14 years ago
Attachment #141729 - Flags: review?(bryner)
Comment on attachment 141729 [details] [diff] [review]
cross-mingw-moz v1.4 (checked in)

Looks good.  I'm assuming msvc's rc.exe is equally fine with foward slashes or
blackslashes in .rc files.
Attachment #141729 - Flags: review?(bryner) → review+
(Assignee)

Updated

14 years ago
Attachment #141729 - Attachment description: cross-mingw-moz v1.4 → cross-mingw-moz v1.4 (checked in)
Comment on attachment 133197 [details] [diff] [review]
cross-mingw-ldap v1.0 (checked in)

r=dmose
Attachment #133197 - Flags: review?(dmose) → review+
(Assignee)

Updated

14 years ago
Attachment #133198 - Flags: review?(wchang0222)
(Assignee)

Comment 16

14 years ago
Created attachment 142868 [details] [diff] [review]
cross-mingw-nspr v1.1
Attachment #133198 - Attachment is obsolete: true
(Assignee)

Updated

14 years ago
Attachment #142868 - Flags: review?(wchang0222)
(Assignee)

Updated

14 years ago
Attachment #133197 - Flags: approval1.7b?

Updated

14 years ago
Attachment #133197 - Flags: approval1.7b? → approval1.7?
Summary: Add support for cross-compiling to mingw → Add support for cross-compiling to mingw (win32)

Comment 17

14 years ago
Comment on attachment 133197 [details] [diff] [review]
cross-mingw-ldap v1.0 (checked in)

a=asa (on behalf of drivers) for checkin to 1.7
Attachment #133197 - Flags: approval1.7? → approval1.7+
(Assignee)

Updated

14 years ago
Attachment #133197 - Attachment description: cross-mingw-ldap v1.0 → cross-mingw-ldap v1.0 (checked in)

Comment 18

14 years ago
Comment on attachment 142868 [details] [diff] [review]
cross-mingw-nspr v1.1

Hi cls,

Some questions.

1. Can we omit the MOZILLA_CLIENT changes?
NSPR does not install its own 'nsinstall' in
objdir/dist/bin, so I think it's not necessary
for NSPR to use Mozilla's nsinstall and not
build its own when MOZILLA_CLIENT is defined.

2. You made several changes like this:

>-    if test -z "$CC"; then
>-	    AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", echo)
>-    fi
>+    AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)

Are these merely a code cleanup or are they
necessary for cross-compiling?

3. I don't understand why the following change
is necessary.

>@@ -677,6 +675,10 @@
> dnl ========================================================
> case "$host" in
> *-mingw*|*-cygwin*|*-msvc*|*-mks*)
>+    NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
>+    if test `echo "${PATH}" | grep -c \;` = 0; then
>+        CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
>+    fi
>     ;;
> *-beos*)
>     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
>@@ -1234,11 +1236,6 @@
>     AC_DEFINE(WIN32)
>     PR_MD_ARCH_DIR=windows
>     RESOLVE_LINK_SYMBOLS=1
>-    NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
>-    if test `echo "${PATH}" | grep -c \;` = 0; then
>-        CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
>-    fi
>-
>     if test -n "$GNU_CC"; then
>         CC="$CC -mno-cygwin"
>         CXX="$CXX -mno-cygwin"

You are merely moving those four lines around.
Also, the first case statement (around line 677/675)
seems to be for overriding HOST_CFLAGS.  The
assignment of NSINSTALL and CYGWIN_WRAPPER look
out of place there.

Comment 19

14 years ago
Comment on attachment 142868 [details] [diff] [review]
cross-mingw-nspr v1.1

>+        solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;

Do we need a semicolon between "OS_ARCH=SunOS" and
"OS_RELEASE=5"?
(Assignee)

Comment 20

14 years ago
> Some questions.
> 
> 1. Can we omit the MOZILLA_CLIENT changes?
> NSPR does not install its own 'nsinstall' in
> objdir/dist/bin, so I think it's not necessary
> for NSPR to use Mozilla's nsinstall and not
> build its own when MOZILLA_CLIENT is defined.

Not really.  With the MOZILLA_CLIENT changes omitted, NSPR expects to use the
version of NSINSTALL from the config directory and it doesn't exist because we
don't build nsinstall when targetting win32.  So we can either use the mozilla
version or we have to build a native version when cross-compiling.

> 2. You made several changes like this:
> 
> >-    if test -z "$CC"; then
> >-	    AC_CHECK_PROGS(CC, "${target_alias}-gcc" "${target}-gcc", echo)
> >-    fi
> >+    AC_CHECK_PROGS(CC, $CC "${target_alias}-gcc" "${target}-gcc", echo)
> 
> Are these merely a code cleanup or are they
> necessary for cross-compiling?

Those are mainly cleanup.  The macro will handle the test.

> 3. I don't understand why the following change
> is necessary.
> 
> >@@ -677,6 +675,10 @@
> > dnl ========================================================
> > case "$host" in
> > *-mingw*|*-cygwin*|*-msvc*|*-mks*)
> >+    NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
> >+    if test `echo "${PATH}" | grep -c \;` = 0; then
> >+        CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
> >+    fi
> >     ;;
> > *-beos*)
> >     HOST_CFLAGS="$HOST_CFLAGS -DXP_BEOS -DBeOS -DBEOS -D_POSIX_SOURCE"
> >@@ -1234,11 +1236,6 @@
> >     AC_DEFINE(WIN32)
> >     PR_MD_ARCH_DIR=windows
> >     RESOLVE_LINK_SYMBOLS=1
> >-    NSINSTALL='$(CYGWIN_WRAPPER) nsinstall'
> >-    if test `echo "${PATH}" | grep -c \;` = 0; then
> >-        CYGWIN_WRAPPER='sh $(topsrcdir)/build/cygwin-wrapper'
> >-    fi
> >-
> >     if test -n "$GNU_CC"; then
> >         CC="$CC -mno-cygwin"
> >         CXX="$CXX -mno-cygwin"
> 
> You are merely moving those four lines around.

Yes, but you'll notice that I'm moving them from a *target* section to a *host*
section.  The CYGWIN_WRAPPER only needs to be used when you're building _on_
win32 but not when you're building _for_ win32.  Same for NSINSTALL.

> Also, the first case statement (around line 677/675)
> seems to be for overriding HOST_CFLAGS. 

Actually, the HOST_CFLAGS assignment is for BeOS which isn't part of the patch.

> >+        solaris*)     OS_ARCH=SunOS OS_RELEASE=5 ;;
> 
> Do we need a semicolon between "OS_ARCH=SunOS" and
> "OS_RELEASE=5"?

Nope. Variable assignment cannot contain whitespace unless it's escaped.

Comment 21

14 years ago
Created attachment 145788 [details] [diff] [review]
wtc's patch for NSPR

cls, could you see if this NSPR patch works?
I removed the MOZILLA_CLIENT changes and the
NSINSTALL/CYGWIN_WRAPPER change.

Comment 22

14 years ago
Comment on attachment 145788 [details] [diff] [review]
wtc's patch for NSPR

I'm marking this patch obsolete.  I wasn't
on the cc list and therefore didn't see cls's
answers to my questions.
Attachment #145788 - Attachment is obsolete: true

Comment 23

14 years ago
Created attachment 145789 [details] [diff] [review]
wtc's patch for NSPR

cls, please test this patch.

The only change between this patch and your
NSPR patch is that I removed the MOZILLA_CLIENT
changes.  I believe that your other changes
will cause us to build nsinstall for the host
system correctly when we are cross-compiling for
win32.
(Assignee)

Comment 24

14 years ago
Comment on attachment 145789 [details] [diff] [review]
wtc's patch for NSPR

Nope.  This patch will not work because the build expects to find nsinstall in
nsprpub/config but we don't build nsinstall when OS_ARCH = WINNT.  

make[1]: Entering directory `/usr/cls/src/obj-x-mingw'
/usr/bin/make -C nsprpub
make[2]: Entering directory `/usr/cls/src/obj-x-mingw/nsprpub'
cd config; /usr/bin/make -j1 export
make[3]: Entering directory `/usr/cls/src/obj-x-mingw/nsprpub/config'
gcc -o now.o -c -DXP_UNIX ../../../mozilla/nsprpub/config/now.c
gcc  now.o   -o now
rm -f /home/cls/src/obj-x-mingw/dist/bin/nspr-config
make[3]: Leaving directory `/usr/cls/src/obj-x-mingw/nsprpub/config'
...
...
make[5]: Entering directory `/usr/cls/src/obj-x-mingw/nsprpub/pr/include/md'
../../../config/./nsinstall -R -m 444
../../../../../mozilla/nsprpub/pr/include/md/_aix32.cfg  ........
make[5]: ../../../config/./nsinstall: Command not found
make[5]: *** [export] Error 127
make[5]: Leaving directory `/usr/cls/src/obj-x-mingw/nsprpub/pr/include/md'
Attachment #145789 - Flags: review-
(Assignee)

Comment 25

14 years ago
Created attachment 145799 [details] [diff] [review]
cross-mingw-nspr-v1.2

Wan-Teh, this patch does what you expected the previous one to do.
Attachment #142868 - Attachment is obsolete: true
Attachment #145789 - Attachment is obsolete: true
(Assignee)

Updated

14 years ago
Attachment #142868 - Flags: review?(wchang0222)
(Assignee)

Updated

14 years ago
Attachment #145799 - Flags: review?(wchang0222)

Comment 26

14 years ago
Comment on attachment 145799 [details] [diff] [review]
cross-mingw-nspr-v1.2

r=wtc.	Thank you, cls, for getting this to
work the way I wanted.
Attachment #145799 - Flags: review?(wchang0222) → review+

Comment 27

14 years ago
The reason I wanted to avoid MOZILLA_CLIENT code in
NSPR is to reduce the risk of inadvertently breaking
Mozilla build when I change NSPR.  I rarely build
Mozilla and usually test my NSPR changes by building
NSPR standalone and running NSPR's test suite.  So
the closer the NSPR standalone build is to the NSPR
MOZILLA_CLIENT build, the better.
(Assignee)

Updated

14 years ago
Attachment #145799 - Flags: approval1.7?
Comment on attachment 145799 [details] [diff] [review]
cross-mingw-nspr-v1.2

How risky is this?  We're planning to branch on Monday, so you're likely to
have to fix any regressions on the 1.7 branch as well...
(Assignee)

Comment 29

14 years ago
Minimal risk.  I've had a variant of this patch in my tree since October and we
made basically the same changes to ldap which got approved and checked in a
couple of weeks ago.
(Assignee)

Comment 30

14 years ago
Comment on attachment 145799 [details] [diff] [review]
cross-mingw-nspr-v1.2

This patch has been checked in on the NSPR trunk and the
NSPRPUB_PRE_4_2_CLIENT_BRANCH branch (seamonkey trunk).

Comment 31

14 years ago
Comment on attachment 145799 [details] [diff] [review]
cross-mingw-nspr-v1.2

a=asa (on behalf of drivers) for checkin to 1.7
Attachment #145799 - Flags: approval1.7? → approval1.7+
(Assignee)

Updated

14 years ago
Status: NEW → RESOLVED
Last Resolved: 14 years ago
Keywords: fixed1.7
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.7final

Comment 32

14 years ago
Comment on attachment 145799 [details] [diff] [review]
cross-mingw-nspr-v1.2

This patch has been checked in on the NSPR_4_5_BRANCH
(NSPR 4.5) and the MOZILLA_1_7_BRANCH (Mozilla 1.7 final).
Product: Browser → Seamonkey
You need to log in before you can comment on or make changes to this bug.