diff --git a/modules/gmake/tests/cpp/test_clang.lua b/modules/gmake/tests/cpp/test_clang.lua index f8cb1e0dbf..2e60290563 100644 --- a/modules/gmake/tests/cpp/test_clang.lua +++ b/modules/gmake/tests/cpp/test_clang.lua @@ -44,3 +44,20 @@ ifeq ($(config),debug) ]] end + function suite.usesCorrectCompilersAndLinkTimeOptimization() + flags { "LinkTimeOptimization" } + make.cppConfigs(prj) + test.capture [[ +ifeq ($(config),debug) + ifeq ($(origin CC), default) + CC = clang + endif + ifeq ($(origin CXX), default) + CXX = clang++ + endif + ifeq ($(origin AR), default) + AR = llvm-ar + endif + ]] + end + diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 7460a0a192..1da61dfbb0 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -324,9 +324,13 @@ clang.tools = { cc = "clang", cxx = "clang++", - ar = "ar" + ar = function(cfg) return iif(cfg.flags.LinkTimeOptimization, "llvm-ar", "ar") end } function clang.gettoolname(cfg, tool) - return clang.tools[tool] + local value = clang.tools[tool] + if type(value) == "function" then + value = value(cfg) + end + return value end