Closed Bug 472093 Opened 16 years ago Closed 15 years ago

fix build system to use NTDDI_VERSION instead of random checks

Categories

(Firefox Build System :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: timeless, Assigned: rain1)

References

()

Details

Attachments

(11 files, 8 obsolete files)

1.18 KB, patch
ted
: review+
Details | Diff | Splinter Review
3.77 KB, patch
Details | Diff | Splinter Review
2.41 KB, patch
rain1
: review+
Details | Diff | Splinter Review
5.92 KB, patch
rain1
: review+
Details | Diff | Splinter Review
626 bytes, patch
ted
: review+
Details | Diff | Splinter Review
811 bytes, patch
jimm
: review+
Details | Diff | Splinter Review
2.38 KB, patch
jimm
: review+
Details | Diff | Splinter Review
2.53 KB, patch
bzbarsky
: review+
bzbarsky
: superreview+
Details | Diff | Splinter Review
1.97 KB, patch
vlad
: review+
Details | Diff | Splinter Review
1.19 KB, patch
rain1
: review-
Details | Diff | Splinter Review
7.65 KB, patch
beltzner
: approval1.9.1-
Details | Diff | Splinter Review
the current system for building random bits that need system components on windows is totally broken.

what follows are a series of patches which replace the broken system with a correct system based on NTDDI (which is the proper way to do this)
Attachment #355372 - Flags: review?(ted.mielczarek)
Attached patch code changes for helper app (obsolete) — Splinter Review
Attachment #355373 - Flags: review?(ted.mielczarek)
Attached patch code for stock icons (obsolete) — Splinter Review
Attachment #355374 - Flags: review?(ted.mielczarek)
Attachment #355375 - Flags: review?(ted.mielczarek)
Attachment #355376 - Flags: review?(ted.mielczarek)
Comment on attachment 355372 [details] [diff] [review]
switch configure to use NTDDI

+*)
+    AC_MSG_ERROR([Invalid value --with-windows-version, must be 500, 501 or 600]);

Do you think we need to keep a check for specific versions here, or could we just let the user pass any 3 digit number? Doesn't really bother me either way, I guess, just sucks to have to continually update stuff like this in the future. Patch looks fine otherwise.
Attachment #355372 - Flags: review?(ted.mielczarek) → review+
Also, I think a peer of the code you're touching should review the rest of these patches.
adding dependency, so that when the win2k bug gets fixed, this should be updated.
Depends on: 363393
Attachment #355373 - Flags: review?(ted.mielczarek)
Attachment #355374 - Flags: review?(ted.mielczarek)
Attachment #355375 - Flags: review?(ted.mielczarek)
Attachment #355376 - Flags: review?(ted.mielczarek)
Just curious, if you build with an SDK older than the Vista SDK, how does something like:
+#if NTDDI_VERSION >= NTDDI_LONGHORN
work? NTDDI_LONGHORN is probably undefined in that case, right? Will the preprocessor just error out on that?
ted, you're right (undefined items in #if are treated as 0, so the if's do the wrong thing for the case you described), the proper way to do it is this:

#define HAS_NTDDI_VERSION(X) X && (NTDDI_VERSION >= X)
#if HAS_NTDDI_VERSION(NTDDI_LONGHORN)

can you suggest a good place for a HAS_NTDDI_VERSION macro to live?
One of the problems with the above approach is that we're overloading NTDDI_VERSION to have two meanings:
- minimum version of windows that the program is guaranteed to run on (the meaning the SDK uses)
- maximum version of windows we build specific support for

Bumping up the NTDDI_VERSION or _WIN32_WINNT globally can cause problems with increased structure sizes, e.g. <http://blogs.msdn.com/oldnewthing/archive/2003/12/12/56061.aspx>, so there's a non-zero risk of bustage with older versions of Windows.

Another problem is that the Vista SDK is the first one to actually define NTDDI_VERSION. The older SDKs relied solely on _WIN32_WINNT and friends.

So, the Server 2008 and higher SDKs make it easy to find out the highest version we can have support for, using winsdkver.h. The Vista SDK has sdkddkver.h (which defines NTDDI_VERSION), and the older SDKs don't have either. The patch uses this information to figure out which version of the SDK is being used, and to define a constant MOZ_WINSDK_MAXVER based on it.

The reason I'm comparing the two values instead of just using NTDDI_MAXVER is that the Win7 beta SDK defines NTDDI_MAXVER to be 0x06000100 (Vista SP1 == Server 2008) instead of what it should be, 0x06010000. This will probably be fixed in the final SDK, though, so I'm fine with removing that check.

If MOZ_WINSDK_MAXVER is now substituted for NTDDI_VERSION, things should work. Since the Server 2003 SDK is the oldest we support, the HAS_NTDDI_VERSION macro will mean that we don't have to worry about NTDDI_* not being defined.

