Page MenuHomePhabricator

[clang][Windows]Ignore Options '/d1nodatetime' and '/d1import_no_registry'
ClosedPublic

Authored by Qfrost911 on Dec 1 2022, 8:16 PM.

Details

Summary

Using clang and VS to build Windows Kernel Driver, two errors will be raised

1>clang-cl : error : no such file or directory: '/d1nodatetime'
1>clang-cl : error : no such file or directory: '/d1import_no_registry'

In the patch, I ignore these options in order to build windows driver under visual studio.

Diff Detail

Event Timeline

Qfrost911 created this revision.Dec 1 2022, 8:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 1 2022, 8:16 PM
Qfrost911 requested review of this revision.Dec 1 2022, 8:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 1 2022, 8:16 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
thieta added a comment.Dec 2 2022, 1:03 AM

I tried to look up what these options do exactly - but they don't seem to be documented.

/d1nodatetime seems like an option that should be implemented instead of just ignored since it can have real reproducible problems not being there.

Do you know what /d1import_no_registry actually does?

I think we can ignore options that are not applicable in clang-cl, but I think if there are options that expect to change something, it's probably better to fail than to silently accept them.

thieta added a reviewer: hans.Dec 2 2022, 1:03 AM

Yes, these options are not documented, so I think they can be ignored. If they are important options for windows driver, why MSVC didn't document them. And, the windows driver run perfectly even if I ignore these two options.

Moreover, there are lots of options which do nothing were defined in clang/Options.td and lld/COFF/Options.td, such as "kernel", "pdbcompress" etc., in order to be compatible with MSVC and other environment.

hans added a comment.Dec 2 2022, 4:00 AM

I hadn't seen /d1 flags before. I suppose they relate to preprocessor stuff as opposed to /d2 flags.

I think the "Unsupported" section below may be better for these. In that case clang-cl will parse the option and warn that it's ignoring it. On line 6931 there's a catch-all for all flags starting with "d2". Perhaps we should add one for "d1" too?

Also, please add these to the "Unsupported but parsed options" tests in clang/test/Driver/cl-options.c

Qfrost911 updated this revision to Diff 479594.Dec 2 2022, 4:25 AM

Ok, I updated this patch.

hans accepted this revision.Dec 2 2022, 4:53 AM

Looks great, thanks!

Do you have commit access, or would you like someone to commit this for you?

This revision is now accepted and ready to land.Dec 2 2022, 4:53 AM
thieta accepted this revision.Dec 2 2022, 6:32 AM

Makes sense they are not documented and we probably can ignore them in that case!

FYI, there's some discussion of /d1nodatetime floating around, even though it isn't formally documented: it disables the definition of the __DATE__, __TIME__, and __TIMESTAMP__ macros.

(No idea about d1import_no_registry, though.)

aganea added a subscriber: aganea.Dec 3 2022, 9:17 AM

FYI, there's some discussion of /d1nodatetime floating around, even though it isn't formally documented: it disables the definition of the __DATE__, __TIME__, and __TIMESTAMP__ macros.

(No idea about d1import_no_registry, though.)

Those two options were introduced (I believe) along with the cl flag /experimental:deterministic (they actually alias to that flag, like -cc1 flags do in Clang). /d1import_no_registry simply adds this attribute to all #import directives, to make them deterministic.

Qfrost911 closed this revision.Dec 8 2022, 8:45 PM