| author | |
| committer | |
| log | 2bd6c60752bbfc568c1fdf358a68480ddd437def |
| tree | 3b1f35ab36514b37a46445bdff961b2a276674b9 |
| parent | 6aa04c422bae89c50e1289e1ca51cd4d414debb7 |
6 files changed, 85 insertions(+), 200 deletions(-)
src/link.cpp+19-3| ... | ... | @@ -437,12 +437,26 @@ static void construct_linker_job_coff(LinkJob *lj) { |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | 439 | if (buf_len(def_contents) != 0) { |
| 440 | Buf *dll_path = buf_alloc(); | |
| 441 | os_path_join(g->cache_dir, buf_create_from_str("all.dll"), dll_path); | |
| 442 | ZigLLDDefToLib(def_contents, dll_path); | |
| 440 | Buf *def_path = buf_alloc(); | |
| 441 | os_path_join(g->cache_dir, buf_create_from_str("all.def"), def_path); | |
| 442 | os_write_file(def_path, def_contents); | |
| 443 | 443 | |
| 444 | 444 | Buf *all_lib_path = buf_alloc(); |
| 445 | 445 | os_path_join(g->cache_dir, buf_create_from_str("all.lib"), all_lib_path); |
| 446 | ||
| 447 | //Buf *dll_path = buf_alloc(); | |
| 448 | //os_path_join(g->cache_dir, buf_create_from_str("all.dll"), dll_path); | |
| 449 | ||
| 450 | ZigList<const char *> args = {0}; | |
| 451 | args.append("link"); | |
| 452 | args.append(buf_ptr(buf_sprintf("-DEF:%s", buf_ptr(def_path)))); | |
| 453 | args.append(buf_ptr(buf_sprintf("-OUT:%s", buf_ptr(all_lib_path)))); | |
| 454 | Buf diag = BUF_INIT; | |
| 455 | if (!ZigLLDLink(g->zig_target.oformat, args.items, args.length, &diag)) { | |
| 456 | fprintf(stderr, "%s\n", buf_ptr(&diag)); | |
| 457 | exit(1); | |
| 458 | } | |
| 459 | ||
| 446 | 460 | lj->args.append(buf_ptr(all_lib_path)); |
| 447 | 461 | } |
| 448 | 462 | |
| ... | ... | @@ -732,6 +746,8 @@ static void construct_linker_job(LinkJob *lj) { |
| 732 | 746 | return construct_linker_job_elf(lj); |
| 733 | 747 | case ZigLLVM_MachO: |
| 734 | 748 | return construct_linker_job_macho(lj); |
| 749 | case ZigLLVM_Wasm: | |
| 750 | zig_panic("TODO link wasm"); | |
| 735 | 751 | } |
| 736 | 752 | } |
| 737 | 753 |
src/parseh.cpp+7-4| ... | ... | @@ -341,7 +341,6 @@ static TypeTableEntry *resolve_type_with_table(Context *c, const Type *ty, const |
| 341 | 341 | case BuiltinType::OCLEvent: |
| 342 | 342 | case BuiltinType::OCLClkEvent: |
| 343 | 343 | case BuiltinType::OCLQueue: |
| 344 | case BuiltinType::OCLNDRange: | |
| 345 | 344 | case BuiltinType::OCLReserveID: |
| 346 | 345 | emit_warning(c, decl, "missed a builtin type"); |
| 347 | 346 | return c->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -445,8 +444,8 @@ static TypeTableEntry *resolve_type_with_table(Context *c, const Type *ty, const |
| 445 | 444 | case CC_X86Pascal: // __attribute__((pascal)) |
| 446 | 445 | emit_warning(c, decl, "function type has x86 pascal calling convention"); |
| 447 | 446 | return c->codegen->builtin_types.entry_invalid; |
| 448 | case CC_X86_64Win64: // __attribute__((ms_abi)) | |
| 449 | emit_warning(c, decl, "function type has x86 64win64 calling convention"); | |
| 447 | case CC_Win64: // __attribute__((ms_abi)) | |
| 448 | emit_warning(c, decl, "function type has win64 calling convention"); | |
| 450 | 449 | return c->codegen->builtin_types.entry_invalid; |
| 451 | 450 | case CC_X86_64SysV: // __attribute__((sysv_abi)) |
| 452 | 451 | emit_warning(c, decl, "function type has x86 64sysv calling convention"); |
| ... | ... | @@ -586,6 +585,7 @@ static TypeTableEntry *resolve_type_with_table(Context *c, const Type *ty, const |
| 586 | 585 | case Type::Atomic: |
| 587 | 586 | case Type::Pipe: |
| 588 | 587 | case Type::ObjCTypeParam: |
| 588 | case Type::DeducedTemplateSpecialization: | |
| 589 | 589 | emit_warning(c, decl, "missed a '%s' type", ty->getTypeClassName()); |
| 590 | 590 | return c->codegen->builtin_types.entry_invalid; |
| 591 | 591 | } |
| ... | ... | @@ -1369,6 +1369,8 @@ int parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const ch |
| 1369 | 1369 | bool capture_diagnostics = true; |
| 1370 | 1370 | bool user_files_are_volatile = true; |
| 1371 | 1371 | bool allow_pch_with_compiler_errors = false; |
| 1372 | bool single_file_parse = false; | |
| 1373 | bool for_serialization = false; | |
| 1372 | 1374 | const char *resources_path = ZIG_HEADERS_DIR; |
| 1373 | 1375 | std::unique_ptr<ASTUnit> err_unit; |
| 1374 | 1376 | std::unique_ptr<ASTUnit> ast_unit(ASTUnit::LoadFromCommandLine( |
| ... | ... | @@ -1376,7 +1378,8 @@ int parse_h_file(ImportTableEntry *import, ZigList<ErrorMsg *> *errors, const ch |
| 1376 | 1378 | pch_container_ops, diags, resources_path, |
| 1377 | 1379 | only_local_decls, capture_diagnostics, None, true, 0, TU_Complete, |
| 1378 | 1380 | false, false, allow_pch_with_compiler_errors, skip_function_bodies, |
| 1379 | user_files_are_volatile, false, None, &err_unit)); | |
| 1381 | single_file_parse, user_files_are_volatile, for_serialization, None, &err_unit, | |
| 1382 | nullptr)); | |
| 1380 | 1383 | |
| 1381 | 1384 | |
| 1382 | 1385 | // Early failures in LoadFromCommandLine may return with ErrUnit unset. |
src/target.cpp+11| ... | ... | @@ -24,6 +24,7 @@ static const ArchType arch_list[] = { |
| 24 | 24 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7m}, |
| 25 | 25 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7s}, |
| 26 | 26 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7k}, |
| 27 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v7ve}, | |
| 27 | 28 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v6}, |
| 28 | 29 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v6m}, |
| 29 | 30 | {ZigLLVM_arm, ZigLLVM_ARMSubArch_v6k}, |
| ... | ... | @@ -44,6 +45,7 @@ static const ArchType arch_list[] = { |
| 44 | 45 | {ZigLLVM_mips64, ZigLLVM_NoSubArch}, |
| 45 | 46 | {ZigLLVM_mips64el, ZigLLVM_NoSubArch}, |
| 46 | 47 | {ZigLLVM_msp430, ZigLLVM_NoSubArch}, |
| 48 | {ZigLLVM_nios2, ZigLLVM_NoSubArch}, | |
| 47 | 49 | {ZigLLVM_ppc, ZigLLVM_NoSubArch}, |
| 48 | 50 | {ZigLLVM_ppc64, ZigLLVM_NoSubArch}, |
| 49 | 51 | {ZigLLVM_ppc64le, ZigLLVM_NoSubArch}, |
| ... | ... | @@ -100,10 +102,12 @@ static const ZigLLVM_VendorType vendor_list[] = { |
| 100 | 102 | ZigLLVM_Myriad, |
| 101 | 103 | ZigLLVM_AMD, |
| 102 | 104 | ZigLLVM_Mesa, |
| 105 | ZigLLVM_SUSE, | |
| 103 | 106 | }; |
| 104 | 107 | |
| 105 | 108 | static const ZigLLVM_OSType os_list[] = { |
| 106 | 109 | ZigLLVM_UnknownOS, |
| 110 | ZigLLVM_Ananas, | |
| 107 | 111 | ZigLLVM_CloudABI, |
| 108 | 112 | ZigLLVM_Darwin, |
| 109 | 113 | ZigLLVM_DragonFly, |
| ... | ... | @@ -156,6 +160,7 @@ static const ZigLLVM_EnvironmentType environ_list[] = { |
| 156 | 160 | ZigLLVM_Cygnus, |
| 157 | 161 | ZigLLVM_AMDOpenCL, |
| 158 | 162 | ZigLLVM_CoreCLR, |
| 163 | ZigLLVM_OpenCL, | |
| 159 | 164 | }; |
| 160 | 165 | |
| 161 | 166 | static const ZigLLVM_ObjectFormatType oformat_list[] = { |
| ... | ... | @@ -163,6 +168,7 @@ static const ZigLLVM_ObjectFormatType oformat_list[] = { |
| 163 | 168 | ZigLLVM_COFF, |
| 164 | 169 | ZigLLVM_ELF, |
| 165 | 170 | ZigLLVM_MachO, |
| 171 | ZigLLVM_Wasm, | |
| 166 | 172 | }; |
| 167 | 173 | |
| 168 | 174 | size_t target_oformat_count(void) { |
| ... | ... | @@ -179,6 +185,7 @@ const char *get_target_oformat_name(ZigLLVM_ObjectFormatType oformat) { |
| 179 | 185 | case ZigLLVM_COFF: return "coff"; |
| 180 | 186 | case ZigLLVM_ELF: return "elf"; |
| 181 | 187 | case ZigLLVM_MachO: return "macho"; |
| 188 | case ZigLLVM_Wasm: return "wasm"; | |
| 182 | 189 | } |
| 183 | 190 | zig_unreachable(); |
| 184 | 191 | } |
| ... | ... | @@ -353,6 +360,7 @@ void resolve_target_object_format(ZigTarget *target) { |
| 353 | 360 | case ZigLLVM_mips64el: |
| 354 | 361 | case ZigLLVM_mipsel: |
| 355 | 362 | case ZigLLVM_msp430: |
| 363 | case ZigLLVM_nios2: | |
| 356 | 364 | case ZigLLVM_nvptx: |
| 357 | 365 | case ZigLLVM_nvptx64: |
| 358 | 366 | case ZigLLVM_ppc64le: |
| ... | ... | @@ -389,6 +397,7 @@ void resolve_target_object_format(ZigTarget *target) { |
| 389 | 397 | } |
| 390 | 398 | |
| 391 | 399 | // See lib/Support/Triple.cpp in LLVM for the source of this data. |
| 400 | // getArchPointerBitWidth | |
| 392 | 401 | static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) { |
| 393 | 402 | switch (arch) { |
| 394 | 403 | case ZigLLVM_UnknownArch: |
| ... | ... | @@ -404,6 +413,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) { |
| 404 | 413 | case ZigLLVM_le32: |
| 405 | 414 | case ZigLLVM_mips: |
| 406 | 415 | case ZigLLVM_mipsel: |
| 416 | case ZigLLVM_nios2: | |
| 407 | 417 | case ZigLLVM_nvptx: |
| 408 | 418 | case ZigLLVM_ppc: |
| 409 | 419 | case ZigLLVM_r600: |
| ... | ... | @@ -504,6 +514,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 504 | 514 | case CIntTypeCount: |
| 505 | 515 | zig_unreachable(); |
| 506 | 516 | } |
| 517 | case ZigLLVM_Ananas: | |
| 507 | 518 | case ZigLLVM_CloudABI: |
| 508 | 519 | case ZigLLVM_DragonFly: |
| 509 | 520 | case ZigLLVM_FreeBSD: |
src/zig_llvm.cpp+15-166| ... | ... | @@ -38,7 +38,6 @@ |
| 38 | 38 | #include <llvm/Support/FileSystem.h> |
| 39 | 39 | #include <llvm/Support/TargetParser.h> |
| 40 | 40 | #include <llvm/Support/raw_ostream.h> |
| 41 | #include <llvm/Support/COFF.h> | |
| 42 | 41 | #include <llvm/Target/TargetMachine.h> |
| 43 | 42 | #include <llvm/Transforms/IPO.h> |
| 44 | 43 | #include <llvm/Transforms/IPO/PassManagerBuilder.h> |
| ... | ... | @@ -105,11 +104,9 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM |
| 105 | 104 | PMBuilder->DisableTailCalls = is_debug; |
| 106 | 105 | PMBuilder->DisableUnitAtATime = is_debug; |
| 107 | 106 | PMBuilder->DisableUnrollLoops = is_debug; |
| 108 | PMBuilder->BBVectorize = !is_debug; | |
| 109 | 107 | PMBuilder->SLPVectorize = !is_debug; |
| 110 | 108 | PMBuilder->LoopVectorize = !is_debug; |
| 111 | 109 | PMBuilder->RerollLoops = !is_debug; |
| 112 | PMBuilder->LoadCombine = !is_debug; | |
| 113 | 110 | PMBuilder->NewGVN = !is_debug; |
| 114 | 111 | PMBuilder->DisableGVNLoadPRE = is_debug; |
| 115 | 112 | PMBuilder->VerifyInput = assertions_on; |
| ... | ... | @@ -125,13 +122,10 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM |
| 125 | 122 | if (is_debug) { |
| 126 | 123 | PMBuilder->Inliner = createAlwaysInlinerLegacyPass(false); |
| 127 | 124 | } else { |
| 128 | PMBuilder->addExtension(PassManagerBuilder::EP_EarlyAsPossible, | |
| 129 | [&](const PassManagerBuilder &, legacy::PassManagerBase &PM) { | |
| 130 | target_machine->addEarlyAsPossiblePasses(PM); | |
| 131 | }); | |
| 125 | target_machine->adjustPassManager(*PMBuilder); | |
| 132 | 126 | |
| 133 | 127 | PMBuilder->addExtension(PassManagerBuilder::EP_EarlyAsPossible, addDiscriminatorsPass); |
| 134 | PMBuilder->Inliner = createFunctionInliningPass(PMBuilder->OptLevel, PMBuilder->SizeLevel); | |
| 128 | PMBuilder->Inliner = createFunctionInliningPass(PMBuilder->OptLevel, PMBuilder->SizeLevel, false); | |
| 135 | 129 | } |
| 136 | 130 | |
| 137 | 131 | // Set up the per-function pass manager. |
| ... | ... | @@ -182,7 +176,7 @@ LLVMValueRef ZigLLVMBuildCall(LLVMBuilderRef B, LLVMValueRef Fn, LLVMValueRef *A |
| 182 | 176 | CallInst *call_inst = CallInst::Create(unwrap(Fn), makeArrayRef(unwrap(Args), NumArgs), Name); |
| 183 | 177 | call_inst->setCallingConv(CC); |
| 184 | 178 | if (always_inline) { |
| 185 | call_inst->addAttribute(AttributeSet::FunctionIndex, Attribute::AlwaysInline); | |
| 179 | call_inst->addAttribute(AttributeList::FunctionIndex, Attribute::AlwaysInline); | |
| 186 | 180 | } |
| 187 | 181 | return wrap(unwrap(B)->Insert(call_inst)); |
| 188 | 182 | } |
| ... | ... | @@ -198,7 +192,7 @@ ZigLLVMDIType *ZigLLVMCreateDebugPointerType(ZigLLVMDIBuilder *dibuilder, ZigLLV |
| 198 | 192 | uint64_t size_in_bits, uint64_t align_in_bits, const char *name) |
| 199 | 193 | { |
| 200 | 194 | DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createPointerType( |
| 201 | reinterpret_cast<DIType*>(pointee_type), size_in_bits, align_in_bits, name); | |
| 195 | reinterpret_cast<DIType*>(pointee_type), size_in_bits, align_in_bits, Optional<unsigned>(), name); | |
| 202 | 196 | return reinterpret_cast<ZigLLVMDIType*>(di_type); |
| 203 | 197 | } |
| 204 | 198 | |
| ... | ... | @@ -599,23 +593,22 @@ void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state) { |
| 599 | 593 | |
| 600 | 594 | void ZigLLVMAddFunctionAttr(LLVMValueRef fn_ref, const char *attr_name, const char *attr_value) { |
| 601 | 595 | Function *func = unwrap<Function>(fn_ref); |
| 602 | const AttributeSet attr_set = func->getAttributes(); | |
| 596 | const AttributeList attr_set = func->getAttributes(); | |
| 603 | 597 | AttrBuilder attr_builder; |
| 604 | 598 | if (attr_value) { |
| 605 | 599 | attr_builder.addAttribute(attr_name, attr_value); |
| 606 | 600 | } else { |
| 607 | 601 | attr_builder.addAttribute(attr_name); |
| 608 | 602 | } |
| 609 | const AttributeSet new_attr_set = attr_set.addAttributes(func->getContext(), | |
| 610 | AttributeSet::FunctionIndex, AttributeSet::get(func->getContext(), | |
| 611 | AttributeSet::FunctionIndex, attr_builder)); | |
| 603 | const AttributeList new_attr_set = attr_set.addAttributes(func->getContext(), | |
| 604 | AttributeList::FunctionIndex, attr_builder); | |
| 612 | 605 | func->setAttributes(new_attr_set); |
| 613 | 606 | } |
| 614 | 607 | |
| 615 | 608 | void ZigLLVMAddFunctionAttrCold(LLVMValueRef fn_ref) { |
| 616 | 609 | Function *func = unwrap<Function>(fn_ref); |
| 617 | const AttributeSet attr_set = func->getAttributes(); | |
| 618 | const AttributeSet new_attr_set = attr_set.addAttribute(func->getContext(), AttributeSet::FunctionIndex, | |
| 610 | const AttributeList attr_set = func->getAttributes(); | |
| 611 | const AttributeList new_attr_set = attr_set.addAttribute(func->getContext(), AttributeList::FunctionIndex, | |
| 619 | 612 | Attribute::Cold); |
| 620 | 613 | func->setAttributes(new_attr_set); |
| 621 | 614 | } |
| ... | ... | @@ -690,6 +683,8 @@ const char *ZigLLVMGetSubArchTypeName(ZigLLVM_SubArchType sub_arch) { |
| 690 | 683 | return "v7s"; |
| 691 | 684 | case ZigLLVM_ARMSubArch_v7k: |
| 692 | 685 | return "v7k"; |
| 686 | case ZigLLVM_ARMSubArch_v7ve: | |
| 687 | return "v7ve"; | |
| 693 | 688 | case ZigLLVM_ARMSubArch_v6: |
| 694 | 689 | return "v6"; |
| 695 | 690 | case ZigLLVM_ARMSubArch_v6m: |
| ... | ... | @@ -741,8 +736,7 @@ LLVMValueRef ZigLLVMBuildCmpXchg(LLVMBuilderRef builder, LLVMValueRef ptr, LLVMV |
| 741 | 736 | LLVMAtomicOrdering failure_ordering) |
| 742 | 737 | { |
| 743 | 738 | return wrap(unwrap(builder)->CreateAtomicCmpXchg(unwrap(ptr), unwrap(cmp), unwrap(new_val), |
| 744 | mapFromLLVMOrdering(success_ordering), mapFromLLVMOrdering(failure_ordering), | |
| 745 | CrossThread)); | |
| 739 | mapFromLLVMOrdering(success_ordering), mapFromLLVMOrdering(failure_ordering))); | |
| 746 | 740 | } |
| 747 | 741 | |
| 748 | 742 | LLVMValueRef ZigLLVMBuildNSWShl(LLVMBuilderRef builder, LLVMValueRef LHS, LLVMValueRef RHS, |
| ... | ... | @@ -802,154 +796,9 @@ bool ZigLLDLink(ZigLLVM_ObjectFormatType oformat, const char **args, size_t arg_ |
| 802 | 796 | |
| 803 | 797 | case ZigLLVM_MachO: |
| 804 | 798 | return lld::mach_o::link(array_ref_args, diag); |
| 799 | ||
| 800 | case ZigLLVM_Wasm: | |
| 801 | zig_panic("ZigLLDLink for Wasm"); | |
| 805 | 802 | } |
| 806 | 803 | zig_unreachable(); |
| 807 | 804 | } |
| 808 | ||
| 809 | // workaround for LLD not exposing ability to convert .def to .lib | |
| 810 | ||
| 811 | #include <set> | |
| 812 | ||
| 813 | namespace lld { | |
| 814 | namespace coff { | |
| 815 | ||
| 816 | class SymbolBody; | |
| 817 | class StringChunk; | |
| 818 | struct Symbol; | |
| 819 | ||
| 820 | struct Export { | |
| 821 | StringRef Name; // N in /export:N or /export:E=N | |
| 822 | StringRef ExtName; // E in /export:E=N | |
| 823 | SymbolBody *Sym = nullptr; | |
| 824 | uint16_t Ordinal = 0; | |
| 825 | bool Noname = false; | |
| 826 | bool Data = false; | |
| 827 | bool Private = false; | |
| 828 | ||
| 829 | // If an export is a form of /export:foo=dllname.bar, that means | |
| 830 | // that foo should be exported as an alias to bar in the DLL. | |
| 831 | // ForwardTo is set to "dllname.bar" part. Usually empty. | |
| 832 | StringRef ForwardTo; | |
| 833 | StringChunk *ForwardChunk = nullptr; | |
| 834 | ||
| 835 | // True if this /export option was in .drectves section. | |
| 836 | bool Directives = false; | |
| 837 | StringRef SymbolName; | |
| 838 | StringRef ExportName; // Name in DLL | |
| 839 | ||
| 840 | bool operator==(const Export &E) { | |
| 841 | return (Name == E.Name && ExtName == E.ExtName && | |
| 842 | Ordinal == E.Ordinal && Noname == E.Noname && | |
| 843 | Data == E.Data && Private == E.Private); | |
| 844 | } | |
| 845 | }; | |
| 846 | ||
| 847 | enum class DebugType { | |
| 848 | None = 0x0, | |
| 849 | CV = 0x1, /// CodeView | |
| 850 | PData = 0x2, /// Procedure Data | |
| 851 | Fixup = 0x4, /// Relocation Table | |
| 852 | }; | |
| 853 | ||
| 854 | struct Configuration { | |
| 855 | enum ManifestKind { SideBySide, Embed, No }; | |
| 856 | llvm::COFF::MachineTypes Machine = llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN; | |
| 857 | bool Verbose = false; | |
| 858 | llvm::COFF::WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN; | |
| 859 | SymbolBody *Entry = nullptr; | |
| 860 | bool NoEntry = false; | |
| 861 | std::string OutputFile; | |
| 862 | bool DoGC = true; | |
| 863 | bool DoICF = true; | |
| 864 | bool Relocatable = true; | |
| 865 | bool Force = false; | |
| 866 | bool Debug = false; | |
| 867 | bool WriteSymtab = true; | |
| 868 | unsigned DebugTypes = static_cast<unsigned>(DebugType::None); | |
| 869 | StringRef PDBPath; | |
| 870 | ||
| 871 | // Symbols in this set are considered as live by the garbage collector. | |
| 872 | std::set<SymbolBody *> GCRoot; | |
| 873 | ||
| 874 | std::set<StringRef> NoDefaultLibs; | |
| 875 | bool NoDefaultLibAll = false; | |
| 876 | ||
| 877 | // True if we are creating a DLL. | |
| 878 | bool DLL = false; | |
| 879 | StringRef Implib; | |
| 880 | std::vector<Export> Exports; | |
| 881 | std::set<std::string> DelayLoads; | |
| 882 | std::map<std::string, int> DLLOrder; | |
| 883 | SymbolBody *DelayLoadHelper = nullptr; | |
| 884 | ||
| 885 | // Used for SafeSEH. | |
| 886 | Symbol *SEHTable = nullptr; | |
| 887 | Symbol *SEHCount = nullptr; | |
| 888 | ||
| 889 | // Used for /opt:lldlto=N | |
| 890 | unsigned LTOOptLevel = 2; | |
| 891 | ||
| 892 | // Used for /opt:lldltojobs=N | |
| 893 | unsigned LTOJobs = 1; | |
| 894 | ||
| 895 | // Used for /merge:from=to (e.g. /merge:.rdata=.text) | |
| 896 | std::map<StringRef, StringRef> Merge; | |
| 897 | ||
| 898 | // Used for /section=.name,{DEKPRSW} to set section attributes. | |
| 899 | std::map<StringRef, uint32_t> Section; | |
| 900 | ||
| 901 | // Options for manifest files. | |
| 902 | ManifestKind Manifest = SideBySide; | |
| 903 | int ManifestID = 1; | |
| 904 | StringRef ManifestDependency; | |
| 905 | bool ManifestUAC = true; | |
| 906 | std::vector<std::string> ManifestInput; | |
| 907 | StringRef ManifestLevel = "'asInvoker'"; | |
| 908 | StringRef ManifestUIAccess = "'false'"; | |
| 909 | StringRef ManifestFile; | |
| 910 | ||
| 911 | // Used for /failifmismatch. | |
| 912 | std::map<StringRef, StringRef> MustMatch; | |
| 913 | ||
| 914 | // Used for /alternatename. | |
| 915 | std::map<StringRef, StringRef> AlternateNames; | |
| 916 | ||
| 917 | uint64_t ImageBase = -1; | |
| 918 | uint64_t StackReserve = 1024 * 1024; | |
| 919 | uint64_t StackCommit = 4096; | |
| 920 | uint64_t HeapReserve = 1024 * 1024; | |
| 921 | uint64_t HeapCommit = 4096; | |
| 922 | uint32_t MajorImageVersion = 0; | |
| 923 | uint32_t MinorImageVersion = 0; | |
| 924 | uint32_t MajorOSVersion = 6; | |
| 925 | uint32_t MinorOSVersion = 0; | |
| 926 | bool DynamicBase = true; | |
| 927 | bool AllowBind = true; | |
| 928 | bool NxCompat = true; | |
| 929 | bool AllowIsolation = true; | |
| 930 | bool TerminalServerAware = true; | |
| 931 | bool LargeAddressAware = false; | |
| 932 | bool HighEntropyVA = false; | |
| 933 | ||
| 934 | // This is for debugging. | |
| 935 | bool DebugPdb = false; | |
| 936 | bool DumpPdb = false; | |
| 937 | }; | |
| 938 | ||
| 939 | extern Configuration *Config; | |
| 940 | ||
| 941 | void writeImportLibrary(); | |
| 942 | void parseModuleDefs(MemoryBufferRef MB); | |
| 943 | ||
| 944 | } // namespace coff | |
| 945 | } // namespace lld | |
| 946 | ||
| 947 | // writes the output to dll_path with .dll replaced with .lib | |
| 948 | void ZigLLDDefToLib(Buf *def_contents, Buf *dll_path) { | |
| 949 | lld::coff::Config = new lld::coff::Configuration; | |
| 950 | auto mem_buf = MemoryBuffer::getMemBuffer(buf_ptr(def_contents)); | |
| 951 | MemoryBufferRef mbref(*mem_buf); | |
| 952 | lld::coff::parseModuleDefs(mbref); | |
| 953 | lld::coff::Config->OutputFile = buf_ptr(dll_path); | |
| 954 | lld::coff::writeImportLibrary(); | |
| 955 | } |
src/zig_llvm.hpp+30-27| ... | ... | @@ -188,6 +188,7 @@ enum ZigLLVM_ArchType { |
| 188 | 188 | ZigLLVM_mips64, // MIPS64: mips64 |
| 189 | 189 | ZigLLVM_mips64el, // MIPS64EL: mips64el |
| 190 | 190 | ZigLLVM_msp430, // MSP430: msp430 |
| 191 | ZigLLVM_nios2, // NIOSII: nios2 | |
| 191 | 192 | ZigLLVM_ppc, // PPC: powerpc |
| 192 | 193 | ZigLLVM_ppc64, // PPC64: powerpc64, ppu |
| 193 | 194 | ZigLLVM_ppc64le, // PPC64LE: powerpc64le |
| ... | ... | @@ -228,30 +229,31 @@ enum ZigLLVM_ArchType { |
| 228 | 229 | }; |
| 229 | 230 | |
| 230 | 231 | enum ZigLLVM_SubArchType { |
| 231 | ZigLLVM_NoSubArch, | |
| 232 | ||
| 233 | ZigLLVM_ARMSubArch_v8_2a, | |
| 234 | ZigLLVM_ARMSubArch_v8_1a, | |
| 235 | ZigLLVM_ARMSubArch_v8, | |
| 236 | ZigLLVM_ARMSubArch_v8r, | |
| 237 | ZigLLVM_ARMSubArch_v8m_baseline, | |
| 238 | ZigLLVM_ARMSubArch_v8m_mainline, | |
| 239 | ZigLLVM_ARMSubArch_v7, | |
| 240 | ZigLLVM_ARMSubArch_v7em, | |
| 241 | ZigLLVM_ARMSubArch_v7m, | |
| 242 | ZigLLVM_ARMSubArch_v7s, | |
| 243 | ZigLLVM_ARMSubArch_v7k, | |
| 244 | ZigLLVM_ARMSubArch_v6, | |
| 245 | ZigLLVM_ARMSubArch_v6m, | |
| 246 | ZigLLVM_ARMSubArch_v6k, | |
| 247 | ZigLLVM_ARMSubArch_v6t2, | |
| 248 | ZigLLVM_ARMSubArch_v5, | |
| 249 | ZigLLVM_ARMSubArch_v5te, | |
| 250 | ZigLLVM_ARMSubArch_v4t, | |
| 251 | ||
| 252 | ZigLLVM_KalimbaSubArch_v3, | |
| 253 | ZigLLVM_KalimbaSubArch_v4, | |
| 254 | ZigLLVM_KalimbaSubArch_v5, | |
| 232 | ZigLLVM_NoSubArch, | |
| 233 | ||
| 234 | ZigLLVM_ARMSubArch_v8_2a, | |
| 235 | ZigLLVM_ARMSubArch_v8_1a, | |
| 236 | ZigLLVM_ARMSubArch_v8, | |
| 237 | ZigLLVM_ARMSubArch_v8r, | |
| 238 | ZigLLVM_ARMSubArch_v8m_baseline, | |
| 239 | ZigLLVM_ARMSubArch_v8m_mainline, | |
| 240 | ZigLLVM_ARMSubArch_v7, | |
| 241 | ZigLLVM_ARMSubArch_v7em, | |
| 242 | ZigLLVM_ARMSubArch_v7m, | |
| 243 | ZigLLVM_ARMSubArch_v7s, | |
| 244 | ZigLLVM_ARMSubArch_v7k, | |
| 245 | ZigLLVM_ARMSubArch_v7ve, | |
| 246 | ZigLLVM_ARMSubArch_v6, | |
| 247 | ZigLLVM_ARMSubArch_v6m, | |
| 248 | ZigLLVM_ARMSubArch_v6k, | |
| 249 | ZigLLVM_ARMSubArch_v6t2, | |
| 250 | ZigLLVM_ARMSubArch_v5, | |
| 251 | ZigLLVM_ARMSubArch_v5te, | |
| 252 | ZigLLVM_ARMSubArch_v4t, | |
| 253 | ||
| 254 | ZigLLVM_KalimbaSubArch_v3, | |
| 255 | ZigLLVM_KalimbaSubArch_v4, | |
| 256 | ZigLLVM_KalimbaSubArch_v5, | |
| 255 | 257 | }; |
| 256 | 258 | |
| 257 | 259 | enum ZigLLVM_VendorType { |
| ... | ... | @@ -271,13 +273,15 @@ enum ZigLLVM_VendorType { |
| 271 | 273 | ZigLLVM_Myriad, |
| 272 | 274 | ZigLLVM_AMD, |
| 273 | 275 | ZigLLVM_Mesa, |
| 276 | ZigLLVM_SUSE, | |
| 274 | 277 | |
| 275 | ZigLLVM_LastVendorType = ZigLLVM_Mesa | |
| 278 | ZigLLVM_LastVendorType = ZigLLVM_SUSE | |
| 276 | 279 | }; |
| 277 | 280 | |
| 278 | 281 | enum ZigLLVM_OSType { |
| 279 | 282 | ZigLLVM_UnknownOS, |
| 280 | 283 | |
| 284 | ZigLLVM_Ananas, | |
| 281 | 285 | ZigLLVM_CloudABI, |
| 282 | 286 | ZigLLVM_Darwin, |
| 283 | 287 | ZigLLVM_DragonFly, |
| ... | ... | @@ -344,6 +348,7 @@ enum ZigLLVM_ObjectFormatType { |
| 344 | 348 | ZigLLVM_COFF, |
| 345 | 349 | ZigLLVM_ELF, |
| 346 | 350 | ZigLLVM_MachO, |
| 351 | ZigLLVM_Wasm, | |
| 347 | 352 | }; |
| 348 | 353 | |
| 349 | 354 | const char *ZigLLVMGetArchTypeName(ZigLLVM_ArchType arch); |
| ... | ... | @@ -363,6 +368,4 @@ void ZigLLVMGetNativeTarget(ZigLLVM_ArchType *arch_type, ZigLLVM_SubArchType *su |
| 363 | 368 | ZigLLVM_VendorType *vendor_type, ZigLLVM_OSType *os_type, ZigLLVM_EnvironmentType *environ_type, |
| 364 | 369 | ZigLLVM_ObjectFormatType *oformat); |
| 365 | 370 | |
| 366 | void ZigLLDDefToLib(Buf *def_contents, Buf *dll_path); | |
| 367 | ||
| 368 | 371 | #endif |
std/debug.zig+3| ... | ... | @@ -147,6 +147,9 @@ pub fn writeStackTrace(out_stream: &io.OutStream, allocator: &mem.Allocator, tty |
| 147 | 147 | builtin.ObjectFormat.macho => { |
| 148 | 148 | %return out_stream.write("(stack trace unavailable for Mach-O object format)\n"); |
| 149 | 149 | }, |
| 150 | builtin.ObjectFormat.wasm => { | |
| 151 | %return out_stream.write("(stack trace unavailable for WASM object format)\n"); | |
| 152 | }, | |
| 150 | 153 | builtin.ObjectFormat.unknown => { |
| 151 | 154 | %return out_stream.write("(stack trace unavailable for unknown object format)\n"); |
| 152 | 155 | }, |