diff options
Diffstat (limited to 'tools/driver')
| -rw-r--r-- | tools/driver/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tools/driver/cc1_main.cpp | 7 | ||||
| -rw-r--r-- | tools/driver/cc1as_main.cpp | 26 | ||||
| -rw-r--r-- | tools/driver/cc1gen_reproducer_main.cpp | 2 | ||||
| -rw-r--r-- | tools/driver/driver.cpp | 6 |
5 files changed, 34 insertions, 8 deletions
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt index 15b0519e4111..89a3aa3ced85 100644 --- a/tools/driver/CMakeLists.txt +++ b/tools/driver/CMakeLists.txt @@ -46,6 +46,7 @@ target_link_libraries(clang clangDriver clangFrontend clangFrontendTool + clangSerialization ) if(WIN32 AND NOT CYGWIN) diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index ef5a191bda0a..7d21c6a671d2 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -13,10 +13,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Option/Arg.h" +#include "clang/Basic/Stack.h" #include "clang/CodeGen/ObjectFilePCHContainerOperations.h" #include "clang/Config/config.h" -#include "clang/Basic/Stack.h" #include "clang/Driver/DriverDiagnostic.h" #include "clang/Driver/Options.h" #include "clang/Frontend/CompilerInstance.h" @@ -29,8 +28,10 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Config/llvm-config.h" #include "llvm/LinkAllPasses.h" +#include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Option/OptTable.h" +#include "llvm/Support/BuryPointer.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" @@ -228,7 +229,7 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { // When running with -disable-free, don't do any destruction or shutdown. if (Clang->getFrontendOpts().DisableFree) { - BuryPointer(std::move(Clang)); + llvm::BuryPointer(std::move(Clang)); return !Success; } diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp index 09db014019bf..be4f174ed412 100644 --- a/tools/driver/cc1as_main.cpp +++ b/tools/driver/cc1as_main.cpp @@ -33,6 +33,7 @@ #include "llvm/MC/MCParser/MCAsmParser.h" #include "llvm/MC/MCParser/MCTargetAsmParser.h" #include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCTargetOptions.h" @@ -132,6 +133,7 @@ struct AssemblerInvocation { unsigned NoExecStack : 1; unsigned FatalWarnings : 1; unsigned IncrementalLinkerCompatible : 1; + unsigned EmbedBitcode : 1; /// The name of the relocation model to use. std::string RelocationModel; @@ -153,6 +155,7 @@ public: FatalWarnings = 0; IncrementalLinkerCompatible = 0; DwarfVersion = 0; + EmbedBitcode = 0; } static bool CreateFromArgs(AssemblerInvocation &Res, @@ -284,6 +287,16 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, Args.hasArg(OPT_mincremental_linker_compatible); Opts.SymbolDefs = Args.getAllArgValues(OPT_defsym); + // EmbedBitcode Option. If -fembed-bitcode is enabled, set the flag. + // EmbedBitcode behaves the same for all embed options for assembly files. + if (auto *A = Args.getLastArg(OPT_fembed_bitcode_EQ)) { + Opts.EmbedBitcode = llvm::StringSwitch<unsigned>(A->getValue()) + .Case("all", 1) + .Case("bitcode", 1) + .Case("marker", 1) + .Default(0); + } + return Success; } @@ -449,6 +462,16 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts, Str.get()->InitSections(Opts.NoExecStack); } + // When -fembed-bitcode is passed to clang_as, a 1-byte marker + // is emitted in __LLVM,__asm section if the object file is MachO format. + if (Opts.EmbedBitcode && Ctx.getObjectFileInfo()->getObjectFileType() == + MCObjectFileInfo::IsMachO) { + MCSection *AsmLabel = Ctx.getMachOSection( + "__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly()); + Str.get()->SwitchSection(AsmLabel); + Str.get()->EmitZeros(1); + } + // Assembly to object compilation should leverage assembly info. Str->setUseAssemblerInfoForParsing(true); @@ -534,7 +557,8 @@ int cc1as_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) { if (Asm.ShowHelp) { std::unique_ptr<OptTable> Opts(driver::createDriverOptTable()); - Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler", + Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...", + "Clang Integrated Assembler", /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0, /*ShowAllAliases=*/false); return 0; diff --git a/tools/driver/cc1gen_reproducer_main.cpp b/tools/driver/cc1gen_reproducer_main.cpp index a4c034d8d357..2d7ea86f7486 100644 --- a/tools/driver/cc1gen_reproducer_main.cpp +++ b/tools/driver/cc1gen_reproducer_main.cpp @@ -14,13 +14,13 @@ #include "clang/Basic/Diagnostic.h" #include "clang/Basic/LLVM.h" -#include "clang/Basic/VirtualFileSystem.h" #include "clang/Driver/Compilation.h" #include "clang/Driver/Driver.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" diff --git a/tools/driver/driver.cpp b/tools/driver/driver.cpp index 0455ba029c65..51143e3d8cb7 100644 --- a/tools/driver/driver.cpp +++ b/tools/driver/driver.cpp @@ -260,9 +260,9 @@ static void FixupDiagPrefixExeName(TextDiagnosticPrinter *DiagClient, const std::string &Path) { // If the clang binary happens to be named cl.exe for compatibility reasons, // use clang-cl.exe as the prefix to avoid confusion between clang and MSVC. - StringRef ExeBasename(llvm::sys::path::filename(Path)); - if (ExeBasename.equals_lower("cl.exe")) - ExeBasename = "clang-cl.exe"; + StringRef ExeBasename(llvm::sys::path::stem(Path)); + if (ExeBasename.equals_lower("cl")) + ExeBasename = "clang-cl"; DiagClient->setPrefix(ExeBasename); } |
