aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
AgeCommit message (Collapse)Author
2023-11-26move Module.Decl.Index and Module.Namespace.Index to InternPoolMeghan Denny
2023-11-26Merge pull request #18105 from Vexu/translate-cAndrew Kelley
Use Aro's tokenizer in `translate-c`
2023-11-25translate-c: use Aro's tokenizerVeikka Tuominen
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-11-19compiler: correct unnecessary uses of 'var'mlugg
2023-11-13compilation: forbid PIE for dynamic librariesMichael Dusan
but allow for { .exe, .o, .a }. closes #17928
2023-11-12rework memory management of Module.Namespace hash mapsAndrew Kelley
The motivating problem here was a memory leak in the hash maps of Module.Namespace. The commit deletes more of the legacy incremental compilation implementation. It had things like use of orderedRemove and trying to do too much OOP-style creation and deletion of objects. Instead, this commit iterates over all the namespaces on Module deinit and calls deinit on the hash map fields. This logic is much simpler to reason about. Similarly, change global inline assembly to an array hash map since iterating over the values is a primary use of it, and clean up the remaining values on Module deinit, solving another memory leak. After this there are no more memory leaks remaining when using the x86 backend in a libc-less compiler.
2023-11-10move libssp into libcompiler_rtAndrew Kelley
closes #7265
2023-11-10Compilation: fix logic regarding needs_c_symbolsAndrew Kelley
2023-11-09Compilation: forward clang diagnostics to error bundlesJacob Young
2023-11-07Merge pull request #17771 from ehaas/mingw-aroAndrew Kelley
mingw: Use aro instead of clang for preprocessing import libs
2023-11-07Merge pull request #17873 from ziglang/elf-archiveJakub Konka
elf: implement archiving input object files
2023-11-06Compilation: unconditionally close open file handles for writable danceJakub Konka
2023-11-06frontend: fix -fsingle-threaded default detection logicAndrew Kelley
The logic in 509be7cf1f10c5d329d2b0524f2af6bfcabd52de assumed that `use_llvm` meant that the LLVM backend would be used, however, use_llvm is false when there are no zig files to compile, which is the case for zig cc. This logic resulted in `-fsingle-threaded` which made libc++ fail to compile for C++ code that includes the threading abstractions (such as LLVM).
2023-11-04Merge pull request #17844 from ziglang/elf-objectJakub Konka
elf: handle emitting relocatables and static libraries - humble beginnings
2023-11-04Compilation: take into account if LLVM is available in lib-building logicJakub Konka
2023-11-04Compilation: refactor logic for library-building capabilitiesAndrew Kelley
And mark the stage2_x86_64 backend as being capable of building compiler-rt and zig libc.
2023-11-03x86_64: fix std test failuresJacob Young
2023-11-03frontend: rip out Decl dependenciesAndrew Kelley
This incremental compilation logic will need to be reworked so that it does not depend on buried pointers - that is, long-lived pointers that are owned by non-top-level objects such as Decl. In the meantime, this fixes memory leaks since the memory management of these dependencies has bitrotted.
2023-11-03comp: remove CBE guards for aroEvan Haas
2023-10-28frontend: make Decl.zir_decl_index typedAndrew Kelley
This field had the wrong type. It's not a `Zir.Inst.Index`, it's actually a `Zir.OptionalExtraIndex`. Also, the former is currently aliased to `u32` while the latter is a nonexhaustive enum that gives us more type checking. This commit is preparation for making this field non-optional. Now it can be changed to `Zir.ExtraIndex` and then the compiler will point out all the places that the non-optional assumption is being violated.
2023-10-25cbe: update `DeclGen.decl_index` to support anon declsJacob Young
2023-10-23frontend: rework `@embedFile` for incremental compilationAndrew Kelley
This feature was made to work with the legacy incremental compilation mechanism which is being reworked. This commit regresses the ability to update files used with `@embedFile` while the compiler is running. In exchange, we get these benefits: * The embedded file contents are copied directly into InternPool rather than there being an extra allocation and memcpy. * The EmbedFile struct, which represents a long-lived object, is made more serialization friendly. * Eliminate the creation and use of a Decl as an anonymous decl. When implementing the new incremental compilation mechanism, functionality will need to be added back for handling `@embedFile`.
2023-10-23Merge pull request #17651 from Vexu/error-limitAndrew Kelley
Make distinct error limit configurable (attempt #2)
2023-10-21InternPool: store alignment of anon declsAndrew Kelley
Commit 5393e56500d499753dbc39704c0161b47d1e4d5c has a flaw pointed out by @mlugg: the `ty` field of pointer values changes when comptime values are pointer-casted. This commit introduces a new encoding which additionally stores the "original pointer type" which is used to store the alignment of the anonymous decl, and potentially other information in the future such as section and pointer address space. However, this new encoding is only used when the original pointer type differs from the casted pointer type in a meaningful way. I was able to make the LLVM backend and the C backend lower anonymous decls with the appropriate alignment, however I will need some help figuring out how to do this for the backends that lower anonymous decls via src/codegen.zig and the wasm backend.
2023-10-21make distinct error limit configurableVeikka Tuominen
Closes #786
2023-10-20Revert "make distinct error limit configurable"Andrew Kelley
This reverts commit 78855bd21866b515018259a2194e036e4b3120df. This commit did not replace uses of `Type.err_int` of which there are currently 60 uses. Re-opens #786
2023-10-20Merge pull request #17608 from squeek502/resinator-fixesAndrew Kelley
resinator: Fix `INCLUDE` var handling and sync with upstream
2023-10-20llvm: set PIE only for executablesMichael Dusan
closes #17575
2023-10-18Revert "Never implicitly add rpaths for each lib dir, add NixOS libdir to rpath"Andrew Kelley
This reverts commit d7b73af8f65bb891c8700ed47777144bb6f35fe1. I did not look at this closely enough. This is incorrect; it should not implicitly add rpaths for every library, and it should not disable the nice default of each_lib_path when compiling for the native OS. See #16062 where we are working on a follow-up improvement to this.
2023-10-18Error if an .rc file uses the 'preprocess only' or 'no preprocess' flagsRyan Liptak
2023-10-18Sync resinator with upstream and fix INCLUDE env var handlingRyan Liptak
The INCLUDE variable being used during `.rc` preprocessing was an accidental regression in https://github.com/ziglang/zig/pull/17412. Closes #17585. resinator changes: source_mapping: Protect against NUL bytes in #line filenames lex: Avoid recalculating column on every tab stop within string literals Proper error handling for failing to open cwd instead of `catch unreachable` Use platform-specific delimiter for INCLUDE env var parsing
2023-10-18compiler: fix LTO availability logicAndrew Kelley
Before this commit, the logic would fail with a "LTO not available" error if the user set `-fno-lto` which doesn't make sense. This commit corrects the logic to understand when the user is explicitly requesting to turn LTO off.
2023-10-18compiler: better default for valgrindAndrew Kelley
* Default to off when strip=true * Report an error when explicitly enabled but not supported for the target
2023-10-18Merge pull request #17524 from Vexu/aro-translate-cAndrew Kelley
Add ability to test Aro based `translate-c`
2023-10-17add c_frontend to translate-c cache hashVeikka Tuominen
2023-10-16make distinct error limit configurableVeikka Tuominen
Closes #786
2023-10-15Add preliminary support for Windows .manifest filesRyan Liptak
An embedded manifest file is really just XML data embedded as a RT_MANIFEST resource (ID = 24). Typically, the Windows-only 'Manifest Tool' (`mt.exe`) is used to embed manifest files, and `mt.exe` also seems to perform some transformation of the manifest data before embedding, but in testing it doesn't seem like the transformations are necessary to get the intended result. So, to handle embedding manifest files, Zig now takes the following approach: - Generate a .rc file with the contents `1 24 "path-to-manifest.manifest"` - Compile that generated .rc file into a .res file - Link the .res file into the final binary This effectively achieves the same thing as `mt.exe` minus the validation/transformations of the XML data that it performs. How this is used: On the command line: ``` zig build-exe main.zig main.manifest ``` (on the command line, specifying a .manifest file when the target object format is not COFF is an error) or in build.zig: ``` const exe = b.addExecutable(.{ .name = "manifest-test", .root_source_file = .{ .path = "main.zig" }, .target = target, .optimize = optimize, .win32_manifest = .{ .path = "main.manifest" }, }); ``` (in build.zig, the manifest file is ignored if the target object format is not COFF) Note: Currently, only one manifest file can be specified per compilation. This is because the ID of the manifest resource is currently always 1. Specifying multiple manifests could be supported if a way for the user to specify an ID for each manifest is added (manifest IDs must be a u16). Closes #17406 options
2023-10-12Add `zig rc` subcommand, a drop-in replacement for rc.exeRyan Liptak
Uses resinator under-the-hood (see https://github.com/ziglang/zig/pull/17069) Closes #9564
2023-10-10revert compiler_rt: no need to put it in a static libraryAndrew Kelley
This mostly reverts 6e0904504155d3cba80955c108116170fd739aec however it leaves intact the linker supporting both obj and lib files, and the frontend choosing which one to create.
2023-10-10Compilation: default to self-hosted backend when not using libllvmAndrew Kelley
When not using libllvm, it means the compiler is not capable of producing an object file or executable, making the self-hosted backends be a better default.
2023-10-10compiler_rt: no need to put it in a static libraryAndrew Kelley
It's simpler to link against compiler_rt.o directly.
2023-10-08give modules friendly names for error reportingAndrew Kelley
2023-10-08fix using the wrong allocator for modulesAndrew Kelley
2023-10-08use long-lived arena for `@cImport`-generated ModuleAndrew Kelley
2023-10-08CLI: finish updating module API usageAndrew Kelley
Finish the work started in 4c4fb839972f66f55aa44fc0aca5f80b0608c731. Now the compiler compiles again. Wire up dependency tree fetching code in the CLI for `zig build`. Everything is hooked up except for `createDependenciesModule` is not yet implemented.
2023-10-08get `zig fetch` working with the new systemAndrew Kelley
* start renaming "package" to "module" (see #14307) - build system gains `main_mod_path` and `main_pkg_path` is still there but it is deprecated. * eliminate the object-oriented memory management style of what was previously `*Package`. Now it is `*Package.Module` and all pointers point to externally managed memory. * fixes to get the new Fetch.zig code working. The previous commit was work-in-progress. There are still two commented out code paths, the one that leads to `Compilation.create` and the one for `zig build` that fetches the entire dependency tree and creates the required modules for the build runner.
2023-10-04comp: add support for -fdata-sectionsJakub Konka
2023-10-03C backend: start handling anonymous declsAndrew Kelley
Start keeping track of dependencies on anon decls for dependency ordering during flush() Currently this causes use of undefined symbols because these dependencies need to get rendered into the output.
2023-10-01CLI: fix -fno-clangAndrew Kelley
Aro/Clang detection logic treated `-fno-clang` the same as `-fclang`.