This is an archive of the discontinued LLVM Phabricator instance.

Let cmake infer source file language by the file extension.
ClosedPublic

Authored by dougk on Jun 24 2015, 2:16 PM.

Details

Summary

The purpose of this is to avoid compiling '.S' files using '.c' flags, which removes "-pedantic" from the cc command. Not using -pedantic is good because there is nearly nothing to reasonably warn about; and the only thing that is warned about is that you can't correctly invoke GLUE2 in lib/builtins/assembly.h on platforms for which USER_LABEL_PREFIX is the empty string.

There is essentially no correct way to avoid that - though there are perhaps dubious ways - and my feeling is that gcc is simply overzealous here because its intent was to warn about invoking a macro of two arguments when only one was supplied, which is not quite the same as giving it a macro having zero characters as one argument; but the preprocessor treats those the same for all intents and purposes.
Incidentally, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33305 was the gcc PR which requested the warning in the first place.

This patch depends on http://reviews.llvm.org/D10707

Diff Detail

Repository
rL LLVM

Event Timeline

dougk updated this revision to Diff 28406.Jun 24 2015, 2:16 PM
dougk retitled this revision from to Let cmake infer source file language by the file extension..
dougk updated this object.
dougk edited the test plan for this revision. (Show Details)
dougk added a reviewer: chapuni.
dougk added a subscriber: Unknown Object (MLST).
rnk added a subscriber: rnk.Jul 27 2015, 2:12 PM

I think this will be problematic. See r214013, which originally introduced this line, and r214130, which last touched the project() line.

rnk edited reviewers, added: rnk, compnerd, samsonov; removed: chapuni.Jul 27 2015, 2:12 PM
dougk added a comment.Jul 27 2015, 3:15 PM

Here's my understanding of the history of the changes -

r214013 contained contradictory directives - on one hand, it informed cmake that the project contained ASM source, and on the other, it said that all files are C source. You shouldn't need to tell cmake that '.s' is to be compiled as '.c' once you tell it that the project contains ASM source. Because the CMakeLists.txt prior to this revision did not say that the project contained ASM, it would have been the case that a standalone build of compiler-rt failed to compile any '.s' file (resulting in PR20360), while a non-standalone build worked correctly because of an enable_language() command inherited from the parent scope (as far as I can tell).

r213684 (somewhat correctly) added the 'set_source_file_properties' which was removed in r213724 (incorrectly) because at that time, there was no ASM specified in the project() line.

At no point was there a project() line that said that ASM source was present without also overriding the language of all source files. So while adding the ASM into project() was correct, doing both - overriding the language *and* saying that ASM is present - was incorrect. There was a bit of flailing on account of either inability to test all combinations of build and/or misunderstanding of cmake, during which time someone concluded that all the changes were incorrect, and thus the final state was exactly as the beginning state.

I believe that the current patch is actually different and an improvement: it declares that ASM should be compiled with however cmake would normally compile ASM.

rnk accepted this revision.Jul 27 2015, 3:21 PM
rnk edited edge metadata.

Thanks for the explanation, let's commit it and see if it sticks. :)

This revision is now accepted and ready to land.Jul 27 2015, 3:22 PM
compnerd accepted this revision.Jul 27 2015, 7:47 PM
compnerd edited edge metadata.
This revision was automatically updated to reflect the committed changes.