jansvoboda11 updated this revision to Diff 416576. jansvoboda11 added a comment.
Avoid buggy driver behavior Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D121997/new/ https://reviews.llvm.org/D121997 Files: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/compilation_database_multiarch.c Index: clang/test/Driver/compilation_database_multiarch.c =================================================================== --- /dev/null +++ clang/test/Driver/compilation_database_multiarch.c @@ -0,0 +1,6 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: %clang -c %s -o %t/out -target x86_64-apple-macos -arch arm64 -arch x86_64 -MJ %t/compilation_database.json +// RUN: FileCheck --input-file=%t/compilation_database.json %s + +// CHECK: { "directory": "{{.*}}", "file": "{{.*}}", "output": "{{.*}}", "arguments": [{{.*}} "--target=arm64-apple-macosx12.0.0"]}, +// CHECK-NEXT: { "directory": "{{.*}}", "file": "{{.*}}", "output": "{{.*}}", "arguments": [{{.*}} "--target=x86_64-apple-macosx12.0.0"]}, Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2382,7 +2382,8 @@ if (!CompilationDatabase) { std::error_code EC; auto File = std::make_unique<llvm::raw_fd_ostream>( - Filename, EC, llvm::sys::fs::OF_TextWithCRLF); + Filename, EC, + llvm::sys::fs::OF_TextWithCRLF | llvm::sys::fs::OF_Append); if (EC) { D.Diag(clang::diag::err_drv_compilationdatabase) << Filename << EC.message();
Index: clang/test/Driver/compilation_database_multiarch.c =================================================================== --- /dev/null +++ clang/test/Driver/compilation_database_multiarch.c @@ -0,0 +1,6 @@ +// RUN: rm -rf %t && mkdir -p %t +// RUN: %clang -c %s -o %t/out -target x86_64-apple-macos -arch arm64 -arch x86_64 -MJ %t/compilation_database.json +// RUN: FileCheck --input-file=%t/compilation_database.json %s + +// CHECK: { "directory": "{{.*}}", "file": "{{.*}}", "output": "{{.*}}", "arguments": [{{.*}} "--target=arm64-apple-macosx12.0.0"]}, +// CHECK-NEXT: { "directory": "{{.*}}", "file": "{{.*}}", "output": "{{.*}}", "arguments": [{{.*}} "--target=x86_64-apple-macosx12.0.0"]}, Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -2382,7 +2382,8 @@ if (!CompilationDatabase) { std::error_code EC; auto File = std::make_unique<llvm::raw_fd_ostream>( - Filename, EC, llvm::sys::fs::OF_TextWithCRLF); + Filename, EC, + llvm::sys::fs::OF_TextWithCRLF | llvm::sys::fs::OF_Append); if (EC) { D.Diag(clang::diag::err_drv_compilationdatabase) << Filename << EC.message();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits