13672 Commits

Author SHA1 Message Date
Andrew Kelley
2b58978360 Revert "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"
This reverts commit 7161ed79c4abcaccdd56fe0b4fbd3d93472d41b8, reversing
changes made to 3f2a65594e1d3c0a4f4943a4ea522e8405db81e0.

Unfortunately, this sat in the PR queue too long and the merge broke the
zig1.wasm bootstrap process.
2024-01-01 17:49:57 -07:00
Andrew Kelley
7161ed79c4
Merge pull request #17824 from kcbanner/fixup_msvc_fmax
cbe: add a system for avoiding collisions with C compiler intrinsics
2024-01-01 15:36:16 -08:00
Jacob Young
3f2a65594e Compilation: cleanup hashmap usage 2024-01-01 13:38:30 -08:00
amp-59
27d4bf7534
Sema: Initialise want_safety for switch prong child block 2023-12-29 11:42:44 +00:00
cfillion
b0dba46800 Sema: fix merging stores instructions from a comptime struct value with -fstrip
The first instruction in the block was never checked resulting in `struct_is_comptime` being incorrectly cleared if there are no instructions before the first field of the comptime struct.

Fixes #17119
2023-12-28 14:44:26 +02:00
Jacob Young
5c2897e89f cbe: fix memory leaks 2023-12-23 02:08:59 -05:00
Jacob Young
d312665803 Sema: ensure slice_ptr produces the correct type
Closes #18345
2023-12-23 02:08:58 -05:00
Stefan Su
42ddf592dd
use casted_rhs instead of rhs so icmp works correctly for airShlSat 2023-12-22 14:51:41 +00:00
Andrew Kelley
225fe6ddbf Compilation: remove parent_compilation_link_libc
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-12-13 11:28:42 -08:00
Andrew Kelley
3d23ba9c35 Revert "Sema: forbid @breakpoint from being called at comptime"
This reverts commit f88b523065fbb8afbd723fd6e803ace0334b713c.

Let's please go through the language proposal process for this change. I
don't see any justification for this breaking change even in the commit
message.
2023-12-11 12:24:15 -07:00
Bogdan Romanyuk
f88b523065
Sema: forbid @breakpoint from being called at comptime 2023-12-11 17:52:19 +02:00
Veikka Tuominen
69195d0cd4 AstGen: add error for using inline loops in comptime only scopes 2023-12-08 16:54:32 -08:00
Jakub Konka
da417b851b elf: return error.FlushFailure in flushObject and flushStaticLib codepaths when found errors 2023-12-05 18:12:58 +01:00
Jakub Konka
418b042f49 elf: fix typo 2023-12-05 18:10:09 +01:00
Jakub Konka
d05db52616 elf: copy out committed ZigObject to a buffer when creating static lib 2023-12-05 17:29:26 +01:00
Jakub Konka
ab423bd63c elf: exit early with an error when parsing or init failed when flushing object/archive 2023-12-05 16:35:08 +01:00
Jakub Konka
ee1630beea elf: exit early with an error when parsing or init failed 2023-12-05 16:31:47 +01:00
Jakub Konka
205857e342 elf: refactor 2023-12-05 14:54:03 +01:00
Jakub Konka
e3592281da elf: escape invalid token string when reporting an error 2023-12-05 14:39:56 +01:00
Jakub Konka
e349bb2b66 elf: upcast e_shnum to u64 to check for valid ranges 2023-12-05 14:27:03 +01:00
Jakub Konka
b294103c7e elf: report malformed archive when parsing errors 2023-12-05 14:11:45 +01:00
Jakub Konka
52959bba7c elf: re-instate basic error reporting for LD script parser 2023-12-05 14:08:04 +01:00
Jakub Konka
2e1dd1e554 elf: move basic parse error reporting to SharedObject 2023-12-05 13:53:11 +01:00
Jakub Konka
3f42ed3ca2 elf: do not write ELF header if there were errors 2023-12-05 13:49:55 +01:00
Jakub Konka
af8621db2d elf: report error at the point where it is happening 2023-12-05 13:28:47 +01:00
Jacob Young
c70c333594 x86_64: fix packed struct field reuse 2023-12-04 13:31:54 -05:00
Jacob Young
bdb6546a8f x86_64: fix vector comparisions 2023-12-04 13:09:13 -05:00
Jacob Young
50993a8f08 x86_64: implement more operations on vectors with 1-bit elements 2023-12-04 01:29:07 -05:00
Jacob Young
485e20884c x86_64: implement movement for pointer vectors 2023-12-03 23:07:50 -05:00
Jacob Young
0be7c23f11 Coff: minor fixes
* Update the msdos stub to be eight bytes smaller, which moves the
   machine PE header field into the first 128 bytes of the file,
   allowing it to be matched by a binfmt_misc magic sequence.
   This allows the build system to get the correct error during exec.
 * Fix library name memory leaks in Sema.
