Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminate dependency on LLD for COFF/PE #17751

Open
Tracked by #8726 ...
andrewrk opened this issue Oct 27, 2023 · 1 comment
Open
Tracked by #8726 ...

eliminate dependency on LLD for COFF/PE #17751

andrewrk opened this issue Oct 27, 2023 · 1 comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. linking os-windows
Projects
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Oct 27, 2023

Related:

Put simply, this issue can be closed when the following diff is applied:

--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -899,15 +899,13 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
 
         // Make a decision on whether to use LLD or our own linker.
         const use_lld = options.use_lld orelse blk: {
-            if (options.target.isDarwin()) {
-                break :blk false;
-            }
-
             if (!build_options.have_llvm)
                 break :blk false;
 
-            if (options.target.ofmt == .c)
-                break :blk false;
+            switch (options.target.ofmt) {
+                .c, .macho, .coff => break :blk false,
+                else => {},
+            }
 
             if (options.want_lto) |lto| {
                 if (lto) {
@squeek502
Copy link
Collaborator

squeek502 commented Oct 27, 2023

For resources, some preliminary investigation makes me think that we will want something similar to cvtres.exe to convert a .res file into a COFF object file, which is the actual thing that gets linked (here's the source for llvm-cvtres which AFAICT is responsible for this functionality in LLVM). I think this is something that would probably make the most sense to have in resinator (and outputting COFF object files is also something that windres supports, so there's precedence for this in alternative resource compilers).

I believe this would mean that the self-hosted linker would only need to care about normal COFF object files, with no special casing for .res files.

Relevant PE format docs: https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#the-rsrc-section

I've made a resinator issue here: squeek502/resinator#7

@andrewrk andrewrk added this to Ditch LLVM in Performance Oct 28, 2023
@andrewrk andrewrk modified the milestones: 0.15.0, 0.13.0 Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. linking os-windows
Projects
Performance
Ditch LLVM
Development

No branches or pull requests

2 participants