This is an archive of the discontinued LLVM Phabricator instance.

[CMake] NFC. Add support for testing the compiler without testing the linker
ClosedPublic

Authored by beanz on Apr 28 2016, 2:51 PM.

Details

Summary

One of the big limitations we have in the compiler-rt build system today is that we cannot bootstrap building the builtins because you need a fully functional toolchain to pass CMake's tests.

This change adds support for compile only tests.

It is NFC because nothing is using the compile-only tests yet.

I believe this is the last separable part of D16653.

Diff Detail

Event Timeline

beanz updated this revision to Diff 55497.Apr 28 2016, 2:51 PM
beanz retitled this revision from to [CMake] NFC. Add support for testing the compiler without testing the linker.
beanz updated this object.
beanz added a reviewer: samsonov.
beanz added a subscriber: llvm-commits.
compnerd added inline comments.Apr 30 2016, 11:47 AM
cmake/Modules/BuiltinTests.cmake
9

Is there an assumption that we will only use a GNU style driver? What is insufficient about CMAKE_C_COMPILE_OBJECT?

emaste added a subscriber: emaste.May 2 2016, 9:51 AM
beanz added inline comments.May 2 2016, 11:12 AM
cmake/Modules/BuiltinTests.cmake
9

Generally I think that we *should* be able to assume a Unix-conformant driver because if you're building the builtin library and you're not using Clang to do it you're probably doing something wrong.

That statement isn't true for the wider compiler-rt project, but I don't think we should be supporting the builtin libraries on any other toolchains.

That said, writing some CMake goop to construct a compiler command based on CMAKE_C_COMPILE_OBJECT shouldn't be too bad, so I'll do it.

beanz updated this revision to Diff 55896.May 2 2016, 2:11 PM

Use CMAKE_C_COMPILE_OBJECT as the template for the compiler command.

beanz updated this revision to Diff 55902.May 2 2016, 3:28 PM

Fixing a bug relating to stringify-ing and un-stringifying lists... I literally just documented this behavior, I should know better. Also fixed formatting to 80-col.

compnerd accepted this revision.May 2 2016, 7:41 PM
compnerd added a reviewer: compnerd.
This revision is now accepted and ready to land.May 2 2016, 7:41 PM
This revision was automatically updated to reflect the committed changes.
rnk added a subscriber: rnk.Aug 1 2016, 11:45 AM
rnk added inline comments.
compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake
55 ↗(On Diff #56050)

Trusting the return code of the compiler is a bit naive. Upstream cmake tests all of the following messages to find unsupported flags:

macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR)
   set(${_VAR}
     FAIL_REGEX "[Uu]nrecogni[sz]ed .*option"               # GNU, NAG
     FAIL_REGEX "unknown .*option"                          # Clang
     FAIL_REGEX "optimization flag .* not supported"        # Clang
     FAIL_REGEX "unknown argument ignored"                  # Clang (cl)
     FAIL_REGEX "ignoring unknown option"                   # MSVC, Intel
     FAIL_REGEX "warning D9002"                             # MSVC, any lang
     FAIL_REGEX "option.*not supported"                     # Intel
     FAIL_REGEX "invalid argument .*option"                 # Intel
     FAIL_REGEX "ignoring option .*argument required"       # Intel
     FAIL_REGEX "ignoring option .*argument is of wrong type" # Intel
     FAIL_REGEX "[Uu]nknown option"                         # HP
     FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
     FAIL_REGEX "command option .* is not recognized"       # XL
     FAIL_REGEX "command option .* contains an incorrect subargument" # XL
     FAIL_REGEX "not supported in this configuration. ignored"       # AIX
     FAIL_REGEX "File with unknown suffix passed to linker" # PGI
     FAIL_REGEX "[Uu]nknown switch"                         # PGI
     FAIL_REGEX "WARNING: unknown flag:"                    # Open64
     FAIL_REGEX "Incorrect command line option:"            # Borland
     FAIL_REGEX "Warning: illegal option"                   # SunStudio 12
     FAIL_REGEX "[Ww]arning: Invalid suboption"             # Fujitsu
   )
endmacro ()

We don't support most of those compilers, but we do support MSVC, which ignores unknown flags, so we need to do something here.

rnk added inline comments.Aug 1 2016, 11:47 AM
compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake
55 ↗(On Diff #56050)

I bring this up because it means we get warnings on Windows:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/26602/steps/build%20compiler-rt/logs/warnings%20%2832%29
cl : Command line warning D9002 : ignoring unknown option '-std=gnu99'