[compiler-rt] r372312 - [cmake] Strip quotes in try_compile_only

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 04:28:32 PDT 2019


Author: hans
Date: Thu Sep 19 04:28:32 2019
New Revision: 372312

URL: http://llvm.org/viewvc/llvm-project?rev=372312&view=rev
Log:
[cmake] Strip quotes in try_compile_only

After r372209, the compile command can end up including an argument with
quotes in it, e.g.

  -fprofile-instr-use="/foo/bar.profdata"

when invoking the compiler with execute_process, the compiler ends up
getting that argument with quotes and all, and fails to open the file.

This all seems horribly broken, but one way of working around it is to
simply strip the quotes from the string here. If they were there to
protect a path that's got spaces in it, that wasn't going to work
anyway because the string is later split by spaces.

Modified:
    compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake

Modified: compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake?rev=372312&r1=372311&r2=372312&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/BuiltinTests.cmake Thu Sep 19 04:28:32 2019
@@ -72,6 +72,12 @@ function(try_compile_only output)
     endif()
   endforeach()
 
+  # Strip quotes from the compile command, as the compiler is not expecting
+  # quoted arguments (see discussion on D62063 for when this can come up). If
+  # the quotes were there for arugments with spaces in them, the quotes were
+  # not going to help since the string gets split on spaces below.
+  string(REPLACE "\"" "" test_compile_command "${test_compile_command}")
+
   string(REPLACE " " ";" test_compile_command "${test_compile_command}")
 
   execute_process(




More information about the llvm-commits mailing list