Tested, works fine with both the Win7 and the Vista SDKs. I'm not sure what's accurate for mingw, so right now I've set it to Server 2003 (0x05020000).
Attachment #360478 - Flags: review?(ted.mielczarek)
Comment on attachment 360478 [details] [diff] [review]
define MOZ_WINSDK_MAXVER instead of overloading NTDDI_VERSION

+                            ac_cv_winsdk_maxver=`cl -E -nologo conftest.h 2>/dev/null | tail -n1`

Just use $CPP here, it's set correctly earlier in the file.

+                # Assume the Server 2003 Platform SDK
+                MOZ_WINSDK_MAXVER=0x05020000

This is basically just an assumption here, right? I guess we don't actually have any existing checks that you're using a Win2k3 SDK, except that MozillaBuild doesn't look for anything older than that.

+#if (NTDDI_VERSION_FROM_WIN32_WINNT(_WIN32_WINNT_MAXVER) > NTDDI_MAXVER)

As discussed on IRC, I'd like a comment explaining that this is a workaround for the current broken Windows 7 SDK.

r=me with those comments addressed.
Attachment #360478 - Flags: review?(ted.mielczarek) → review+
(In reply to comment #11)
> +                # Assume the Server 2003 Platform SDK
> +                MOZ_WINSDK_MAXVER=0x05020000
> 
> This is basically just an assumption here, right? I guess we don't actually
> have any existing checks that you're using a Win2k3 SDK, except that
> MozillaBuild doesn't look for anything older than that.

Yeah, that's right.

According to Ted, our policy should be to not silently disable code if we can't build it. We should instead "error with an informative message telling you either a) what you need to install to build the code, or b) what you need to disable to not build that code".

In this case, we should target the Vista SDK by default, and error out if the Vista SDK is not present, telling him to either install the Vista SDK or target a lower version.
Per discussion on IRC, I also removed the #define, as we're going to test against the target ver instead.
Attachment #360478 - Attachment is obsolete: true
Attachment #363186 - Flags: review+
Keywords: checkin-needed
Attachment #363186 - Attachment description: MOZ_WINSDK_MAXVER review nits fixed → [to checkin] MOZ_WINSDK_MAXVER review nits fixed
The patch also defines both the targetver and MOZ_DISABLE_VISTA_SDK_REQUIREMENTS if one of them is set. The idea is to eventually get rid of the DISABLE_VISTA_SDK_REQUIREMENTS define and just check version numbers.
Attachment #363343 - Attachment is obsolete: true
Attachment #363346 - Flags: review?(ted.mielczarek)
Comment on attachment 363186 [details] [diff] [review]
MOZ_WINSDK_MAXVER review nits fixed
[Checkin: Comment 16]


http://hg.mozilla.org/mozilla-central/rev/d55509df48fa
Attachment #363186 - Attachment description: [to checkin] MOZ_WINSDK_MAXVER review nits fixed → MOZ_WINSDK_MAXVER review nits fixed [Checkin: Comment 16]
Keywords: checkin-needed
Target Milestone: --- → mozilla1.9.2a1
Attachment #363346 - Flags: review?(ted.mielczarek) → review-
Comment on attachment 363346 [details] [diff] [review]
Part 2, define MOZ_WINSDK_TARGETVER + error out if SDK is too old, v2

I don't want to add a --with-winsdk-target, we should just use the value of --with-windows-version (translated into a NTDDI_VERSION, ala timeless' patch) as the target value here.

+    AC_MSG_WARN([Resulting builds will not be compatible with Windows Vista. (bug 428970)])

No need for this, if someone is explicitly passing this option they ought to know they're not targeting Vista anymore.

+#if 0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER
+#error "sdk not recent enough"
+#endif

This needs a way better error message. I might recommend that you make a small page on developer.mozilla.org, and provide a short error with the URL in this error.
Assignee: timeless → sid.bugzilla
I've fixed Ted's nits, added a wiki page, and changed --with-windows-version to mean this. Since --with-windows-version isn't relevant in the JS configure.in any more, and JS doesn't support MOZ_DISABLE_VISTA_SDK_REQUIREMENTS, I've removed it from there entirely.

bsmedberg: since ted has indicated that he's quite busy, will it be fine if you review this patch? Thanks.
Attachment #363346 - Attachment is obsolete: true
Attachment #366552 - Flags: review?
Attachment #366552 - Flags: review? → review?(benjamin)
Blocks: 474060
Attachment #366552 - Flags: review?(benjamin) → review-
Comment on attachment 366552 [details] [diff] [review]
Part 2, define MOZ_WINSDK_TARGETVER + error out if SDK is too old, v3

>diff --git a/configure.in b/configure.in

