[LNT] r302232 - Empty CMAKE_C_FLAGS_{build_type} when setting flags manually.

Kristof Beyls via llvm-commits llvm-commits at lists.llvm.org
Fri May 5 06:26:04 PDT 2017


Author: kbeyls
Date: Fri May  5 08:26:03 2017
New Revision: 302232

URL: http://llvm.org/viewvc/llvm-project?rev=302232&view=rev
Log:
Empty CMAKE_C_FLAGS_{build_type} when setting flags manually.

This is for lnt runtest test-suite.
When requesting specific compiler flags, users probably don't want
whatever the cmake defaults are for a particular build type to be
injected too into the build command line.
For example, 'lnt runtest test-suite --cppflags="-O0 -g"', would still
build the test-suite at -O3, since the test-suite sets CMAKE_BUILD_TYPE to
RELEASE by default, which appends flags "-O3 -DNDEBUG" after "-O0 -g" on the
command line (at least on my linux setup).
To make sure that doesn't happen, clear the default build flags for
all cmake build types, when the user requested specific build flags.


Modified:
    lnt/trunk/lnt/tests/test_suite.py
    lnt/trunk/tests/runtest/test_suite.py

Modified: lnt/trunk/lnt/tests/test_suite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/test_suite.py?rev=302232&r1=302231&r2=302232&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/test_suite.py (original)
+++ lnt/trunk/lnt/tests/test_suite.py Fri May  5 08:26:03 2017
@@ -603,13 +603,22 @@ class TestSuiteTest(BuiltinTest):
         if self.opts.cxx:
             defs['CMAKE_CXX_COMPILER'] = self.opts.cxx
 
+        cmake_build_types = ('DEBUG','MINSIZEREL', 'RELEASE', 'RELWITHDEBINFO')
         if self.opts.cppflags or self.opts.cflags:
             all_cflags = ' '.join([self.opts.cppflags, self.opts.cflags])
             defs['CMAKE_C_FLAGS'] = self._unix_quote_args(all_cflags)
+            # Ensure that no flags get added based on build type when the user
+            # explicitly specifies flags to use.
+            for build_type in cmake_build_types:
+                defs['CMAKE_C_FLAGS_'+build_type] = ""
 
         if self.opts.cppflags or self.opts.cxxflags:
             all_cxx_flags = ' '.join([self.opts.cppflags, self.opts.cxxflags])
             defs['CMAKE_CXX_FLAGS'] = self._unix_quote_args(all_cxx_flags)
+            # Ensure that no flags get added based on build type when the user
+            # explicitly specifies flags to use.
+            for build_type in cmake_build_types:
+                defs['CMAKE_CXX_FLAGS_'+build_type] = ""
 
         if self.opts.run_under:
             defs['TEST_SUITE_RUN_UNDER'] = self._unix_quote_args(self.opts.run_under)

Modified: lnt/trunk/tests/runtest/test_suite.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/runtest/test_suite.py?rev=302232&r1=302231&r2=302232&view=diff
==============================================================================
--- lnt/trunk/tests/runtest/test_suite.py (original)
+++ lnt/trunk/tests/runtest/test_suite.py Fri May  5 08:26:03 2017
@@ -121,6 +121,12 @@
 # RUN: FileCheck --check-prefix CHECK-CFLAG1 < %t.err %s
 # CHECK-CFLAG1: Inferred C++ compiler under test
 # CHECK-CFLAG1: CMAKE_C_FLAGS: '-Wall
+# Ensure that default c flags for build configurations are made empty to avoid
+# surprises:
+# CHECK-CFLAG1: CMAKE_C_FLAGS_DEBUG: ''
+# CHECK-CFLAG1: CMAKE_C_FLAGS_MINSIZEREL: ''
+# CHECK-CFLAG1: CMAKE_C_FLAGS_RELEASE: ''
+# CHECK-CFLAG1: CMAKE_C_FLAGS_RELWITHDEBINFO: ''
 
 ## With a couple of cflags
 # RUN: lnt runtest test-suite \




More information about the llvm-commits mailing list