Flags<[DriverOption]>;
def fembed_bitcode_EQ : Joined<["-"], "fembed-bitcode=">,
- Group<f_Group>, Flags<[DriverOption, CC1Option]>, MetaVarName<"<option>">,
+ Group<f_Group>, Flags<[DriverOption, CC1Option, CC1AsOption]>, MetaVarName<"<option>">,
HelpText<"Embed LLVM bitcode (option: off, all, bitcode, marker)">;
def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group<f_Group>,
Alias<fembed_bitcode_EQ>, AliasArgs<["all"]>,
CmdArgs.push_back("-target-feature");
CmdArgs.push_back(MipsTargetFeature);
}
+
+ // forward -fembed-bitcode to assmebler
+ if (C.getDriver().embedBitcodeEnabled() ||
+ C.getDriver().embedBitcodeMarkerOnly())
+ Args.AddLastArg(CmdArgs, options::OPT_fembed_bitcode_EQ);
}
static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
--- /dev/null
+// REQUIRES: arm-registered-target
+
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode -### 2>&1 | FileCheck %s -check-prefix=CHECK-AS
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode-marker -### 2>&1 | FileCheck %s -check-prefix=CHECK-AS-MARKER
+// CHECK-AS: -cc1as
+// CHECK-AS: -fembed-bitcode=all
+// CHECK-AS-MARKER: -fembed-bitcode=marker
+
+// RUN: %clang -c -target armv7-apple-ios10 %s -fembed-bitcode -o %t.o
+// RUN: llvm-readobj -section-headers %t.o | FileCheck --check-prefix=CHECK-SECTION %s
+// CHECK-SECTION: Name: __asm
+// CHECK-SECTION-NEXT: Segment: __LLVM
#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"
unsigned NoExecStack : 1;
unsigned FatalWarnings : 1;
unsigned IncrementalLinkerCompatible : 1;
+ unsigned EmbedBitcode : 1;
/// The name of the relocation model to use.
std::string RelocationModel;
FatalWarnings = 0;
IncrementalLinkerCompatible = 0;
DwarfVersion = 0;
+ EmbedBitcode = 0;
}
static bool CreateFromArgs(AssemblerInvocation &Res,
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;
}
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);