aboutsummaryrefslogtreecommitdiff
path: root/src/link.zig
AgeCommit message (Collapse)Author
2024-03-26compiler: eliminate most usages of TypedValuemlugg
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-03-11std.builtin: make link mode fields lowercaseTristan Ross
2024-03-06feat: add support for --enable-new-dtags and --disable-new-dtagsDillen Meijboom
2024-02-27move `zig libc` command to be lazily builtAndrew Kelley
part of #19063 This is a prerequisite for doing the same for Resinator.
2024-02-21LLVM: Remove use of LLVM in Builderantlilja
2024-02-16std.os.windows: add error.UnrecognizedVolumeAndrew Kelley
Thanks to @matklad for finding this additional NTSTATUS possibility when calling GetFinalPathNameByHandle.
2024-02-02cli+build: handle -ObjC flag and route it to MachO linkerJakub Konka
2024-01-24macho: parse dependent dylibsJakub Konka
2024-01-19zig cc: expose clang precompiled C header supportXavier Bouchoux
see https://releases.llvm.org/17.0.1/tools/clang/docs/UsersManual.html#generating-a-pch-file syntax examples: `zig cc -x c-header test.h -o test.pch` `zig cc -include-pch test.pch main.c` `zig c++ -x c++-header test.h -o test.pch` `zig c++ -include-pch test.pch main.cpp`
2024-01-14compiler: move each_lib_rpath to frontendJan200101
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2024-01-09Add support for `--(no-)undefined-version`dhash
Co-authored-by: Motiejus Jakštys <motiejus@jakstys.lt> Co-authored-by: Jakub Konka <kubkon@jakubkonka.com> Co-authored-by: Samuel Cantero <scanterog@gmail.com> Co-authored-by: Giorgos Georgiou <giorgos.georgiou@datadoghq.com> Co-authored-by: Carl Åstholm <carl@astholm.se>
2024-01-01link: accept the update arena in flushAndrew Kelley
This branch introduced an arena allocator for temporary allocations in Compilation.update. Almost every implementation of flush() inside the linker code was already creating a local arena that had the lifetime of the function call. This commit passes the update arena so that all those local ones can be deleted, resulting in slightly more efficient memory usage with every compilation update. While at it, this commit also removes the Compilation parameter from the linker flush function API since a reference to the Compilation is now already stored in `link.File`.
2024-01-01restore -fno-emit-bin -femit-llvm-ir functionalityAndrew Kelley
Now, link.File will always be null when -fno-emit-bin is specified, and in the case that LLVM artifacts are still required, the Zcu instance has an LlvmObject.
2024-01-01move misc_errors from linker to CompilationAndrew Kelley
So that they can be referenced by getAllErrorsAlloc(). Fixes missing compile errors.
2024-01-01move eh_frame_hdr from link.File to CompilationAndrew Kelley
since it's accessed by Compilation. fixes an invalid check of bin_file==null
2024-01-01move force_undefined_symbols into CompilationAndrew Kelley
This field is needed by Compilation regardless of whether a link file is instantiated. Fixes an invalid check for bin_file=null.
2024-01-01Compilation: several branch regression fixesAndrew Kelley
* move wasi_emulated_libs into Compilation - It needs to be accessed from Compilation, which needs to potentially build those artifacts. * Compilation: improve error reporting for two cases - the setMiscFailure mechanism is handy - let's use it! * fix one instance of incorrectly checking for emit_bin via `comp.bin_file != null`. There are more instances of this that need to be fixed in a future commit. * fix renameTmpIntoCache not handling the case where it needs to make the "o" directory in the zig-cache directory. - while I'm at it, simplify the logic for handling the fact that Windows returns error.AccessDenied rather than error.PathAlreadyExists for failure to rename a directory over another one. * fix missing cache hash additions - there are still more to add in a future commit - addNonIncrementalStuffToCacheManifest is called when bin_file is always null, and then it incorrectly checks if bin_file is non-null and only then adds a bunch of stuff to the cache hash. It needs to instead add to the cache hash based on lf_open_opts.
2024-01-01compiler: push entry symbol name resolution into the linkerAndrew Kelley
This is necessary because on COFF, the entry symbol name is not known until the linker has looked at the set of global symbol names to determine which of the four possible main entry points is present.
2024-01-01linker: rename intermediary_basname to zcu_object_sub_pathAndrew Kelley
2024-01-01fix remaining compile errors except oneAndrew Kelley
2024-01-01move dll_export_fns and rdynamic to Compilation.ConfigAndrew Kelley
2024-01-01update codegen.llvm references to bin_file.optionsAndrew Kelley
2024-01-01fix a round of compile errors caused by this branchAndrew Kelley
2024-01-01compiler: miscellaneous branch progressAndrew Kelley
implement builtin.zig file population for all modules rather than assuming there is only one global builtin.zig module. move some fields from link.File to Compilation move some fields from Module to Compilation compute debug_format in global Compilation config resolution wire up C compilation to the concept of owner modules make whole cache mode call link.File.createEmpty() instead of link.File.open()
2024-01-01Compilation: redo whole vs incremental logic in create and updateAndrew Kelley
2024-01-01compiler: update many references to bin_file.optionsAndrew Kelley
2024-01-01remove parent_compilation_link_libcAndrew Kelley
2024-01-01linkers: update references to "options" fieldAndrew Kelley
2024-01-01update image_base referencesAndrew Kelley
2024-01-01linker: update link_mode referencesAndrew Kelley
2024-01-01move a large chunk of linker logic away from "options"Andrew Kelley
These options are only supposed to be provided to the initialization functions, resolved, and then computed values stored in the appropriate place (base struct or the object-format-specific structs). Many more to go...
2024-01-01WIP: move many global settings to become per-ModuleAndrew Kelley
Much of the logic from Compilation.create() is extracted into Compilation.Config.resolve() which accepts many optional settings and produces concrete settings. This separate step is needed by API users of Compilation so that they can pass the resolved global settings to the Module creation function, which itself needs to resolve per-Module settings. Since the target and other things are no longer global settings, I did not want them stored in link.File (in the `options` field). That options field was already a kludge; those options should be resolved into concrete settings. This commit also starts to work on that, deleting link.Options, moving the fields into Compilation and ObjectFormat-specific structs instead. Some fields were ephemeral and should not have been stored at all, such as symbol_size_hint. The link.File object of Compilation is now a `?*link.File` and `null` when -fno-emit-bin is passed. It is now arena-allocated along with Compilation itself, avoiding some messy cleanup code that was there before. On the command line, it is now possible to configure the standard library itself by using `--mod std` just like any other module. This meant that the CLI needed to create the standard library module rather than having Compilation create it. There are a lot of changes in this commit and it's still not done. I didn't realize how quickly this changeset was going to balloon out of control, and there are still many lines that need to be changed before it even compiles successfully. * introduce std.Build.Cache.HashHelper.oneShot * add error_tracing to std.Build.Module * extract build.zig file generation into src/Builtin.zig * each CSourceFile and RcSourceFile now has a Module owner, which determines some of the C compiler flags.
2024-01-01compiler: get the dynamic linker from the targetAndrew Kelley
instead of passing it to Compilation separately and storing it separately in the linker options.
2024-01-01zig build system: change target, compilation, and module APIsAndrew Kelley
Introduce the concept of "target query" and "resolved target". A target query is what the user specifies, with some things left to default. A resolved target has the default things discovered and populated. In the future, std.zig.CrossTarget will be rename to std.Target.Query. Introduces `std.Build.resolveTargetQuery` to get from one to the other. The concept of `main_mod_path` is gone, no longer supported. You have to put the root source file at the module root now. * remove deprecated API * update build.zig for the breaking API changes in this branch * move std.Build.Step.Compile.BuildId to std.zig.BuildId * add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions, std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and std.Build.TestOptions. * remove `std.Build.constructCMacro`. There is no use for this API. * deprecate `std.Build.Step.Compile.defineCMacro`. Instead, `std.Build.Module.addCMacro` is provided. - remove `std.Build.Step.Compile.defineCMacroRaw`. * deprecate `std.Build.Step.Compile.linkFrameworkNeeded` - use `std.Build.Module.linkFramework` * deprecate `std.Build.Step.Compile.linkFrameworkWeak` - use `std.Build.Module.linkFramework` * move more logic into `std.Build.Module` * allow `target` and `optimize` to be `null` when creating a Module. Along with other fields, those unspecified options will be inherited from parent `Module` when inserted into an import table. * the `target` field of `addExecutable` is now required. pass `b.host` to get the host target.
2023-12-13Compilation: remove parent_compilation_link_libcAndrew Kelley
This option is not needed since the link_libc flag can be set directly when creating compiler_rt. This fixes a problem where an immutable flag was being mutated in Sema.
2023-11-26os: expect ETIMEDOUT, ECONNRESET, ENOTCONN from recvfrom & read familyLauri Tirkkonen
reads on eg. connected TCP sockets can fail with ETIMEDOUT, and ENOTCONN happens eg. if you try to read a TCP socket that has not been connected yet. interestingly read() was already handling CONNRESET & TIMEDOUT, but readv(), pread(), and preadv() were somewhat inconsistent.
2023-11-26move Module.Decl.Index and Module.Namespace.Index to InternPoolMeghan Denny
2023-11-24spirv: add -fstructured-cfg optionRobin Voetter
This enables the compiler to generate a structured cfg even in opencl, even if it is not strictly required by the SPIR-V Kernel specification.
2023-10-26link: support exporting constant values without a DeclAndrew Kelley
The main motivating change here is to prevent the creation of a fake Decl object by the frontend in order to `@export()` a value. Instead, `link.updateDeclExports` is renamed to `link.updateExports` and accepts a tagged union which can be either a Decl.Index or a InternPool.Index.
2023-10-21codegen: implement lowering aligned anon declsJacob Young
2023-10-19link: initialize llvm before calling the llvm APIJacob Young
2023-10-04comp: add support for -fdata-sectionsJakub Konka
2023-10-03codegen: separate getAnonDeclVAddr into lowerAnonDecl and the formerJakub Konka
Implement the stub for Elf. I believe that separating the concerns, namely, having an interface function that is responsible for signalling the linker to lower the anon decl only, and a separate function to obtain the decl's vaddr is preferable since it allows us to handle codegen errors in a simpler way.
2023-10-03link: stub out getAnonDeclVAddrAndrew Kelley
2023-09-27Merge pull request #17284 from ziglang/elf-testsJakub Konka
elf: link against musl libc, add ELF test harness, dynamically allocate misc SHF_ALLOC sections
2023-09-26Add '--compress-debug-sections=zstd'LinuxUserGD
2023-09-26elf: properly close the output file when linkingJakub Konka
2023-09-25kubkon review changes: 3Michael Dusan
- make vendored settings failure unreachable - rename field `darwinSdkLayout` → `darwin_sdk_layout` - make `darwin_sdk_layout` optional
2023-09-25kubkon review changes: 1Michael Dusan
general: - rename `DarwinSdkLayout` → `DarwinSdkLayout` - drop `DarwinSdkLayout.installation` (not needed for darwin) - document struct inferSdkVersion: - use explicit allocator - avoid trying to infer SDK ver from vendored path