>+    # If the maximum version supported by this SDK is lower than the target
>+    # version, error out
>+    AC_MSG_CHECKING([for Windows SDK being recent enough])
>+    AC_TRY_COMPILE([],
>+#if 0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER
>+#error "sdk not recent enough"
>+#endif

It has been my experience that AC_TRY_COMPILE doesn't work with MSVC at all... are you sure this does what you expect? And, aren't MOZ_WINSDK_TARGETVER and MOZ_WINSDK_MAXVER both shell variables? Why do you need AC_TRY_COMPILE instead of something simpler?
(In reply to comment #19)
> (From update of attachment 366552 [details] [diff] [review])
> >diff --git a/configure.in b/configure.in
> 
> >+    # If the maximum version supported by this SDK is lower than the target
> >+    # version, error out
> >+    AC_MSG_CHECKING([for Windows SDK being recent enough])
> >+    AC_TRY_COMPILE([],
> >+#if 0x$MOZ_WINSDK_TARGETVER > $MOZ_WINSDK_MAXVER
> >+#error "sdk not recent enough"
> >+#endif
> 
> It has been my experience that AC_TRY_COMPILE doesn't work with MSVC at all...
> are you sure this does what you expect? 

Yes, this works fine, at least with MSVC9. I assumed it would work fine with earlier versions too, because of <http://mxr.mozilla.org/mozilla-central/source/configure.in#492>.

> And, aren't MOZ_WINSDK_TARGETVER and
> MOZ_WINSDK_MAXVER both shell variables? Why do you need AC_TRY_COMPILE instead
> of something simpler?

Is there a better way to compare two hexadecimal values? The trouble is that we extract the MOZ_WINSDK_MAXVER straight from the header file, so that has to have the leading 0x.
perl -e "exit((0x01 < 0x01) ? 0 : 1)" or somesuch
Attached patch Part 2, v4 (obsolete) — Splinter Review
Thanks -- I've changed the check to perl.
Attachment #366552 - Attachment is obsolete: true
Attachment #369111 - Flags: review?(benjamin)
Attachment #369111 - Flags: review?(benjamin) → review+
Keywords: checkin-needed
Attachment #369111 - Attachment description: Part 2, v4 → [to checkin] Part 2, v4
Can we get quick summary of how to use this? Also, once this last part lands, are we good to go for some win7 checkins?
(In reply to comment #23)
> Can we get quick summary of how to use this?

We need to figure out where to place the HAS_NTDDI_VERSION macro, as mentioned in comment 9. Once that is done, we'll have to wrap (say) Win7 specific blocks with

#if HAS_NTDDI_VERSION(NTDDI_WIN7)

> Also, once this last part lands,
> are we good to go for some win7 checkins?

After the HAS_NTDDI_VERSION thing lands, sure.
Attachment #369111 - Attachment is obsolete: true
Attachment #372121 - Flags: review+
Attachment #369111 - Attachment description: [to checkin] Part 2, v4 → Part 2, v4
Per a discussion with Ted, this shouldn't cause trouble.
Attachment #372322 - Flags: review?(ted.mielczarek)
Attachment #355376 - Attachment is obsolete: true
Attachment #372324 - Flags: review?(jmathies)
Jim, you seem to be the go-to guy in this area as well -- is it fine if you review this?
Attachment #372325 - Flags: review?(jmathies)
Attachment #355373 - Attachment is obsolete: true
Attachment #372326 - Flags: superreview?(bzbarsky)
Attachment #372326 - Flags: review?(bzbarsky)
These patches should cover all the disable-vista-sdk uses in m-c.

I've tested these, and these seem to work fine with both --with-windows-version=502 and 600.

I haven't touched parental controls because I've kept it as is in configure.in as well.
Attachment #355374 - Attachment is obsolete: true
Attachment #372327 - Flags: superreview?
Attachment #372327 - Flags: review?
Attachment #372327 - Flags: superreview?(vladimir)
Attachment #372327 - Flags: superreview?
Attachment #372327 - Flags: review?(vladimir)
Attachment #372327 - Flags: review?
Attachment #372326 - Flags: superreview?(bzbarsky)
Attachment #372326 - Flags: superreview+
Attachment #372326 - Flags: review?(bzbarsky)
Attachment #372326 - Flags: review+
Attachment #372327 - Flags: superreview?(vladimir)
Attachment #372327 - Flags: superreview?(ted.mielczarek)
Attachment #372327 - Flags: review?(vladimir)
Attachment #372327 - Flags: review+
Attachment #372324 - Flags: review?(jmathies) → review+
Attachment #372325 - Flags: review?(jmathies) → review+
(In reply to comment #30)
> Created an attachment (id=372327) [details]
> Code changes for stock icons
> 
> These patches should cover all the disable-vista-sdk uses in m-c.
> 
> I've tested these, and these seem to work fine with both
> --with-windows-version=502 and 600.
> 
> I haven't touched parental controls because I've kept it as is in configure.in
> as well.

Are you planning on leaving that flag in for pc or migrating that over as well? I don't see any reason to split that out, seems like it should use this new scheme as well.
(In reply to comment #31)
> (In reply to comment #30)
> > Created an attachment (id=372327) [details] [details]
> > Code changes for stock icons
> > 
> > These patches should cover all the disable-vista-sdk uses in m-c.
> > 
> > I've tested these, and these seem to work fine with both
> > --with-windows-version=502 and 600.
> > 
> > I haven't touched parental controls because I've kept it as is in configure.in
> > as well.
> 
> Are you planning on leaving that flag in for pc or migrating that over as well?
> I don't see any reason to split that out, seems like it should use this new
> scheme as well.

I presumed that
- we might add parental controls support for other OSes in the future
- someone might want to build with the Vista SDK but with parental controls disabled.

At least that's why I thought there were separate flags for parental controls and the Vista SDK -- maybe I'm wrong there. If you think the disable parental controls flag should be merged, I'll file a follow-up bug for it.
Comment on attachment 372121 [details] [diff] [review]
part 2, merged to m-c tip
[Checkin: Comment 33]

Pushed to m-c: http://hg.mozilla.org/mozilla-central/rev/fcaf50dc12d2
Attachment #372121 - Attachment description: [to checkin] part 2, merged to m-c tip → [checked in] part 2, merged to m-c tip
Keywords: checkin-needed
Attachment #372322 - Flags: review?(ted.mielczarek) → review+
Comment on attachment 372327 [details] [diff] [review]
Code changes for stock icons

You don't need to ask me for review on these patches that don't touch the build system, but this looks fine.
Attachment #372327 - Flags: superreview?(ted.mielczarek) → superreview+
> - someone might want to build with the Vista SDK but with parental controls
> disabled.

That reason WFM. The original bug is bug 425979. 

I've got another patch coming for some code related to gesture support on win7 that landed a few weeks ago as well.
Attachment #373868 - Flags: review?(sid.bugzilla)
Attachment #373868 - Flags: review?(sid.bugzilla) → review-
Comment on attachment 373868 [details] [diff] [review]
Code changes for gesture support

This errors out at nsWinGesture.h while building with the Windows 7 beta SDK, with --with-windows-version=601.

This isn't the right thing to do, as the gesture defines are included from the SDK headers only when NTDDI_VERSION is >= NTDDI_WIN7, and we aren't bumping it up here.

I see three options:
1. leave it as it is
2. make the check #if NTDDI_VERSION < MOZ_NTDDI_WIN7
3. bump NTDDI_VERSION in nsWinGesture.h up when MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7, though that's a bit riskier as future code won't have the natural checks that the lower NTDDI_VERSION provides.

I'd be fine with either 1 or 2.
Jim's indicated that he'd like to leave the gestures code as it is.
Keywords: checkin-needed
Blocks: 363393
No longer depends on: 363393
Comment on attachment 372121 [details] [diff] [review]
part 2, merged to m-c tip
[Checkin: Comment 33]


What about 1.9.1?

I wanted to port this to comm-central, but I guess SeaMonkey needs 1.9.1 and 1.9.2 to be synchronized first?
{
configure: error: Invalid value --with-windows-version, must be 400, 500 or 501
}
Attachment #372121 - Attachment description: [checked in] part 2, merged to m-c tip → part 2, merged to m-c tip [Checkin: Comment 33]
(In reply to comment #39)
> (From update of attachment 372121 [details] [diff] [review])
> 
> What about 1.9.1?
> 

If you'd like to port it to c-c, then yes, all the patches here need to be checked in to 1.9.1 as well. Not sure if this will get approval though.

Of course, the patch needs to be checked in to m-c before approval's asked, so it'd be great if you or someone else could do that. :)
http://hg.mozilla.org/mozilla-central/rev/047ec54f7a9d
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Attachment #374083 - Attachment description: [to checkin] patches to check in, combined → [checkin: comment 41] patches to check in, combined
Attachment #363186 - Flags: approval1.9.1?
Attachment #372121 - Flags: approval1.9.1?
Attachment #374083 - Flags: approval1.9.1?
Flags: in-testsuite-
One advantage of having this in 1.9.1 is that it'll be a lot easier to backport some Win7 features from m-c, if we decide to do so.

All these patches are pretty low risk, and they shouldn't affect official builds, as they use neither --disable-vista-sdk-requirements nor --with-windows-version.
Comment on attachment 374083 [details] [diff] [review]
[checkin: comment 41] patches to check in, combined

I don't think we'll be backporting Windows 7 things to branch, unless you think there are security fixes that would require these changes.
Attachment #374083 - Flags: approval1.9.1? → approval1.9.1-
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: