aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
AgeCommit message (Collapse)Author
2024-05-27Module: fix and improve progress reportingmlugg
* correctly report time spent analyzing function bodies * print fully qualified decl names * also have a progress node for codegen The downside of these changes is that it's a bit flickerey, but the upside is that it's accurate; you can see what the compiler's doing!
2024-05-27Compilation: only create progress nodes for work actually being doneAndrew Kelley
2024-05-27update the codebase for the new std.Progress APIAndrew Kelley
2024-05-26Merge pull request #20049 from ziglang/std.process.ChildAndrew Kelley
std: restructure child process namespace
2024-05-26Compilation: fix regressed assembly diagnosticsJacob Young
Regressed by #17947
2024-05-26std: restructure child process namespaceAndrew Kelley
2024-05-22Compilation: better cleanup of temporary filesJacob Young
The diag file did not get deleted on the success path and the dep file did not get deleted on the failure path.
2024-05-09handle visionos target OS tag in the compilerJakub Konka
* rename .xros to .visionos as agreed in the tracking issue * add support for VisionOS platform in the MachO linker
2024-05-08zig cc: -Wno-overriding-t-option was renamedAndrew Kelley
in LLVM commit 1c66d08b0137cef7761b8220d3b7cb7833f57cdb
2024-05-08libcxx: update to LLVM 18Andrew Kelley
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42 This adds the flag `-D_LIBCPP_HARDENING_MODE` which is determined based on the Zig optimization mode. This commit also fixes libunwind, libcxx, and libcxxabi to properly report sub compilation errors.
2024-05-03add std.Thread.Pool.spawnWgAndrew Kelley
This function accepts a WaitGroup parameter and manages the reference counting therein. It also is infallible. The existing `spawn` function is still handy when the job wants to further schedule more tasks.
2024-05-03Rename Dir.writeFile2 -> Dir.writeFile and update all callsitesRyan Liptak
writeFile was deprecated in favor of writeFile2 in f645022d16361865e24582d28f1e62312fbc73bb. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-05-03lld: use a response file on `NameTooLong`Jacob Young
2024-04-28std.posix.iovec: use .base and .len instead of .iov_base and .iov_lenNameless
2024-04-22ComptimeStringMap: return a regular struct and optimizeTravis Staloch
this patch renames ComptimeStringMap to StaticStringMap, makes it accept only a single type parameter, and return a known struct type instead of an anonymous struct. initial motivation for these changes was to reduce the 'very long type names' issue described here https://github.com/ziglang/zig/pull/19682. this breaks the previous API. users will now need to write: `const map = std.StaticStringMap(T).initComptime(kvs_list);` * move `kvs_list` param from type param to an `initComptime()` param * new public methods * `keys()`, `values()` helpers * `init(allocator)`, `deinit(allocator)` for runtime data * `getLongestPrefix(str)`, `getLongestPrefixIndex(str)` - i'm not sure these belong but have left in for now incase they are deemed useful * performance notes: * i posted some benchmarking results here: https://github.com/travisstaloch/comptime-string-map-revised/issues/1 * i noticed a speedup reducing the size of the struct from 48 to 32 bytes and thus use u32s instead of usize for all length fields * i noticed speedup storing KVs as a struct of arrays * latest benchmark shows these wall_time improvements for debug/safe/small/fast builds: -6.6% / -10.2% / -19.1% / -8.9%. full output in link above.
2024-04-12Autodoc: fix root module name in sources.tarIan Johnson
This was overlooked in #19458. Using the fully qualified name of each module usually makes sense, but there is one module where it does not, namely, the root module, since its name is `root`. The original Autodoc tar creation logic used `comp.root_name` for the root module back when it was the only module included in `sources.tar`, and that made sense. Now, we get the best of both worlds, using the proper root name for the root module while using the module name for the rest.
2024-04-08InternPool: remove slice from byte aggregate keysJacob Young
This deletes a ton of lookups and avoids many UAF bugs. Closes #19485
2024-03-30cbe: rewrite `CType`Jacob Young
Closes #14904
2024-03-30cbe: fix bugs revealed by an upcoming commitJacob Young
Closes #18023
2024-03-28Merge pull request #19399 from ypsvlq/mingwAndrew Kelley
mingw: support -municode
2024-03-28Autodoc: add all modules to sources.tarIan Johnson
Closes #19403 This commit adds all modules in the compilation to the generated `sources.tar` when using `-femit-docs` (including `std` and `builtin`). Additionally, it considers the main module when doing so, rather than the root module, so the behavior when running `zig test -femit-docs test.zig` is now correct.
2024-03-27mingw: support -municodeElaine Gibson
2024-03-26Zcu: eliminate `Decl.alive` fieldmlugg
Legacy anon decls now have three uses: * Type owner decls * Function owner decls * `@export` and `@extern` Therefore, there are no longer any cases where we wish to explicitly omit legacy anon decls from the binary. This means we can remove the concept of an "alive" vs "dead" `Decl`, which also allows us to remove the separate `anon_work_queue` in `Compilation`.
2024-03-25compiler: implement analysis-local comptime-mutable memorymlugg
This commit changes how we represent comptime-mutable memory (`comptime var`) in the compiler in order to implement the intended behavior that references to such memory can only exist at comptime. It does *not* clean up the representation of mutable values, improve the representation of comptime-known pointers, or fix the many bugs in the comptime pointer access code. These will be future enhancements. Comptime memory lives for the duration of a single Sema, and is not permitted to escape that one analysis, either by becoming runtime-known or by becoming comptime-known to other analyses. These restrictions mean that we can represent comptime allocations not via Decl, but with state local to Sema - specifically, the new `Sema.comptime_allocs` field. All comptime-mutable allocations, as well as any comptime-known const allocs containing references to such memory, live in here. This allows for relatively fast checking of whether a value references any comptime-mtuable memory, since we need only traverse values up to pointers: pointers to Decls can never reference comptime-mutable memory, and pointers into `Sema.comptime_allocs` always do. This change exposed some faulty pointer access logic in `Value.zig`. I've fixed the important cases, but there are some TODOs I've put in which are definitely possible to hit with sufficiently esoteric code. I plan to resolve these by auditing all direct accesses to pointers (most of them ought to use Sema to perform the pointer access!), but for now this is sufficient for all realistic code and to get tests passing. This change eliminates `Zcu.tmp_hack_arena`, instead using the Sema arena for comptime memory mutations, which is possible since comptime memory is now local to the current Sema. This change should allow `Decl` to store only an `InternPool.Index` rather than a full-blown `ty: Type, val: Value`. This commit does not perform this refactor.
2024-03-21std.Build.Cache: use an array hash map for filesAndrew Kelley
Rather than an ArrayList. Provides deduplication.
2024-03-20mingw: define _WIN32_WINNT when building CRTElaine Gibson
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-03-11Merge pull request #19174 from squeek502/lazy-resinatorAndrew Kelley
Lazily compile the `zig rc` subcommand and use it during `zig build-exe`, etc
2024-03-11std.builtin: make link mode fields lowercaseTristan Ross
2024-03-11Fix progress when multiple zig rc child processes are building resinatorRyan Liptak
2024-03-11Report the progress of lazily building zig rcRyan Liptak
jitCmd now takes a `server` option that will emit progress/errors via std.zig.Server when enabled.
2024-03-11Integrate resinator errors with Zig using std.zig.Server and ErrorBundleRyan Liptak
This takes the code that was previously in src/Compilation.zig to turn resinator diagnostics into Zig error bundles and puts it in resinator/main.zig, and then makes resinator emit the resulting error bundles via std.zig.Server (which is used by the build runner, etc). Also adds support for turning Aro diagnostics into ErrorBundles.
2024-03-11Lazily compile the `zig rc` subcommand and use it during `zig build-exe`Ryan Liptak
This moves .rc/.manifest compilation out of the main Zig binary, contributing towards #19063 Also: - Make resinator use Aro as its preprocessor instead of clang - Sync resinator with upstream
2024-03-10add missing field to module creationAndrew Kelley
Fixes a merge conflict with one of mlugg's recent branches.
2024-03-10fix 32 bit compilationAndrew Kelley
2024-03-10autodocs: fix root name and missing dir closeAndrew Kelley
2024-03-10-femit-docs: create main.wasm artifactAndrew Kelley
2024-03-10-femit-docs: creating sources.tarAndrew Kelley
It's always a good day when you get to use File.writeFileAll 😎
2024-03-10frontend: skeleton for creating autodocsAndrew Kelley
This time, unlike the old implementation, it properly does autodoc generation during the compilation pipeline, saving time.
2024-03-10better to use AST than ZIR for doc generationAndrew Kelley
2024-03-07Merge pull request #19190 from mlugg/struct-equivalenceAndrew Kelley
compiler: namespace type equivalence based on AST node + captures
2024-03-06feat: add support for --enable-new-dtags and --disable-new-dtagsDillen Meijboom
2024-03-06Package.Module: deduplicate identical builtin modulesmlugg
Previously, when multiple modules had builtin modules with identical sources, two distinct `Module`s and `File`s were created pointing at the same file path. This led to a bug later in the frontend. These modules are now deduplicated with a simple hashmap on the builtin source.
2024-03-01compiler: audit debug mode checksJacob Young
* Introduce `-Ddebug-extensions` for enabling compiler debug helpers * Replace safety mode checks with `std.debug.runtime_safety` * Replace debugger helper checks with `!builtin.strip_debug_info` Sometimes, you just have to debug optimized compilers...
2024-02-28use hash.addListOfBytes where applicableAndrew Kelley
2024-02-28add missing export symbol names to whole mode wasm cache hashAndrew Kelley
Fixes false positive cache hit.
2024-02-28make aro-based translate-c lazily built from sourceAndrew Kelley
Part of #19063. Primarily, this moves Aro from deps/ to lib/compiler/ so that it can be lazily compiled from source. src/aro_translate_c.zig is moved to lib/compiler/aro_translate_c.zig and some of Zig CLI logic moved to a main() function there. aro_translate_c.zig becomes the "common" import for clang-based translate-c. Not all of the compiler was able to be detangled from Aro, however, so it still, for now, remains being compiled with the main compiler sources due to the clang-based translate-c depending on it. Once aro-based translate-c achieves feature parity with the clang-based translate-c implementation, the clang-based one can be removed from Zig. Aro made it unnecessarily difficult to depend on with these .def files and all these Zig module requirements. I looked at the .def files and made these observations: - The canonical source is llvm .def files. - Therefore there is an update process to sync with llvm that involves regenerating the .def files in Aro. - Therefore you might as well just regenerate the .zig files directly and check those into Aro. - Also with a small amount of tinkering, the file size on disk of these generated .zig files can be made many times smaller, without compromising type safety in the usage of the data. This would make things much easier on Zig as downstream project, particularly we could remove those pesky stubs when bootstrapping. I have gone ahead with these changes since they unblock me and I will have a chat with Vexu to see what he thinks.
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-26compiler: JIT zig fmtAndrew Kelley
See #19063
2024-02-26move Zir to std.zig.ZirAndrew Kelley
Part of an effort to ship more of the compiler in source form.