Page MenuHomePhabricator

[libcxx] Update the way the -std= flag is chosen by CMake and LibcxxTestFormat
ClosedPublic

Authored by EricWF on Jun 27 2014, 12:42 PM.

Details

Summary

This patch does two things:
CMake Update:

  • Add compiler flag checks for -std=c++11 and -std=c++1y and remove check for -std=c++0x.
  • Add configuration option LIBCXX_ENABLE_CXX1Y to prevent/allow -std=c++1y from being chosen as the std version. LIBCXX_ENABLE_CXX1Y is set to OFF by default.
  • if LIBCXX_ENABLE_CXX1Y is enabled then set LIBCXX_STD_VERSION to c++1y and fail if the compiler does not support -std=c++1y
  • If c++1y is not enabled then use c++11 and fail if the compiler does not support c++11.

Lit Update:

  • Update lit.site.cfg.in to capture LIBCXX_STD_VERSION information as config.std.
  • Remove mentions of has_cxx0X configuration option.
  • Check for `--param std=X' passed to lit on the command line.
  • Choose the std for the tests either from command line parameter or (if it doesn't exist) the lit.site.cfg.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 10943.Jun 27 2014, 12:42 PM
EricWF retitled this revision from to [libcxx] Update the way the -std= flag is chosen by CMake and LibcxxTestFormat.
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added a reviewer: mclow.lists.
EricWF set the repository for this revision to rL LLVM.
EricWF added inline comments.Jun 27 2014, 12:47 PM
CMakeLists.txt
46

Should this be on by default?

test/lit.cfg
210

I am going to change this to omit the version flag as opposed to defaulting to c++0x. If the version flag was empty then no suitable version flag was found by CMake.

EricWF updated this object.Jun 27 2014, 12:51 PM
EricWF added a subscriber: Unknown Object (MLST).
EricWF updated this revision to Diff 10945.Jun 27 2014, 2:46 PM
EricWF updated this object.

Added the ability for the user to override the -std=<version> flag used by lit on the command line by passing --param std=<version>.

danalbert added inline comments.
CMakeLists.txt
193

Should the else case be an error? Can libc++ be compiled with less than c++0x?

EricWF updated this revision to Diff 10948.Jun 27 2014, 3:36 PM

Add error message during configuration if the CMakeLists.txt cannot find standards version >= c++0x.

I also fixed misnamed flag options.

mclow.lists edited edge metadata.Jun 30 2014, 11:19 AM

I would prefer to just drop the whole "c++0x" case. That was a placeholder until c++11 was approved; which happened three years ago.

I'm pretty sure that the LLVM build system just uses "-std=c++11" to build clang.

EricWF updated this revision to Diff 10982.Jun 30 2014, 1:02 PM
EricWF updated this object.
EricWF edited edge metadata.

I've dropped support for C++0x.

This patch is somewhat related to this bug. If this patch is merged the CMake build system will require that libc++ be built with c++11 or greater.
http://llvm.org/bugs/show_bug.cgi?id=13081

I'm fine with dropping the ability to build libc++ with a C++03 compiler.
[ I'm *not* fine with dropping the ability to use libc++ from c++03 code ]

Responsible opposing viewpoints... ?

rnk added a subscriber: ajwong.Jun 30 2014, 3:22 PM
rnk added a subscriber: rnk.

I'm fine with dropping the ability to build libc++ with a C++03 compiler.
[ I'm *not* fine with dropping the ability to use libc++ from c++03 code ]

Responsible opposing viewpoints... ?

Albert, is the Android NDK version of GCC new enough?

In D4329#19, @rnk wrote:

I'm fine with dropping the ability to build libc++ with a C++03 compiler.
[ I'm *not* fine with dropping the ability to use libc++ from c++03 code ]

Responsible opposing viewpoints... ?

Albert, is the Android NDK version of GCC new enough?

NDK has both gcc-4.6 and gcc-4.8. I think we only expect libc++ to work with gcc-4.8 so we're probably okay. Let me verify with Andrew Hseih, head of android NDK. He's in Taiwan though so it'll be a few hours before he responds.

In D4329#22, @ajwong wrote:
In D4329#19, @rnk wrote:

I'm fine with dropping the ability to build libc++ with a C++03 compiler.
[ I'm *not* fine with dropping the ability to use libc++ from c++03 code ]

Responsible opposing viewpoints... ?

Albert, is the Android NDK version of GCC new enough?

NDK has both gcc-4.6 and gcc-4.8. I think we only expect libc++ to work with gcc-4.8 so we're probably okay. Let me verify with Andrew Hseih, head of android NDK. He's in Taiwan though so it'll be a few hours before he responds.

Verified that we're only supporting gcc >= 4.8. Android NDK should be fine. :)

I don't think libc++ currently builds in C++03 mode anyway. I've tried building it with GCC 4.8 and Clang 3.4 with no version flag and both compilers fail to build future.cpp, hash.cpp and shared_mutex.cpp.

EricWF updated this revision to Diff 11218.Jul 9 2014, 4:58 PM
EricWF updated this object.

Change the default value for LIBCXX_ENABLE_CXX1Y to OFF instead of ON. GCC does not support the relaxed constexpr rules to compile libc++ as C++1y.

(Also a gentle ping)

This looks fine to me, and builds w/o any problems on my (Mac OSX) system.

Any outstanding corrections or suggestions?

EricWF updated this revision to Diff 12339.Aug 10 2014, 4:42 PM
EricWF updated this object.
EricWF added a reviewer: danalbert.

Rework patch and update patch summary.

EricWF updated this revision to Diff 12340.Aug 10 2014, 4:50 PM

Remove dead code in test/CMakeLists.txt

danalbert added inline comments.Aug 14 2014, 9:08 PM
CMakeLists.txt
197

I think the case of LIBCXX_ENABLE_CXX1Y && !LIBCXX_HAS_STDCXX1Y_FLAG should raise an error, not fall back to C++11.

test/lit.cfg
311

It wouldn't be inferred, since it was defined by the user. I also don't think we need to be asserting on the line above. If std isn't defined either from the command line or from lit.site.cfg, we should probably just not pass any -std flag to the compiler and let it do the default. Might add a lit_config.note() stating that this is happening in that case.

Thanks for the notes! I'll update the way lit.cfg handles the std parameter.

CMakeLists.txt
197

If that were to be the case then we should turn LIBCXX_ENABLE_CXX1Y off by default. There is no need for CMake to fail because it can't find a c++1y flag since libc++ builds as c++11.

Selfishly I want the c++1y to be enabled by default because I'm doing a lot of work on the LFTS that requires c++1y and I don't want to specify it to run the tests.

test/lit.cfg
311

I'm not sure if we should fall back to default. The majority of the test-suite does not build unless its tested with >=c++11. I think we should instead fall back to c++11.

EricWF updated this revision to Diff 12541.Aug 14 2014, 10:03 PM

Implement Dans suggestion for finding the std flag in lit.cfg

danalbert added inline comments.Aug 15 2014, 8:10 AM
CMakeLists.txt
197

We'll have to make that not the default for the time being then. Having cmake lie isn't an option. We might know about this non-intuitive behavior, but most people aren't going to read the cmake files and would just assume it worked. We shouldn't do a warning or other message either. There usually isn't a reason to look at the cmake output unless it fails.

test/lit.cfg
301

Yeah, this is fine. C++11 is probably a safe default these days.

emaste added a subscriber: emaste.Aug 15 2014, 9:01 AM
EricWF updated this revision to Diff 12576.Aug 15 2014, 4:39 PM

Implement Dan's comments regarding the c++1y flag. It is now off by default. If it is enabled CMake will fail instead of falling back on c++11. If the c++1y flag is off then c++11 will be selected. If the compiler does not support c++11 CMake will fail.

danalbert accepted this revision.Aug 15 2014, 5:00 PM
danalbert edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Aug 15 2014, 5:00 PM
EricWF updated this object.Aug 15 2014, 5:25 PM
EricWF edited edge metadata.
EricWF closed this revision.Aug 15 2014, 5:26 PM