2023-12-03 18:18:09 -05:00
Jacob Young
7c85ea65ba x86_64: "implement" aggregate_init for vectors 2023-12-03 13:55:31 -05:00
Jacob Young
82ba9b8560 print_air: fix printing of instruction indices 2023-12-03 11:36:23 -05:00
Jacob Young
e00f1397e3 x86_64: implement some todos 2023-12-03 10:24:03 -05:00
Jacob Young
014833b61f x86_64: implement more compliant vectors 2023-12-03 10:22:06 -05:00
Jacob Young
917b4ad5e0 x86_64: implement more atomic ops 2023-12-03 10:22:06 -05:00
Jacob Young
daf91ed8d1 Air: use typesafe Air.Inst.Index
I need some indices for a thing...
2023-12-03 02:05:06 -08:00
Jacob Young
bf5ab54510 test: test with -fstrip and fix failures
Closes #17513
2023-12-01 04:34:50 +00:00
Veikka Tuominen
39a966b0a4 Sema: improve error location for array cat/mul 2023-11-30 13:15:40 +02:00
David Rubin
1e42a3de89
Remove all usages of std.mem.copy and remove std.mem.set (#18143) 2023-11-29 16:03:02 -05:00
Luuk de Gram
596d1cd5a8
wasm-linker: support --no-gc-sections
By default we garbage-collect sections for Wasm to reduce size, as well
as finish linking quicker (as we have fewer things to do). However,
when the user specifies `--no-gc-sections` we ensure all resolved symbols
get marked and therefore do not get garbage collected.
This is supported in both incremental-mode and traditional linking.
2023-11-28 16:40:26 +01:00
Luuk de Gram
4be3cd2754
wasm-linker: support gc for wasm backend code
When using the Wasm backend, we will now also perform garbage collection
there, to ensure unreferenced symbols do not get parsed nor emit into
the final binary.
2023-11-28 15:47:07 +01:00
Luuk de Gram
8447d4fb1f
wasm-linker: handle debug info during gc
When we encounter a debug info symbol, we initially have to parse it
into an atom to find its relocations. We then go through its relocations
to find out if any of the target symbols are marked alive. When it
finds an alive symbol, we also mark the debug symbol as alive to ensure
this piece of debug info is emit to the binary. When it does not encounter
any alive symbols, the debug symbol remains dead and will be garbage-
collected during `allocateAtoms`.
2023-11-28 15:47:07 +01:00
Luuk de Gram
f7d4f72fd5
wasm-linker: Only emit name of referenced symbols 2023-11-28 15:47:07 +01:00
Luuk de Gram
6f7a9b3144
wasm-linker: deduplicate aliased functions
When multiple symbols point to the same function, we ensure any
other symbol other than the original will be discarded and point
to the original instead. This prevents emitting the same function
code more than once.
2023-11-28 15:47:07 +01:00
Luuk de Gram
8856ba7505
wasm-linker: parse symbols into atoms lazily
Rather than parsing every symbol into an atom, we now only parse them
into an atom when such atom is marked. This means garbage-collected
symbols will also not be parsed into atoms, and neither are discarded
symbols which have been resolved by other symbols. (Such as multiple
weak symbols).

This also introduces a binary search for finding the start index into
the list of relocations. This speeds up finding the corresponding
relocations tremendously as they're ordered ascended by address.

Lastly, we re-use the memory of atom's data as well as relocations
instead of duplicating it. This means we half the memory usage of
atom's data and relocations for linked object files. As we are
aware of decls and synthetic atoms, we free the memory of those
atoms indepedently of the atoms of object files to prevent double-frees.
2023-11-28 15:47:07 +01:00
Luuk de Gram
c986c6c90a
wasm-linker: do not merge unreferenced symbols
When a symbol is unreferenced and therefore garbage-collected, we do
not merge its specific section into the final binary.
2023-11-28 15:47:07 +01:00
Luuk de Gram
589aef1537
wasm-linker: mark symbols and its references
Symbols which are exported to the host, or contain the `NO_STRIP`
flag, will be marked. All symbols which are referenced by this symbol
are marked likewise. We achieve this by parsing all relocations of a
symbol, and then marking the symbol it points to within the relocation.
2023-11-28 15:47:06 +01:00
Luuk de Gram
f3626eb816
wasm-link: ensure TLS global when resolved
When a linked object contains references to the __tls_base symbol,
we lazily create this symbol. However, we wouldn't create the corresponding
Wasm global. This meant its address wasn't set correctly as well as fail
to output it into the `Names` section.
2023-11-28 15:47:03 +01:00
Andrew Kelley
2a32264533 package fetching: catch relative paths that resolve into cache dir
The logic here already caught the case when a dependency path tried to
escape out of the zig cache directory using up directories. However, it
did not catch the case when the relative path tried to reach into a
different path within the zig-cache. For example, if it asked for
"../../../blah" then it would be caught, but if it asked for "../blah"
then it would try to resolve as "zig-cache/p/blah" and probably result
in file-not-found, or perhaps resolve to a different package if someone
inadvertently used a valid package hash instead of "blah".

Now it correctly gives a "dependency path outside project" error,
however, still allows relative paths with up-dirs that were not fetched
via URL.
2023-11-28 04:14:41 -05:00
Bogdan Romanyuk
7fbbeae617
value: handle lazy_align and lazy_size in writeToPackedMemory 2023-11-27 12:35:29 +00:00