Index: lnt/tests/nt.py =================================================================== --- lnt/tests/nt.py +++ lnt/tests/nt.py @@ -132,6 +132,13 @@ # FIXME: Eliminate this blanket option. target_flags.extend(self.cflags) + if self.cflag_string: + import shlex + import pipes + # FIXME: This isn't generally OK on Windows :/ + safely_quoted_on_linux = map(pipes.quote, shlex.split(self.cflag_string)) + target_flags.extend(safely_quoted_on_linux) + # Pass flags to backend. for f in self.mllvm: target_flags.extend(['-mllvm', f]) @@ -1510,6 +1517,10 @@ group.add_option("", "--cflag", dest="cflags", help="Additional flags to set in TARGET_FLAGS", action="append", type=str, default=[], metavar="FLAG") + group.add_option("", "--cflags", dest="cflag_string", + help="Additional flags to set in TARGET_FLAGS, space separated string. " + "These flags are appended after *all* the individual --cflag arguments.", + type=str, default='', metavar="FLAG") group.add_option("", "--mllvm", dest="mllvm", help="Add -mllvm FLAG to TARGET_FLAGS", action="append", type=str, default=[], metavar="FLAG") @@ -1829,6 +1840,8 @@ # test-suite directory, that borks things. prepare_report_dir(config) + note('TARGET_FLAGS: {}'.format(' '.join(config.target_flags))) + # Multisample, if requested. if opts.multisample is not None: # Collect the sample reports. Index: tests/runtest/nt.py =================================================================== --- tests/runtest/nt.py +++ tests/runtest/nt.py @@ -63,3 +63,64 @@ # RUN: --test-suite %S/Inputs/test-suite \ # RUN: --cc %{shared_inputs}/FakeCompilers/clang-r154331 \ # RUN: --no-timestamp --without-llvm > %t.log 2> %t.err + +# Check cflag handling + +## With a lone cflag +# RUN: lnt runtest nt \ +# RUN: --sandbox %t.SANDBOX \ +# RUN: --test-suite %S/Inputs/test-suite \ +# RUN: --cc %{shared_inputs}/FakeCompilers/clang-r154331 \ +# RUN: --cflag '-Wall' \ +# RUN: --no-timestamp > %t.log 2> %t.err +# RUN: FileCheck --check-prefix CHECK-CFLAG1 < %t.err %s +# CHECK-CFLAG1: inferred C++ compiler under test +# CHECK-CFLAG1: TARGET_FLAGS: -Wall + +## With a couple of cflags +# RUN: lnt runtest nt \ +# RUN: --sandbox %t.SANDBOX \ +# RUN: --test-suite %S/Inputs/test-suite \ +# RUN: --cc %{shared_inputs}/FakeCompilers/clang-r154331 \ +# RUN: --cflag '-Wall' \ +# RUN: --cflag '-mfloat-abi=hard' \ +# RUN: --cflag '-O3' \ +# RUN: --no-timestamp > %t.log 2> %t.err +# RUN: FileCheck --check-prefix CHECK-CFLAG2 < %t.err %s +# CHECK-CFLAG2: inferred C++ compiler under test +# CHECK-CFLAG2: TARGET_FLAGS: -Wall -mfloat-abi=hard -O3 + +## With a cflags +# RUN: lnt runtest nt \ +# RUN: --sandbox %t.SANDBOX \ +# RUN: --test-suite %S/Inputs/test-suite \ +# RUN: --cc %{shared_inputs}/FakeCompilers/clang-r154331 \ +# RUN: --cflags '-Wall -mfloat-abi=hard -O3' \ +# RUN: --no-timestamp > %t.log 2> %t.err +# RUN: FileCheck --check-prefix CHECK-CFLAG3 < %t.err %s +# CHECK-CFLAG3: inferred C++ compiler under test +# CHECK-CFLAG3: TARGET_FLAGS: -Wall -mfloat-abi=hard -O3 + +## With a cflags with a quoted space and escaped spaces +# RUN: lnt runtest nt \ +# RUN: --sandbox %t.SANDBOX \ +# RUN: --test-suite %S/Inputs/test-suite \ +# RUN: --cc %{shared_inputs}/FakeCompilers/clang-r154331 \ +# RUN: --cflags "-Wall -test=escaped\ space -some-option='stay with me' -O3" \ +# RUN: --no-timestamp > %t.log 2> %t.err +# RUN: FileCheck --check-prefix CHECK-CFLAG4 < %t.err %s +# CHECK-CFLAG4: inferred C++ compiler under test +# CHECK-CFLAG4: TARGET_FLAGS: -Wall '-test=escaped space' '-some-option=stay with me' -O3 + +## With cflag and cflags +# RUN: lnt runtest nt \ +# RUN: --sandbox %t.SANDBOX \ +# RUN: --test-suite %S/Inputs/test-suite \ +# RUN: --cc %{shared_inputs}/FakeCompilers/clang-r154331 \ +# RUN: --cflag '--target=armv7a-none-eabi' \ +# RUN: --cflag '-Weverything' \ +# RUN: --cflags '-Wall -test=escaped\ space -some-option="stay with me" -O3' \ +# RUN: --no-timestamp > %t.log 2> %t.err +# RUN: FileCheck --check-prefix CHECK-CFLAG5 < %t.err %s +# CHECK-CFLAG5: inferred C++ compiler under test +# CHECK-CFLAG5: TARGET_FLAGS: --target=armv7a-none-eabi -Weverything -Wall '-test=escaped space' '-some-option=stay with me' -O3