Index: llvm/test/tools/llvm-ar/response-utf8.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-ar/response-utf8.test @@ -0,0 +1,8 @@ +## Check that response files can cope with non-ascii characters. + +# RUN: llvm-ar r %t.a %s + +# RUN: echo "r %t-£.a %s" > %t-non-ascii.txt +# RUN: llvm-ar @%t-non-ascii.txt +## Work-around diff not working with non-ascii filenames on windows. +RUN: env LANG=en_US.UTF-8 %python -c "assert open(ur'%t-\U000000A3.a', 'rb').read() == open(r'%t.a', 'rb').read()" Index: llvm/test/tools/llvm-ar/response.test =================================================================== --- /dev/null +++ llvm/test/tools/llvm-ar/response.test @@ -0,0 +1,20 @@ +## llvm-ar should be able to consume response files. + +# RUN: echo contents > %t.txt +# RUN: echo rc %t1.a %t.txt > %t.response1.txt +# RUN: llvm-ar @%t.response1.txt +# RUN: llvm-ar p %t1.a | FileCheck %s + +## Quotes and Spaces. +# RUN: echo contents > "%t space.txt" +## Python is used here to ensure the quotes are written to the response file +# RUN: %python -c "import os; open(r'%t.response2.txt', 'wb').write(r'%t2.a \"%t space.txt\"'+ '\n')" +# RUN: llvm-ar rc @%t.response2.txt +# RUN: llvm-ar p %t2.a | FileCheck %s + +## Arguments after the response file. +# RUN: echo rc %t3.a > %t.response3.txt +# RUN: llvm-ar @%t.response3.txt %t.txt +# RUN: llvm-ar p %t3.a | FileCheck %s + +CHECK: contents Index: llvm/tools/llvm-ar/llvm-ar.cpp =================================================================== --- llvm/tools/llvm-ar/llvm-ar.cpp +++ llvm/tools/llvm-ar/llvm-ar.cpp @@ -1089,7 +1089,11 @@ static int ar_main(int argc, char **argv) { SmallVector Argv(argv, argv + argc); StringSaver Saver(Alloc); - cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv); + cl::ExpandResponseFiles(Saver, + Triple(sys::getProcessTriple()).isOSWindows() + ? cl::TokenizeWindowsCommandLine + : cl::TokenizeGNUCommandLine, + Argv); for (size_t i = 1; i < Argv.size(); ++i) { StringRef Arg = Argv[i]; const char *match;