aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
AgeCommit message (Collapse)Author
2023-06-10CLI: introduce --verbose-intern-poolAndrew Kelley
and stop dumping to stderr without the user's consent.
2023-06-10InternPool: port most of value tagsJacob Young
2023-06-10Module: remove tmp_hack_arenaAndrew Kelley
This was only needed when pointers were not fully migrated to InternPool yet.
2023-06-10stage2: move opaque types to InternPoolAndrew Kelley
2023-06-10stage2: add tmp_hack_arena for the InternPool transitionAndrew Kelley
Temporarily used for some unfortunate allocations made by backends that need to construct pointer types that can't be represented by the InternPool. Once all types are migrated to be stored in the InternPool, this can be removed.
2023-06-10InternPool: add a dump functionAndrew Kelley
So we can see stats
2023-06-10stage2: start the InternPool transitionAndrew Kelley
Instead of doing everything at once which is a hopelessly large task, this introduces a piecemeal transition that can be done in small increments at a time. This is a minimal changeset that keeps the compiler compiling. It only uses the InternPool for a small set of types. Behavior tests are not passing. Air.Inst.Ref and Zir.Inst.Ref are separated into different enums but compile-time verified to have the same fields in the same order. The large set of changes is mainly to deal with the fact that most Type and Value methods now require a Module to be passed in, so that the InternPool object can be accessed.
2023-06-03Merge pull request #15579 from squeek502/mem-delimitersAndrew Kelley
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-05-29Merge pull request #15891 from mlugg/fix/dont-emit-fn-called-at-comptimeAndrew Kelley
Prevent analysis of functions only referenced at comptime
2023-05-30zig ld: handle `--library :path/to/lib.so`Motiejus Jakštys
`-l :path/to/lib.so` behavior on gcc/clang is: - the path is recorded as-is: no paths, exact filename (`libX.so.Y`). - no rpaths. The previous version removed the `:` and pretended it's a positional argument to the linker. That works in almost all cases, except in how rules_go[1] does things (the Bazel wrapper for Go). Test case in #15743, output: gcc rpath: 0x0000000000000001 (NEEDED) Shared library: [libversioned.so.2] 0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/x] gcc plain: 0x0000000000000001 (NEEDED) Shared library: [libversioned.so.2] zig cc rpath: 0x0000000000000001 (NEEDED) Shared library: [libversioned.so.2] 0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/x] zig cc plain: 0x0000000000000001 (NEEDED) Shared library: [libversioned.so.2] Fixes #15743 [1]: https://github.com/bazelbuild/rules_go
2023-05-29Prevent analysis of functions only referenced at comptimemlugg
The idea here is that there are two ways we can reference a function at runtime: * Through a direct call, i.e. where the function is comptime-known * Through a function pointer This means we can easily perform a form of rudimentary escape analysis on functions. If we ever see a `decl_ref` or `ref` of a function, we have a function pointer, which could "leak" into runtime code, so we emit the function; but for a plain `decl_val`, there's no need to. This change means that `comptime { _ = f; }` no longer forces a function to be emitted, which was used for some things (mainly tests). These use sites have been replaced with `_ = &f;`, which still triggers analysis of the function body, since you're taking a pointer to the function. Resolves: #6256 Resolves: #15353
2023-05-23std.sort: add pdqsort and heapsortAli Chraghi
2023-05-17rename omit_pkg_fetching_code to only_core_functionalityAndrew Kelley
No functional changes. This renames an internal build option to better reflect how it is used.
2023-05-17Merge pull request #15459 from motiejus/build-id-fullAndrew Kelley
stage2: implement `--build-id` styles
2023-05-16tweaks to --build-idAndrew Kelley
* build.zig: the result of b.option() can be assigned directly in many cases thanks to the return type being an optional * std.Build: make the build system aware of the std.Build.Step.Compile.BuildId type when used as an option. - remove extraneous newlines in error logs * simplify caching logic * simplify hexstring parsing tests and use a doc test * simplify hashing logic. don't use an optional when the `none` tag already provides this meaning. * CLI: fix incorrect linker arg parsing
2023-05-16stage2: implement --build-id stylesMotiejus Jakštys
2023-05-16CLI: fix stdin dumping behaviorAndrew Kelley
* no need to move `tmpFilePath` around * no need for calculating max length of `FileExt` tag name * provide a canonical file extension name for `FileExt` so that, e.g. the file will be named `stdin.S` instead of `stdin.assembly_with_cpp`. * move temp file cleanup to a function to reduce defer bloat in a large function. * fix bug caused by mixing relative and absolute paths in the cleanup logic. * remove commented out test and dead code
2023-05-16zig cc: support reading from non-filesMotiejus Jakštys
echo 'some C program' | $CC -x c - Is a common pattern to test for compiler or linker features. This patch adds support for reading from non-regular files. This will make at least one more Go test to pass.
2023-05-13std.mem: Rename splitFull/tokenizeFull to splitSequence/tokenizeSequenceRyan Liptak
I think this makes the name less ambiguous and more obvious that the suffix applies to the `delimiter`.
2023-05-13Update all std.mem.split calls to their appropriate functionRyan Liptak
Everywhere that can now use `splitScalar` should get a nice little performance boost.
2023-05-11setup spirv backend in behavior testsAli Chraghi
2023-04-28update codebase to use `@memset` and `@memcpy`Andrew Kelley
2023-04-25cbe: fix mutability issues with builtin test_functionsJacob Young
2023-04-21Merge pull request #15355 from mlugg/feat/liveness-control-flowAndrew Kelley
Liveness: control flow analysis and other goodies
2023-04-20fixes to the previous commitAndrew Kelley
* CompileStep: Avoid calling producesPdbFile() to determine whether the option should be respected. If the user asks for it, put it on the command line and let the Zig CLI deal with it appropriately. * Make the namespace of `std.dwarf.Format.dwarf32` no longer have a redundant "dwarf" in it. * Add `zig cc` integration for `-gdwarf32` and `-gdwarf64`. * Toss in a bonus bug fix for `-gdwarf-2`, `-gdwarf-3`, etc. * Avoid using default init values for struct fields unnecessarily. * Add missing cache hash addition for the new option.
2023-04-20Expose an option for producing 64-bit DWARF formatDavid Gonzalez Martin
This commit enables producing 64-bit DWARF format for Zig executables that are produced through the LLVM backend. This is achieved by exposing both command-line flags and CompileStep flags. The production of the 64-bit format only affects binaries that use the DWARF format and it is disabled on MacOS due to it being problematic. This commit, despite generating the interface for the Zig user to be able to tell the compile which format is wanted, is just implemented for the LLVM backend, so clang and the self-hosted backends will need this to be implemented in a future commit. This is an effort to work around #7962, since the emission of the 64-bit format automatically produces 64-bit relocations. Further investigation will be needed to make DWARF 32-bit format to emit bigger relocations when needed and not make the linker angry.
2023-04-20Liveness: add a liveness verification passJacob Young
This code only runs in a debug zig compiler, similar to verifying llvm modules.
2023-04-18compilation: fix generating coff debug info on -gnukcbanner
The issue with just passing `-gcodeview` is that it's not part of the `OPT_g_Group` in `clang/Driver/Options.td`, so it doesn't trigger debug info to be generated. Passing only `-g` is sufficient on MSVC, as there is logic in `Clang.cpp` which enables codeview if that is the default for the toolchain. Since the default for -gnu is not codeview, we do pass `-gcodeview` in that case.
2023-04-18Assembly file add soft float option for mips (#15340)hequn
2023-04-17compilation: fix non-zig compilations not using CacheMode.wholekcbanner
main: consume --debug-log argument even when logging is disabled
2023-04-12Autodoc usingnamespace (#15216)Loris Cro
* autodoc: init support for usingnamespace decls * autodoc: don't build autodoc when building zig2.c * autodoc: usingnamespace decls support in frontend (#15203) * autodoc: init support for usingnamespace decls * autodoc: usingnamespace decls support in frontend --------- Co-authored-by: Krzysztof Wolicki <46651553+der-teufel-programming@users.noreply.github.com>
2023-04-09spirv: cannot build libcRobin Voetter
SPIR-V cannot build libc, ssp, compiler-rt, etc at the time of this commit, so prevent trying to build them.
2023-04-09dont destroy old bin file on link openpath failureRobin Voetter
This was causing some crashes.
2023-04-07zig cc: complete the -wrap flag implementationAndrew Kelley
* use a set instead of a list * use of this flag currently requires LLD * add documentation * make it only a zig cc compatibility flag for now because I personally think this is an anti-feature.
2023-04-07add linker -wrap flagZach Cheung
2023-04-05Merge remote-tracking branch 'origin/master' into llvm16Andrew Kelley
2023-04-01link: handle -u flag in all linkersJakub Konka
Also clean up parsing of linker args - reuse `ArgsIterator`. In MachO, ensure we add every symbol marked with `-u` as undefined before proceeding with symbol resolution. Additionally, ensure those symbols are never garbage collected. MachO entry_in_dylib test: pass `-u _my_main` when linking executable so that it is not incorrectly garbage collected by the linker.
2023-03-25compilation: fixup linker_dynamicbase default in InitOptionskcbanner
2023-03-17Merge remote-tracking branch 'origin/master' into llvm16Andrew Kelley
2023-03-17main: add debug option to dump unoptimized llvm irJacob Young
2023-03-16Merge remote-tracking branch 'origin/master' into llvm16Andrew Kelley
2023-03-15add compile log output to build runnerAndrew Kelley
2023-03-15fix ZIR decoding of error notesAndrew Kelley
2023-03-15std.Build.RunStep: add maxrss, duration, and cached statusAndrew Kelley
2023-03-15stage2: avoid linux-only APIs on other operating systemsAndrew Kelley
2023-03-15compiler: update function accepts a std.Progress.NodeAndrew Kelley
This makes progress be exposed to the top-level caller of update(). I tossed in a bonus change: when the `zig build` subcommand sees exit code 2, it omits the "following command failed" line, and the build runner uses exit code 2 when there are compile errors. This tidies up the output on build failure by a little bit.
2023-03-15add builtin.zig_version_stringAndrew Kelley
sometimes this is more useful than SemanticVersion
2023-03-15std.zig.ErrorBundle: rework binary encodingAndrew Kelley
* Separate into a "WIP" struct and a "finished" struct. * Use a bit of indirection for error notes to simplify ergonomics of this data structure.
2023-03-15progress towards semantic error serializationAndrew Kelley
Introduces std.zig.ErrorBundle which is a trivially serializeable set of compilation errors. This is in the standard library so that both the compiler and the build runner can use it. The idea is they will use it to communicate compilation errors over a binary protocol. The binary encoding of ErrorBundle is a bit problematic - I got a little too aggressive with compaction. I need to change it in a follow-up commit to use some indirection in the error message list, otherwise iteration is too unergonomic. In fact it's so problematic right now that the logic getAllErrorsAlloc() actually fails to produce a viable ErrorBundle because it puts SourceLocation data in between the root level ErrorMessage data. This commit has a simplification - redundant logic for rendering AST errors to stderr has been removed in favor of moving the logic for lowering AST errors into AstGen. So even if we get parse errors, the errors will get lowered into ZIR before being reported. I believe this will be useful when working on --autofix. Either way, some redundant brittle logic was happily deleted. In Compilation, updateSubCompilation() is improved to properly perform error reporting when a sub-compilation object fails. It no longer dumps directly to stderr; instead it populates an ErrorBundle object, which gets added to the parent one during getAllErrorsAlloc(). In package fetching code, instead of dumping directly to stderr, it now populates an ErrorBundle object, and gets properly reported at the CLI layer of abstraction.
2023-03-15stage2: hot code swapping PoCAndrew Kelley
* CLI supports --listen to accept commands on a socket * make it able to produce an updated executable while it is running