This is an archive of the discontinued LLVM Phabricator instance.

Set C99 as default C Standard for PS4 target
ClosedPublic

Authored by dyung on Apr 1 2016, 12:58 PM.

Details

Summary

On the PS4, the default C standard is C99 which differs from the current default of C11. This patch makes the default C99 when targeting the PS4. This change also renames the test ps4-cpu-defaults.cpp to ps4-misc-defaults.cpp so that the test I added for this makes more sense given the test filename.

Diff Detail

Repository
rL LLVM

Event Timeline

dyung updated this revision to Diff 52406.Apr 1 2016, 12:58 PM
dyung retitled this revision from to Set C99 as default C Standard for PS4 target.
dyung updated this object.
dyung updated this object.Apr 1 2016, 2:59 PM
dyung added a subscriber: cfe-commits.
ygao added a subscriber: ygao.Apr 1 2016, 5:41 PM
ygao added inline comments.
test/Driver/ps4-misc-defaults.cpp
10 ↗(On Diff #52406)

It seems to me that this part of the test, exercising "-E", should be placed under test/Preprocessor, instead of test/Driver.

rsmith added a subscriber: rsmith.Apr 1 2016, 5:48 PM

What's the motivation for this change? Clang's C11 mode should accept all code accepted by its C99 mode (and conversely, most or perhaps all of the C11 language features are accepted by default in C99 mode as an extension). Is the problem the C11 standard library extensions?

dyung added a comment.Apr 1 2016, 6:03 PM

What's the motivation for this change? Clang's C11 mode should accept all code accepted by its C99 mode (and conversely, most or perhaps all of the C11 language features are accepted by default in C99 mode as an extension). Is the problem the C11 standard library extensions?

From my understanding, there are 2 issues that block us. The first is that we currently do not ship all of the header files for C11. The second is that we do not yet fully have C11 library support yet for our platform.

rsmith accepted this revision.Apr 1 2016, 6:24 PM
rsmith added a reviewer: rsmith.

From my understanding, there are 2 issues that block us. The first is that we currently do not ship all of the header files for C11. The second is that we do not yet fully have C11 library support yet for our platform.

How do things go wrong if Clang is used in C11 mode against a C99 library? Do you have code that conditionally uses C11 library features if they're available? (And thanks for explaining, by the way; this is useful information for when we next consider changing the default language mode -- we'll likely be changing the default C++ language mode soon.)

Anyway, it seems reasonable for the PS4 toolchain to control its defaults here, and the patch itself LGTM.

This revision is now accepted and ready to land.Apr 1 2016, 6:24 PM
dyung added a comment.Apr 1 2016, 6:43 PM

From my understanding, there are 2 issues that block us. The first is that we currently do not ship all of the header files for C11. The second is that we do not yet fully have C11 library support yet for our platform.

How do things go wrong if Clang is used in C11 mode against a C99 library? Do you have code that conditionally uses C11 library features if they're available? (And thanks for explaining, by the way; this is useful information for when we next consider changing the default language mode -- we'll likely be changing the default C++ language mode soon.)

Anyway, it seems reasonable for the PS4 toolchain to control its defaults here, and the patch itself LGTM.

My understanding is that we currently do not ship all of the headers required for C11, so if users tried to use anything from those, they would be unable to do so. I am also under the impression that C11 requires some library support which we do not yet provide.

Thanks for the quick review!

dyung updated this revision to Diff 52622.Apr 4 2016, 2:07 PM
dyung edited edge metadata.

Moved the test to test/Preprocessor as suggested by Gao and found a nice place to add it.

ygao accepted this revision.Apr 4 2016, 2:41 PM
ygao added a reviewer: ygao.

The test LGTM. Thanks!

This revision was automatically updated to reflect the committed changes.
wristow added a subscriber: wristow.Apr 5 2016, 3:22 PM

From my understanding, there are 2 issues that block us. The first is that we currently do not ship all of the header files for C11. The second is that we do not yet fully have C11 library support yet for our platform.

How do things go wrong if Clang is used in C11 mode against a C99 library? Do you have code that conditionally uses C11 library features if they're available? (And thanks for explaining, by the way; this is useful information for when we next consider changing the default language mode -- we'll likely be changing the default C++ language mode soon.)

Anyway, it seems reasonable for the PS4 toolchain to control its defaults here, and the patch itself LGTM.

My understanding is that we currently do not ship all of the headers required for C11, so if users tried to use anything from those, they would be unable to do so. I am also under the impression that C11 requires some library support which we do not yet provide.

To confirm and more directly answer your questions, we haven't encountered any situations where things have gone wrong when compiling in C11 mode against a C99 library. As far as we're aware, Clang doesn't have any problems in that area (e.g., we don't know of any situations where Clang in C11 mode is rejecting valid C99 code). We're just being conservative, in that since we don't provide C11 libraries and headers (and therefore we officially tell our customers we don't support C11), we don't want to run into situations where customers might conditionally enable a C11 library feature. We may revisit that approach sometime in the future depending on customer demand for C11 features, but at this point, we're defaulting to C99 just to be conservative.

we'll likely be changing the default C++ language mode soon.)

Privately, PS4 defaults to C++11; we haven't sent that patch upstream because it would make tests fail on the PS4 bot. :-) This is the work Charles Li has been doing, to get the tests ready for the dialect change.