| author | |
| committer | |
| log | 921825b4c0a83c98782e1b9266522aefb1b17022 |
| tree | 6d2c75762c3e08dd686710666f8208fa1406be6c |
| parent | b4120423a5f0785e950739ab8c1324691971d680 |
| parent | cf96b6f87b5feaa699f0d15b1525d53a374b6227 |
14 files changed, 104 insertions(+), 24 deletions(-)
CMakeLists.txt+8-3| ... | ... | @@ -47,15 +47,20 @@ option(ZIG_TEST_COVERAGE "Build Zig with test coverage instrumentation" OFF) |
| 47 | 47 | option(ZIG_FORCE_EXTERNAL_LLD "If your system has the LLD patches use it instead of the embedded LLD" OFF) |
| 48 | 48 | |
| 49 | 49 | find_package(llvm) |
| 50 | include_directories(${LLVM_INCLUDE_DIRS}) | |
| 51 | ||
| 52 | 50 | find_package(clang) |
| 53 | include_directories(${CLANG_INCLUDE_DIRS}) | |
| 54 | 51 | |
| 55 | 52 | if(ZIG_FORCE_EXTERNAL_LLD) |
| 56 | 53 | find_package(lld) |
| 54 | include_directories(${LLVM_INCLUDE_DIRS}) | |
| 57 | 55 | include_directories(${LLD_INCLUDE_DIRS}) |
| 56 | include_directories(${CLANG_INCLUDE_DIRS}) | |
| 58 | 57 | else() |
| 58 | # This goes first so that we find embedded LLD instead | |
| 59 | # of system LLD. | |
| 60 | include_directories("${CMAKE_SOURCE_DIR}/deps/lld/include") | |
| 61 | ||
| 62 | include_directories(${LLVM_INCLUDE_DIRS}) | |
| 63 | include_directories(${CLANG_INCLUDE_DIRS}) | |
| 59 | 64 | set(EMBEDDED_LLD_LIB_SOURCES |
| 60 | 65 | "${CMAKE_SOURCE_DIR}/deps/lld/lib/Driver/DarwinLdDriver.cpp" |
| 61 | 66 | "${CMAKE_SOURCE_DIR}/deps/lld/lib/Config/Version.cpp" |
c_headers/avx512fintrin.h+2-7| ... | ... | @@ -267,21 +267,16 @@ _mm512_maskz_set1_epi32(__mmask16 __M, int __A) |
| 267 | 267 | __M); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | #ifdef __x86_64__ | |
| 270 | 271 | static __inline __m512i __DEFAULT_FN_ATTRS |
| 271 | 272 | _mm512_maskz_set1_epi64(__mmask8 __M, long long __A) |
| 272 | 273 | { |
| 273 | #ifdef __x86_64__ | |
| 274 | 274 | return (__m512i) __builtin_ia32_pbroadcastq512_gpr_mask (__A, |
| 275 | 275 | (__v8di) |
| 276 | 276 | _mm512_setzero_si512 (), |
| 277 | 277 | __M); |
| 278 | #else | |
| 279 | return (__m512i) __builtin_ia32_pbroadcastq512_mem_mask (__A, | |
| 280 | (__v8di) | |
| 281 | _mm512_setzero_si512 (), | |
| 282 | __M); | |
| 283 | #endif | |
| 284 | 278 | } |
| 279 | #endif | |
| 285 | 280 | |
| 286 | 281 | static __inline __m512 __DEFAULT_FN_ATTRS |
| 287 | 282 | _mm512_setzero_ps(void) |
deps/lld-prebuilt/lld/Config/Version.inc+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | #define LLD_VERSION 5.0.0 | |
| 2 | #define LLD_VERSION_STRING "5.0.0" | |
| 1 | #define LLD_VERSION 5.0.1 | |
| 2 | #define LLD_VERSION_STRING "5.0.1" | |
| 3 | 3 | #define LLD_VERSION_MAJOR 5 |
| 4 | 4 | #define LLD_VERSION_MINOR 0 |
| 5 | 5 | #define LLD_REVISION_STRING "" |
deps/lld/COFF/Config.h+1| ... | ... | @@ -157,6 +157,7 @@ struct Configuration { |
| 157 | 157 | uint32_t MinorImageVersion = 0; |
| 158 | 158 | uint32_t MajorOSVersion = 6; |
| 159 | 159 | uint32_t MinorOSVersion = 0; |
| 160 | bool CanExitEarly = false; | |
| 160 | 161 | bool DynamicBase = true; |
| 161 | 162 | bool NxCompat = true; |
| 162 | 163 | bool AllowIsolation = true; |
deps/lld/COFF/Driver.cpp+8-2| ... | ... | @@ -52,15 +52,21 @@ BumpPtrAllocator BAlloc; |
| 52 | 52 | StringSaver Saver{BAlloc}; |
| 53 | 53 | std::vector<SpecificAllocBase *> SpecificAllocBase::Instances; |
| 54 | 54 | |
| 55 | bool link(ArrayRef<const char *> Args, raw_ostream &Diag) { | |
| 55 | bool link(ArrayRef<const char *> Args, bool CanExitEarly, raw_ostream &Diag) { | |
| 56 | 56 | ErrorCount = 0; |
| 57 | 57 | ErrorOS = &Diag; |
| 58 | 58 | Config = make<Configuration>(); |
| 59 | 59 | Config->Argv = {Args.begin(), Args.end()}; |
| 60 | 60 | Config->ColorDiagnostics = |
| 61 | 61 | (ErrorOS == &llvm::errs() && Process::StandardErrHasColors()); |
| 62 | Config->CanExitEarly = CanExitEarly; | |
| 62 | 63 | Driver = make<LinkerDriver>(); |
| 63 | 64 | Driver->link(Args); |
| 65 | ||
| 66 | // Call exit() if we can to avoid calling destructors. | |
| 67 | if (CanExitEarly) | |
| 68 | exitLld(ErrorCount ? 1 : 0); | |
| 69 | ||
| 64 | 70 | freeArena(); |
| 65 | 71 | return !ErrorCount; |
| 66 | 72 | } |
| ... | ... | @@ -1123,7 +1129,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) { |
| 1123 | 1129 | // This is useful because MSVC link.exe can generate complete PDBs. |
| 1124 | 1130 | if (Args.hasArg(OPT_msvclto)) { |
| 1125 | 1131 | invokeMSVC(Args); |
| 1126 | exit(0); | |
| 1132 | return; | |
| 1127 | 1133 | } |
| 1128 | 1134 | |
| 1129 | 1135 | // Do LTO by compiling bitcode input files to a set of native COFF files then |
deps/lld/COFF/Error.cpp+3-2| ... | ... | @@ -32,7 +32,7 @@ namespace coff { |
| 32 | 32 | uint64_t ErrorCount; |
| 33 | 33 | raw_ostream *ErrorOS; |
| 34 | 34 | |
| 35 | static LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) { | |
| 35 | LLVM_ATTRIBUTE_NORETURN void exitLld(int Val) { | |
| 36 | 36 | // Dealloc/destroy ManagedStatic variables before calling |
| 37 | 37 | // _exit(). In a non-LTO build, this is a nop. In an LTO |
| 38 | 38 | // build allows us to get the output of -time-passes. |
| ... | ... | @@ -78,7 +78,8 @@ void error(const Twine &Msg) { |
| 78 | 78 | print("error: ", raw_ostream::RED); |
| 79 | 79 | *ErrorOS << "too many errors emitted, stopping now" |
| 80 | 80 | << " (use /ERRORLIMIT:0 to see all errors)\n"; |
| 81 | exitLld(1); | |
| 81 | if (Config->CanExitEarly) | |
| 82 | exitLld(1); | |
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | ++ErrorCount; |
deps/lld/COFF/Error.h+2| ... | ... | @@ -27,6 +27,8 @@ LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg); |
| 27 | 27 | LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix); |
| 28 | 28 | LLVM_ATTRIBUTE_NORETURN void fatal(llvm::Error &Err, const Twine &Prefix); |
| 29 | 29 | |
| 30 | LLVM_ATTRIBUTE_NORETURN void exitLld(int Val); | |
| 31 | ||
| 30 | 32 | template <class T> T check(ErrorOr<T> V, const Twine &Prefix) { |
| 31 | 33 | if (auto EC = V.getError()) |
| 32 | 34 | fatal(EC, Prefix); |
deps/lld/ELF/SyntheticSections.cpp+9-3| ... | ... | @@ -427,10 +427,11 @@ CieRecord *EhFrameSection<ELFT>::addCie(EhSectionPiece &Piece, |
| 427 | 427 | &Sec->template getFile<ELFT>()->getRelocTargetSym(Rels[FirstRelI]); |
| 428 | 428 | |
| 429 | 429 | // Search for an existing CIE by CIE contents/relocation target pair. |
| 430 | CieRecord *Cie = &CieMap[{Piece.data(), Personality}]; | |
| 430 | CieRecord *&Cie = CieMap[{Piece.data(), Personality}]; | |
| 431 | 431 | |
| 432 | 432 | // If not found, create a new one. |
| 433 | if (Cie->Piece == nullptr) { | |
| 433 | if (!Cie) { | |
| 434 | Cie = make<CieRecord>(); | |
| 434 | 435 | Cie->Piece = &Piece; |
| 435 | 436 | Cies.push_back(Cie); |
| 436 | 437 | } |
| ... | ... | @@ -522,9 +523,14 @@ template <class ELFT> |
| 522 | 523 | static void writeCieFde(uint8_t *Buf, ArrayRef<uint8_t> D) { |
| 523 | 524 | memcpy(Buf, D.data(), D.size()); |
| 524 | 525 | |
| 526 | size_t Aligned = alignTo(D.size(), sizeof(typename ELFT::uint)); | |
| 527 | ||
| 528 | // Zero-clear trailing padding if it exists. | |
| 529 | memset(Buf + D.size(), 0, Aligned - D.size()); | |
| 530 | ||
| 525 | 531 | // Fix the size field. -4 since size does not include the size field itself. |
| 526 | 532 | const endianness E = ELFT::TargetEndianness; |
| 527 | write32<E>(Buf, alignTo(D.size(), sizeof(typename ELFT::uint)) - 4); | |
| 533 | write32<E>(Buf, Aligned - 4); | |
| 528 | 534 | } |
| 529 | 535 | |
| 530 | 536 | template <class ELFT> void EhFrameSection<ELFT>::finalizeContents() { |
deps/lld/ELF/SyntheticSections.h+2-1| ... | ... | @@ -103,7 +103,8 @@ private: |
| 103 | 103 | std::vector<CieRecord *> Cies; |
| 104 | 104 | |
| 105 | 105 | // CIE records are uniquified by their contents and personality functions. |
| 106 | llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord> CieMap; | |
| 106 | llvm::DenseMap<std::pair<ArrayRef<uint8_t>, SymbolBody *>, CieRecord *> | |
| 107 | CieMap; | |
| 107 | 108 | }; |
| 108 | 109 | |
| 109 | 110 | class GotSection : public SyntheticSection { |
deps/lld/include/lld/Driver/Driver.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | |
| 16 | 16 | namespace lld { |
| 17 | 17 | namespace coff { |
| 18 | bool link(llvm::ArrayRef<const char *> Args, | |
| 18 | bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly, | |
| 19 | 19 | llvm::raw_ostream &Diag = llvm::errs()); |
| 20 | 20 | } |
| 21 | 21 |
deps/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp-1| ... | ... | @@ -621,7 +621,6 @@ void ArchHandler_x86_64::applyFixupFinal( |
| 621 | 621 | // Fall into llvm_unreachable(). |
| 622 | 622 | break; |
| 623 | 623 | } |
| 624 | return; | |
| 625 | 624 | } |
| 626 | 625 | |
| 627 | 626 | void ArchHandler_x86_64::applyFixupRelocatable(const Reference &ref, |
deps/lld/test/ELF/eh-frame-padding-no-rosegment.s created+64| ... | ... | @@ -0,0 +1,64 @@ |
| 1 | // REQUIRES: x86 | |
| 2 | ||
| 3 | .cfi_startproc | |
| 4 | .cfi_personality 0x1b, bar | |
| 5 | .cfi_endproc | |
| 6 | ||
| 7 | .global bar | |
| 8 | .hidden bar | |
| 9 | bar: | |
| 10 | ||
| 11 | // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o | |
| 12 | ||
| 13 | // Check the size of the CIE (0x18 + 4) and FDE (0x10 + 4) | |
| 14 | // RUN: llvm-readobj -s -section-data %t.o | FileCheck --check-prefix=OBJ %s | |
| 15 | ||
| 16 | // OBJ: Name: .eh_frame | |
| 17 | // OBJ-NEXT: Type: | |
| 18 | // OBJ-NEXT: Flags [ | |
| 19 | // OBJ-NEXT: SHF_ALLOC | |
| 20 | // OBJ-NEXT: ] | |
| 21 | // OBJ-NEXT: Address: | |
| 22 | // OBJ-NEXT: Offset: | |
| 23 | // OBJ-NEXT: Size: | |
| 24 | // OBJ-NEXT: Link: | |
| 25 | // OBJ-NEXT: Info: | |
| 26 | // OBJ-NEXT: AddressAlignment: | |
| 27 | // OBJ-NEXT: EntrySize: | |
| 28 | // OBJ-NEXT: SectionData ( | |
| 29 | // OBJ-NEXT: 0000: 18000000 00000000 017A5052 00017810 | |
| 30 | // OBJ-NEXT: 0010: 061B0000 00001B0C 07089001 10000000 | |
| 31 | // OBJ-NEXT: 0020: 20000000 00000000 00000000 00000000 | |
| 32 | // OBJ-NEXT: ) | |
| 33 | ||
| 34 | // RUN: ld.lld %t.o -no-rosegment -o %t -shared | |
| 35 | ||
| 36 | // Check that .eh_frame is in the same segment as .text | |
| 37 | // RUN: llvm-readobj -l --elf-output-style=GNU %t | FileCheck --check-prefix=PHDR %s | |
| 38 | ||
| 39 | // PHDR: Segment Sections | |
| 40 | // PHDR: .text | |
| 41 | // PHDR-SAME: .eh_frame | |
| 42 | ||
| 43 | // Check that the CIE and FDE are padded with 0x00 and not 0xCC when the | |
| 44 | // .eh_frame section is placed in the executable segment | |
| 45 | // RUN: llvm-readobj -s -section-data %t | FileCheck %s | |
| 46 | ||
| 47 | // CHECK: Name: .eh_frame | |
| 48 | // CHECK-NEXT: Type: | |
| 49 | // CHECK-NEXT: Flags | |
| 50 | // CHECK-NEXT: SHF_ALLOC | |
| 51 | // CHECK-NEXT: ] | |
| 52 | // CHECK-NEXT: Address: | |
| 53 | // CHECK-NEXT: Offset: | |
| 54 | // CHECK-NEXT: Size: | |
| 55 | // CHECK-NEXT: Link: | |
| 56 | // CHECK-NEXT: Info: | |
| 57 | // CHECK-NEXT: AddressAlignment: | |
| 58 | // CHECK-NEXT: EntrySize: | |
| 59 | // CHECK-NEXT: SectionData ( | |
| 60 | // CHECK-NEXT: 0000: 1C000000 00000000 017A5052 00017810 | |
| 61 | // CHECK-NEXT: 0010: 061BBEFF FFFF1B0C 07089001 00000000 | |
| 62 | // CHECK-NEXT: 0020: 14000000 24000000 A8FFFFFF 00000000 | |
| 63 | // CHECK-NEXT: 0030: 00000000 00000000 | |
| 64 | // CHECK-NEXT: ) |
deps/lld/tools/lld/lld.cpp+1-1| ... | ... | @@ -103,7 +103,7 @@ int main(int Argc, const char **Argv) { |
| 103 | 103 | case Gnu: |
| 104 | 104 | return !elf::link(Args, true); |
| 105 | 105 | case WinLink: |
| 106 | return !coff::link(Args); | |
| 106 | return !coff::link(Args, true); | |
| 107 | 107 | case Darwin: |
| 108 | 108 | return !mach_o::link(Args); |
| 109 | 109 | default: |
src/zig_llvm.cpp+1-1| ... | ... | @@ -789,7 +789,7 @@ bool ZigLLDLink(ZigLLVM_ObjectFormatType oformat, const char **args, size_t arg_ |
| 789 | 789 | zig_unreachable(); |
| 790 | 790 | |
| 791 | 791 | case ZigLLVM_COFF: |
| 792 | return lld::coff::link(array_ref_args); | |
| 792 | return lld::coff::link(array_ref_args, false, diag); | |
| 793 | 793 | |
| 794 | 794 | case ZigLLVM_ELF: |
| 795 | 795 | return lld::elf::link(array_ref_args, false, diag); |