diff --git a/.gitignore b/.gitignore index b33fbbf932379..a17ab39ba1c27 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,12 @@ # as most of those are useless. #==============================================================================# +# Tool Runtime Dir +.dotnet + +# Build results +artifacts + #==============================================================================# # File extensions to be ignored anywhere in the tree. #==============================================================================# diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index c11f56f2e2a8e..149fa0ebc9a7c 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -3,17 +3,17 @@ - + https://github.com/dotnet/arcade - 14df52bae2c74fc850a8c40fe68ea5be5cd30116 + 87531ff8de2e6501ff85973c9af44953a2c5b687 - + https://github.com/dotnet/arcade - 14df52bae2c74fc850a8c40fe68ea5be5cd30116 + 87531ff8de2e6501ff85973c9af44953a2c5b687 - + https://github.com/dotnet/arcade - 14df52bae2c74fc850a8c40fe68ea5be5cd30116 + 87531ff8de2e6501ff85973c9af44953a2c5b687 diff --git a/eng/Versions.props b/eng/Versions.props index d16d97bef4b7e..5a8d4b1622f12 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -6,6 +6,6 @@ 1 - 7.0.0-beta.22426.8 + 8.0.0-beta.22452.1 diff --git a/eng/azure-pipelines.yml b/eng/azure-pipelines.yml index d406d672631d4..554fe6ab15373 100644 --- a/eng/azure-pipelines.yml +++ b/eng/azure-pipelines.yml @@ -158,7 +158,7 @@ stages: archflag: --arch arm64 LLVMTableGenArg: /p:LLVMTableGenPath=$(Build.SourcesDirectory)/artifacts/obj/BuildRoot-x64/bin/llvm-tblgen pool: - vmImage: macOS-10.15 + vmImage: macos-11 steps: - bash: | set -ex diff --git a/global.json b/global.json index 01e43a7b20634..9a426a21b0c31 100644 --- a/global.json +++ b/global.json @@ -3,8 +3,8 @@ "dotnet": "7.0.100-preview.7.22377.5" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22426.8", - "Microsoft.DotNet.Helix.Sdk": "7.0.0-beta.22426.8", + "Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.22452.1", + "Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.22452.1", "Microsoft.Build.Traversal": "2.0.34" } } diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp index 362d5df76017b..200431a34cdef 100644 --- a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.cpp @@ -38,6 +38,10 @@ void Dump(MCObjectStreamer *Streamer, uint16_t DwarfVersion, unsigned TargetPoin dwarf::DW_TAG_compile_unit, dwarf::DW_CHILDREN_yes, dwarf::DW_AT_producer, dwarf::DW_FORM_string, dwarf::DW_AT_language, dwarf::DW_FORM_data2, + dwarf::DW_AT_name, dwarf::DW_FORM_string, + dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string, + dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, + dwarf::DW_AT_high_pc, DW_FORM_size, dwarf::DW_AT_stmt_list, (DwarfVersion >= 4 ? dwarf::DW_FORM_sec_offset : dwarf::DW_FORM_data4), 0, 0, @@ -125,6 +129,17 @@ void Dump(MCObjectStreamer *Streamer, uint16_t DwarfVersion, unsigned TargetPoin dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, 0, 0, + SubprogramStaticNoChildrenSpec, + dwarf::DW_TAG_subprogram, dwarf::DW_CHILDREN_no, + dwarf::DW_AT_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_linkage_name, dwarf::DW_FORM_strp, + dwarf::DW_AT_decl_file, dwarf::DW_FORM_data1, + dwarf::DW_AT_decl_line, dwarf::DW_FORM_data1, + dwarf::DW_AT_type, dwarf::DW_FORM_ref4, + dwarf::DW_AT_external, dwarf::DW_FORM_flag_present, + dwarf::DW_AT_declaration, dwarf::DW_FORM_flag_present, + 0, 0, + Variable, dwarf::DW_TAG_variable, dwarf::DW_CHILDREN_no, dwarf::DW_AT_name, dwarf::DW_FORM_strp, diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h index 3cd8cea23772c..1a79930824c15 100644 --- a/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfAbbrev.h @@ -30,6 +30,7 @@ enum DwarfAbbrev : uint16_t SubprogramStatic, SubprogramSpec, SubprogramStaticSpec, + SubprogramStaticNoChildrenSpec, Variable, VariableLoc, VariableStatic, diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp index b2ad3f4bd3d56..555bb2ccb8a43 100644 --- a/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfGen.cpp @@ -816,7 +816,7 @@ void SubprogramInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTy EmitInfoOffset(Streamer, MethodTypeInfo, 4); // DW_AT_low_pc - MCSymbol *Sym = context.getOrCreateSymbol(Twine(Name)); + MCSymbol *Sym = context.lookupSymbol(Twine(Name)); const MCExpr *SymExpr = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, context); Streamer->emitValue(SymExpr, TargetPointerSize); @@ -907,6 +907,7 @@ void DwarfGen::SetTypeBuilder(UserDefinedDwarfTypesBuilder *TypeBuilder) { void DwarfGen::EmitCompileUnit() { MCContext &context = Streamer->getContext(); + unsigned TargetPointerSize = context.getAsmInfo()->getCodePointerSize(); MCSymbol *LineSectionSymbol = nullptr; MCSymbol *AbbrevSectionSymbol = nullptr; @@ -966,6 +967,31 @@ void DwarfGen::EmitCompileUnit() { Streamer->emitIntValue(dwarf::DW_LANG_C_plus_plus, 2); #endif + // We need to generate DW_AT_name and DW_AT_compdir to get Apple's ld64 to correctly + // generate debug map in final executable. If we don't generate it then the linker + // will skip over the object file. + // Ref: https://github.com/apple-oss-distributions/ld64/blob/dbf8f7feb5579761f1623b004bd468bdea7c6225/src/ld/OutputFile.cpp#L7166 + + // DW_AT_name + Streamer->emitBytes(StringRef("IL.c")); + Streamer->emitIntValue(0, 1); + + // DW_AT_compdir + Streamer->emitBytes(StringRef("/tmp")); + Streamer->emitIntValue(0, 1); + + // There need to be global DW_AT_low_pc/DW_AT_high_pc symbols to indicate the base and + // size of the range covered by the symbols. Currently we use a shortcut where we emit + // a range starting at the beginning of file and ending at the start of the debug section + // which is located at the end of the object file. + + // DW_AT_low_pc + Streamer->emitIntValue(0, TargetPointerSize); + + // DW_AT_high_pc + const MCExpr *SymExpr = MCSymbolRefExpr::create(debugSection->getBeginSymbol(), MCSymbolRefExpr::VK_None, context); + Streamer->emitValue(SymExpr, TargetPointerSize); + // DW_AT_stmt_list if (LineSectionSymbol == nullptr) { Streamer->emitIntValue(0, 4); diff --git a/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp index 6d663e0512884..f124d239a06f5 100644 --- a/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp +++ b/llvm/tools/objwriter/debugInfo/dwarf/dwarfTypeBuilder.cpp @@ -601,8 +601,12 @@ void DwarfMemberFunctionIdTypeInfo::DumpStrings(MCObjectStreamer *Streamer) { void DwarfMemberFunctionIdTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, UserDefinedDwarfTypesBuilder *TypeBuilder) { // Abbrev Number bool IsStatic = MemberFunctionTypeInfo->IsStatic(); + bool HasParameters = MemberFunctionTypeInfo->GetArgTypes().size(); - Streamer->emitULEB128IntValue(IsStatic ? DwarfAbbrev::SubprogramStaticSpec : DwarfAbbrev::SubprogramSpec); + Streamer->emitULEB128IntValue( + IsStatic ? (HasParameters ? DwarfAbbrev::SubprogramStaticSpec + : DwarfAbbrev::SubprogramStaticNoChildrenSpec) + : DwarfAbbrev::SubprogramSpec); // DW_AT_name EmitSectionOffset(Streamer, StrSymbol, 4); @@ -652,8 +656,10 @@ void DwarfMemberFunctionIdTypeInfo::DumpTypeInfo(MCObjectStreamer *Streamer, Use EmitInfoOffset(Streamer, ArgTypeInfo, 4); } - // Ternimate DIE - Streamer->emitIntValue(0, 1); + // Terminate DIE (skip for SubprogramStaticNoChildrenSpec which has no children) + if (!IsStatic || HasParameters) { + Streamer->emitIntValue(0, 1); + } } // DwarfTypesBuilder diff --git a/llvm/tools/objwriter/objwriter.cpp b/llvm/tools/objwriter/objwriter.cpp index 3fe42df9b7a3b..34653027a1cb2 100644 --- a/llvm/tools/objwriter/objwriter.cpp +++ b/llvm/tools/objwriter/objwriter.cpp @@ -152,10 +152,8 @@ bool ObjectWriter::Init(llvm::StringRef ObjectFilePath, const char* tripleName) unsigned TargetPointerSize = Streamer->getContext().getAsmInfo()->getCodePointerSize(); TypeBuilder->SetTargetPointerSize(TargetPointerSize); - if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsELF) { - DwarfGenerator.reset(new DwarfGen()); - DwarfGenerator->SetTypeBuilder(static_cast(TypeBuilder.get())); - } + DwarfGenerator.reset(new DwarfGen()); + DwarfGenerator->SetTypeBuilder(static_cast(TypeBuilder.get())); CFIsPerOffset.set_size(0); @@ -207,7 +205,7 @@ void ObjectWriter::SwitchSection(const char *SectionName, assert(!Section->getBeginSymbol()); // Output a DWARF linker-local symbol. // This symbol is used as a base for other symbols in a section. - MCSymbol *SectionStartSym = OutContext->createTempSymbol(); + MCSymbol *SectionStartSym = OutContext->createLinkerPrivateTempSymbol(); Streamer->emitLabel(SectionStartSym); Section->setBeginSymbol(SectionStartSym); } @@ -256,6 +254,12 @@ MCSection *ObjectWriter::GetSpecificSection(const char *SectionName, if (attributes & CustomSectionAttributes_MachO_Init_Func_Pointers) { typeAndAttributes |= MachO::SectionType::S_MOD_INIT_FUNC_POINTERS; } + if (attributes & CustomSectionAttributes_Executable) { + // Needs to be set on sections with actual code. The linker uses + // it to determine code sections and emit information about function + // boundaries. + typeAndAttributes |= MachO::S_ATTR_PURE_INSTRUCTIONS; + } Section = OutContext->getMachOSection( (attributes & CustomSectionAttributes_Executable) ? "__TEXT" : "__DATA", SectionName, typeAndAttributes, Kind); @@ -440,6 +444,25 @@ int ObjectWriter::EmitSymbolRef(const char *SymbolName, Size = 8; break; case RelocType::IMAGE_REL_BASED_REL32: + if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsMachO && + ObjFileInfo->getTargetTriple().getArch() == Triple::aarch64) { + MCSymbol *TempSymbol = OutContext->createTempSymbol(); + Streamer->emitLabel(TempSymbol); + const MCExpr *TargetExpr = MCSymbolRefExpr::create(Symbol, Kind, *OutContext); + const MCSymbolRefExpr *SectionExpr = MCSymbolRefExpr::create(TempSymbol, Kind, *OutContext); + TargetExpr = MCBinaryExpr::createSub( + TargetExpr, SectionExpr, *OutContext); + // If the fixup is pc-relative, we need to bias the value to be relative to + // the start of the field, not the end of the field + TargetExpr = MCBinaryExpr::createSub( + TargetExpr, MCConstantExpr::create(4, *OutContext), *OutContext); + if (Delta != 0) { + TargetExpr = MCBinaryExpr::createAdd( + TargetExpr, MCConstantExpr::create(Delta, *OutContext), *OutContext); + } + Streamer->emitValueImpl(TargetExpr, 4, SMLoc(), false); + return 4; + } Size = 4; IsPCRel = true; if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsELF) { @@ -449,6 +472,21 @@ int ObjectWriter::EmitSymbolRef(const char *SymbolName, } break; case RelocType::IMAGE_REL_BASED_RELPTR32: + if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsMachO && + ObjFileInfo->getTargetTriple().getArch() == Triple::aarch64) { + MCSymbol *TempSymbol = OutContext->createTempSymbol(); + Streamer->emitLabel(TempSymbol); + const MCExpr *TargetExpr = MCSymbolRefExpr::create(Symbol, Kind, *OutContext); + const MCSymbolRefExpr *SectionExpr = MCSymbolRefExpr::create(TempSymbol, Kind, *OutContext); + TargetExpr = MCBinaryExpr::createSub( + TargetExpr, SectionExpr, *OutContext); + if (Delta != 0) { + TargetExpr = MCBinaryExpr::createAdd( + TargetExpr, MCConstantExpr::create(Delta, *OutContext), *OutContext); + } + Streamer->emitValueImpl(TargetExpr, 4, SMLoc(), false); + return 4; + } Size = 4; IsPCRel = true; Delta += 4; @@ -471,6 +509,9 @@ int ObjectWriter::EmitSymbolRef(const char *SymbolName, return 4; } case RelocType::IMAGE_REL_BASED_ARM64_PAGEBASE_REL21: { + if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsMachO) { + Kind = MCSymbolRefExpr::VK_PAGE; + } const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta); TargetExpr = AArch64MCExpr::create(TargetExpr, AArch64MCExpr::VK_CALL, *OutContext); @@ -478,6 +519,9 @@ int ObjectWriter::EmitSymbolRef(const char *SymbolName, return 4; } case RelocType::IMAGE_REL_BASED_ARM64_PAGEOFFSET_12A: { + if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsMachO) { + Kind = MCSymbolRefExpr::VK_PAGEOFF; + } const MCExpr *TargetExpr = GenTargetExpr(Symbol, Kind, Delta); TargetExpr = AArch64MCExpr::create(TargetExpr, AArch64MCExpr::VK_LO12, *OutContext); @@ -556,8 +600,12 @@ void ObjectWriter::EmitCFILsda(const char *LsdaBlobSymbolName) { // Create symbol reference MCSymbol *T = OutContext->getOrCreateSymbol(LsdaBlobSymbolName); Assembler->registerSymbol(*T); - Streamer->emitCFILsda(T, llvm::dwarf::Constants::DW_EH_PE_pcrel | - llvm::dwarf::Constants::DW_EH_PE_sdata4); + if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsMachO) { + Streamer->emitCFILsda(T, llvm::dwarf::Constants::DW_EH_PE_pcrel); + } else { + Streamer->emitCFILsda(T, llvm::dwarf::Constants::DW_EH_PE_pcrel | + llvm::dwarf::Constants::DW_EH_PE_sdata4); + } } void ObjectWriter::EmitCFICode(int Offset, const char *Blob) { @@ -882,9 +930,8 @@ void ObjectWriter::EmitDebugFunctionInfo(const char *FunctionName, Streamer->emitSymbolAttribute(Sym, MCSA_ELF_TypeFunction); Streamer->emitELFSize(Sym, MCConstantExpr::create(FunctionSize, *OutContext)); - EmitDwarfFunctionInfo(FunctionName, FunctionSize, MethodTypeIndex); } - // TODO: Should test it for Macho. + EmitDwarfFunctionInfo(FunctionName, FunctionSize, MethodTypeIndex); } } @@ -963,12 +1010,10 @@ void ObjectWriter::EmitDebugModuleInfo() { Streamer->SwitchSection(Section); Streamer->emitCVFileChecksumsDirective(); Streamer->emitCVStringTableDirective(); - } else if (ObjFileInfo->getObjectFileType() == ObjFileInfo->IsELF) { + } else { DwarfGenerator->EmitAbbrev(); DwarfGenerator->EmitAranges(); DwarfGenerator->Finish(); - } else { - OutContext->setGenDwarfForAssembly(true); } }