Skip to content

implement the self-hosted LLVM backend #6541

Closed

Description

@andrewrk

Relevant source locations:

zig/src/Compilation.zig

Lines 416 to 431 in ab7ea53

// Make a decision on whether to use LLVM or our own backend.
const use_llvm = if (options.use_llvm) |explicit| explicit else blk: {
// If we have no zig code to compile, no need for LLVM.
if (options.root_pkg == null)
break :blk false;
// If we are the stage1 compiler, we depend on the stage1 c++ llvm backend
// to compile zig code.
if (build_options.is_stage1)
break :blk true;
// We would want to prefer LLVM for release builds when it is available, however
// we don't have an LLVM backend yet :)
// We would also want to prefer LLVM for architectures that we don't have self-hosted support for too.
break :blk false;
};

Here we will want to add link.File.LLVM, alongside ELF, WASM, Macho, COFF, etc.

zig/src/link.zig

Lines 152 to 164 in ab7ea53

pub fn openPath(allocator: *Allocator, options: Options) !*File {
const use_stage1 = build_options.is_stage1 and options.use_llvm;
if (use_stage1 or options.emit == null) {
return switch (options.object_format) {
.coff, .pe => &(try Coff.createEmpty(allocator, options)).base,
.elf => &(try Elf.createEmpty(allocator, options)).base,
.macho => &(try MachO.createEmpty(allocator, options)).base,
.wasm => &(try Wasm.createEmpty(allocator, options)).base,
.c => unreachable, // Reported error earlier.
.hex => return error.HexObjectFormatUnimplemented,
.raw => return error.RawObjectFormatUnimplemented,
};
}

Activity

  1. added
    enhancement
    frontend
    on Oct 4, 2020
  2. added this to the 0.8.0 milestone on Oct 4, 2020
  3. added
    contributor friendly
    on Oct 4, 2020
  4. added
    backend-llvm
    on Dec 29, 2020
  5. andrewrk commented on Dec 29, 2020

    @andrewrk
    MemberAuthor

    This was done by @FireFox317, landed in 2df2f00. Follow-up issues with the LLVM backend will be separate issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmcontributor friendlyenhancementfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions