Commit Graph

19598 Commits

Author SHA1 Message Date
Jakub Konka 007eb3bd71 macho: fix some TODOs 2022-08-03 21:26:52 +02:00
Jakub Konka 2c8fc3b597 macho: add missing u64 to usize casts
Fixes 32bit builds.
2022-08-03 21:19:41 +02:00
Jakub Konka 90e3268270 macho: do not preempt segment headers; do it when commiting to file
This way, tracking segment-to-section mapping becomes a lot easier
since it's effectively just start index plus number of sections
defined within the segment. If a section becomes empty however
care needs to be taken to remove the header upon committing to the
final binary.
2022-08-03 21:19:41 +02:00
Jakub Konka 421d3e8d28 macho: add missing align cast in LoadCommandIterator 2022-08-03 21:19:41 +02:00
Jakub Konka 1e710396d4 macho: fix linking in incremental context
Fix incorrect writing of symtab and strtab in dSYM bundle in incremental
context.

Fix incorrectly navigating unnamed consts (freeing) in incremental context.
This is currently hard-coded to require all consts to land in `__TEXT,__const`,
which is wrong and needs a rewrite.
2022-08-03 21:19:41 +02:00
Jakub Konka 7bba3d330a macho: cleanup output section selection logic
Cache only section indexes used by the linker for synthetic sections
and/or incremental codepath.
2022-08-03 21:19:41 +02:00
Jakub Konka bb532584bc macho: update how we insert output sections
Instead of generating sections upfront, allow generation by scanning
the object files for input -> output sections mapping. Next, always
strive to keep output sections in the final container sorted as they
appear in the final binary. This makes the linker less messy wrt
handling of output sections sort order for dyld/macOS not to complain.
There's still more work to be done for incremental context though
to make this work but looks promising already.
2022-08-03 21:19:41 +02:00
Jakub Konka f26d5ee7ea macho: sync with zld
gitrev a2c32e972f8c5adfcda8ed2d99379ae868f59c24

https://github.com/kubkon/zld/commit/a2c32e972f8c5adfcda8ed2d99379ae868f59c24
2022-08-03 21:19:41 +02:00
Loris Cro 4c750016eb autodoc: inferred error unions in function return values 2022-08-03 17:21:56 +02:00
Loris Cro ecccf1f91f Add codeowners file for automated PR assignment
Added myself for Autodoc related files.
2022-08-03 16:26:53 +02:00
Loris Cro dd8ca27979 Merge pull request #12323 from ziglang/autodoc-issue-template
Update issue templates
2022-08-03 16:20:59 +02:00
Loris Cro c85bdbffa9 Update issue templates 2022-08-03 16:20:27 +02:00
Frank Denis fa321a07cd crypto.sign.ed25519: include a context string in blind key signatures (#12316)
The next revision of the specification is going to include a context
string in the way blinded scalars are computed.

See:
https://github.com/cfrg/draft-irtf-cfrg-signature-key-blinding/issues/30#issuecomment-1180516152
https://github.com/cfrg/draft-irtf-cfrg-signature-key-blinding/pull/37
2022-08-03 15:25:15 +02:00
Loris Cro 447a4cc115 autodoc: fix off-by-1 error in analysis of pointer types 2022-08-02 17:49:36 +02:00
Loris Cro c5afefec42 autodoc: fix autodoc analysis for @typeInfo
We were previously erroneously saving it as a `@TypeOf`.
2022-08-02 17:49:36 +02:00
Loris Cro 622714b76b autodoc: fix frontend crash while rendering std.mem
Previously we expected to only find decl refs in a `foo.bar.baz`
type of expression. This would crash when trying to render something
like `@typeInfo(T).Int.bits`. We now properly account for builtins
and other components.
2022-08-02 17:49:36 +02:00
Veikka Tuominen 14f0b70570 Sema: add safety for sentinel slice 2022-08-02 18:34:30 +03:00
Veikka Tuominen 292906fb23 Sema: fix reify Fn alignment and args 2022-08-02 18:33:03 +03:00
Veikka Tuominen 4831c1c65f Merge pull request #12277 from Vexu/stage2-compile-errors
Stage2: validate packed struct field types
2022-08-02 18:32:44 +03:00
Loris Cro 2375658da9 Merge pull request #12276 from r00ster91/shortdesc
autodoc: better short description algorithm
2022-08-02 16:32:08 +02:00
Loris Cro 9ba2377d64 Merge pull request #12305 from squeek502/autodoc-field-doc-borders
autodoc: Add borders to field docs to make it clear which field they are associated with
2022-08-02 16:30:12 +02:00
Veikka Tuominen e47706f344 Sema: validate packed struct field types 2022-08-01 23:59:40 +03:00
Veikka Tuominen f1768b40b2 stage2: better source location for var decls 2022-08-01 23:37:01 +03:00
Veikka Tuominen 57f9405a8f Sema: validate bitcast operand type 2022-08-01 23:37:01 +03:00
Ryan Liptak e7b6a18331 std.fs: Split Iterator.next on Linux and WASI to allow for handling platform-specific errors
Follow up to #12226, implements the compromise detailed in https://github.com/ziglang/zig/issues/12211#issuecomment-1196011590
2022-08-01 19:38:05 +03:00
Ikko Ashimine ff125db53d wasm: fix typo in CodeGen.zig
occured -> occurred
2022-07-31 13:00:37 -07:00
Ryan Liptak 1a1b7a3afd Linux: Add IN_MASK_CREATE and corresponding error handling in inotify_add_watch
From https://man7.org/linux/man-pages/man7/inotify.7.html

> **IN_MASK_CREATE** (since Linux 4.18)
>
> Watch pathname only if it does not already have a watch associated with it; the error EEXIST results if pathname is already being watched.
2022-07-31 13:00:16 -07:00
Cody Tapscott 075f93fa10 stage2 LLVM: Pass inline assembly outputs directly when not targeting memory
This change provides a basic implementation of #2349 for stage2. There's
still quite a lot of work before this logic is as complete as what's in
Clang (https://github.com/llvm/llvm-project/blob/b3645353041818f61e2580635409ddb81ff5a272/clang/lib/CodeGen/CGStmt.cpp#L2304-L2795),
particularly considering the diversity of constraints across targets.

It's probably not worth doing the complete work until there's a clearer
picture for constraints in Zig's future dedicated ASM syntax, but at
least this gives us a small improvement for now.

As a bonus, this also fixes a bug with how we were handling `_`
identifiers.
2022-07-31 12:59:19 -07:00
Andrew Kelley 1ab15b6c9c Merge pull request #12289 from Vexu/stage2
Stage2: reify functions + fixes
2022-07-31 12:57:53 -07:00
sin-ack b35490c217 cmake: Print all LLVM config errors instead of just the last one
If you have multiple llvm-config executables in your path, and all of
them cause failures, then only the last failure will be printed. This
can cause confusion when the multiple llvm-config executables are from
different major LLVM versions, i.e. LLVM 13 and 14, which might mask an
error that happened on the LLVM 14 llvm-config with an unrelated error.

This commit makes it so that all errors are collected into a list and
printed all at once; this way, you can see how each llvm-config
executable failed to configure properly. Note that the failures still
won't be printed if a successful configuration is found.
2022-07-31 12:56:00 -07:00
Ryan Liptak 921ba6cad4 autodoc: Add borders to field docs to make it clear which field they are associated with 2022-07-30 17:26:29 -07:00
Cody Tapscott c0a1b4fa46 stage2: Fix AIR printing
Packed structs never have comptime fields, and a slice might actually be
backed by a variable, which we need to catch before iterating its
elements.
2022-07-30 12:36:11 -07:00
Evan Haas 8632e4fc7b translate-c: use correct number of initializers for vectors
Fixes #12264
2022-07-30 13:24:03 +03:00
Veikka Tuominen 02dc073260 Sema: check comptime slice sentinel 2022-07-30 11:07:37 +03:00
Andrew Kelley 3cf8f283d3 Merge pull request #12085 from topolarity/dyn-link-libcpp
Dynamically link `libc++` if integrating with system LLVM
2022-07-29 14:18:32 -07:00
Veikka Tuominen d26d696ee0 parser: require expression after colon in slice expr 2022-07-30 00:18:08 +03:00
Veikka Tuominen 4758752e5d Sema: implement coercion from tuples to tuples
Closes #12242
2022-07-30 00:18:08 +03:00
Veikka Tuominen 17622b9db1 Sema: implement @Type for functions
Closes #12280
2022-07-30 00:18:08 +03:00
Veikka Tuominen f43ea43ac9 stage2: fix hashing of struct values
Closes #12279
2022-07-30 00:17:49 +03:00
Cody Tapscott 4fc2acdaa4 build.zig: Emit warning if "config.h" cannot be found
We now warn the user if config.h could not be located.

This also updates the search to stop early upon encountering a
`.git` directory, so that we avoid recursing outside of the zig
source if possible.
2022-07-29 11:38:58 -07:00
Wei Fu b3d0694fc5 stage1: remove deadcode ast_print
Fixes: 2a990d696 ("stage1: rework tokenizer to match stage2")
Fixes: b6354ddd5 ("move AST rendering code to separate file")

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-07-29 11:28:39 -07:00
Andrew Kelley 64dc1b05d6 Merge pull request #12286 from ziglang/division-safety
Division safety improvements
2022-07-29 11:03:27 -07:00
Andrew Kelley 932d1f785e CI: -Denable-llvm for test-cases
This requires using -Dstatic-llvm and setting the search prefix and the
target, just like it is required for building stage2 and stage3. This
prevents Zig from trying to integrate with the system, which would
trigger an error due to the `cc` command not being installed.

closes #12144
2022-07-29 11:03:12 -07:00
Andrew Kelley a7a6f38eeb Sema: fix runtime safety for integer overflow with vectors 2022-07-29 11:03:12 -07:00
Cody Tapscott 58540f968a ELF: Scan for dylibs-as-objects when adding rpaths
Shared libraries can be provided on the command line as if they were
objects, as a path to the ".so" file. The "each-lib-rpath" functionality
was ignoring these shared libraries accidentally, causing missing rpaths
in the output executable.
2022-07-29 09:44:45 -07:00
Andrew Kelley 1b1c70ce38 disable failing incremental compilation test case
see #12288

now `zig build test-cases -Denable-llvm` passes locally for me.
2022-07-29 02:35:06 -07:00
Andrew Kelley daac39364a fix compile error test case note column number 2022-07-29 02:35:06 -07:00
Andrew Kelley 40f8f0134f Sema: enhance div_trunc, div_exact, div_floor
* No longer emit div_exact AIR instruction that can produce a
   remainder, invoking undefined behavior.
 * div_trunc, div_exact, div_floor are extracted from analyzeArithmetic
   and directly handled similarly to div_trunc, integrating them with
   integer overflow safety checking.
 * Also they no longer emit divide-by-zero safety checking when RHS
   is comptime known to be non-zero.
2022-07-29 02:35:06 -07:00
Andrew Kelley 1fc24e8d80 Sema: enhance div instruction analysis
Concrete improvements:
 * Added safety for integer overflow (-MAX_INT/-1)
 * Omit division by zero safety check when RHS is comptime known to
   be non-zero.
 * Avoid emitting `_optimized` variants of AIR instructions for integers
   (this suffix is intended to be used for floats only).

Subjective changes: I extracted the div logic out from analyzeArithmetic
in order to reduce the amount of branches - not for performance reasons
but for code clarity. It is more lines of code however, and some logic
is duplicated.
2022-07-29 02:35:06 -07:00
Andrew Kelley a482517357 std.debug: default signal handler also handles SIGFPE 2022-07-29 02:35:06 -07:00