[compiler-rt] Allow appending to 'target_cflags' value from lit_config.
authorHafiz Abid Qadeer <abidh@codesourcery.com>
Tue, 8 Dec 2020 11:46:36 +0000 (11:46 +0000)
committerHafiz Abid Qadeer <abidh@codesourcery.com>
Tue, 8 Dec 2020 11:46:36 +0000 (11:46 +0000)
This patch is similar to D84708. When testing compiler-rt on different
baremetal targets, it helps to have the ability to pass some more parameters
at test time that allows you to build the test executable for a
given target. For an example, you may need a different linker command
file for different targets.

This patch will allows to do things like

$ llvm-lit --param=append_target_cflags="-T simulator.ld"
or
$ llvm-lit --param=append_target_cflags="-T hardware.ld"

In this way, you can run tests on different targets without having to run
cmake again.

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D91783

compiler-rt/test/lit.common.cfg.py

index 889e293..e2de463 100644 (file)
@@ -582,5 +582,11 @@ if config.use_lld and config.has_lld and not config.use_lto:
 elif config.use_lld and (not config.has_lld):
   config.unsupported = True
 
+# Append any extra flags passed in lit_config
+append_target_cflags = lit_config.params.get('append_target_cflags', None)
+if append_target_cflags:
+  lit_config.note('Appending to extra_cflags: "{}"'.format(append_target_cflags))
+  extra_cflags += [append_target_cflags]
+
 config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, config.clang]) + " "
 config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "