14653 Commits

Author SHA1 Message Date
Andrew Kelley
65bea9ac07 LLVM 18 update: avoid passing vectors sometimes
LLVM now refuses to lower arguments and return values on x86 targets
when the total vector bit size is >= 512.

This code detects such a situation and uses byref instead of byval.
2024-05-08 19:37:28 -07:00
Andrew Kelley
21f1e76efe zig cc: update clang CLI data to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:28 -07:00
Andrew Kelley
d34fae26d5 LLVM 18 std lib updates and fixes
* some manual fixes to generated CPU features code. In the future it
  would be nice to make the script do those automatically.

* add to various target OS switches. Some of the values I was unsure of
  and added TODO panics, for example in the case of spirv CPU arch.
2024-05-08 19:37:28 -07:00
Andrew Kelley
6a018d3e65 update zig_clang C++ API wrapper bindings to LLVM 18
release/18.x branch, commit 78b99c73ee4b96fe9ce0e294d4632326afb2db42
2024-05-08 19:37:28 -07:00
Andrew Kelley
243ae3a6cb update for LLVM 18 new target data
New OSs:
* XROS
* Serenity
* Vulkan

Removed OSs:
* Ananas
* CloudABI
* Minix
* Contiki

New CPUs:
* spirv

The removed stuff is removed from LLVM but not Zig.
2024-05-08 19:37:28 -07:00
Andrew Kelley
e4029b9943 llvm-ar patch: update main function 2024-05-08 19:37:28 -07:00
Andrew Kelley
08329863e8 clang patch: update main function 2024-05-08 19:37:28 -07:00
Andrew Kelley
de72860de6 update ar and clang C++ files to LLVM 18 2024-05-08 19:37:28 -07:00
mlugg
db890dbae7 InternPool: eliminate var_args_param_type
This was a "fake" type used to handle C varargs parameters, much like
generic poison. In fact, it is treated identically to generic poison in
all cases other than one (the final coercion of a call argument), which
is trivially special-cased. Thus, it makes sense to remove this special
tag and instead use `generic_poison_type` in its place. This fixes
several bugs in Sema related to missing handling of this tag.

Resolves: #19781
2024-05-04 22:03:56 +01:00
Jacob Young
5bbb2f966a link: restore lost passthrough behavior
Fixes bug introduced by 3b5be9fb6e06f6494ca05fb087a2121e220beb3f
2024-05-04 11:03:45 -04:00
Andrew Kelley
16d368d0d2 introduce std.process.raiseFileDescriptorLimit 2024-05-03 21:03:29 -07:00
Andrew Kelley
a72292513e add std.Thread.Pool.spawnWg
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-03 20:58:02 -07:00
Jonathan Marler
a96b78c170 add std.zip and support zip files in build.zig.zon
fixes #17408

Helpful reviewers/testers include Joshe Wolfe, Auguste Rame, Andrew
Kelley and Jacob Young.

Co-authored-by: Joel Gustafson <joelg@mit.edu>
2024-05-03 16:58:53 -04:00
Ryan Liptak
b86c4bde64 Rename Dir.writeFile2 -> Dir.writeFile and update all callsites
writeFile was deprecated in favor of writeFile2 in f645022d16361865e24582d28f1e62312fbc73bb. This commit renames writeFile2 to writeFile and makes writeFile2 a compile error.
2024-05-03 13:29:22 -07:00
Jacob Young
3b5be9fb6e lld: use a response file on NameTooLong 2024-05-03 13:27:04 -07:00
Anton Lilja
20b9b54e6b
LLVM: Fix panic when using tagged union backed by enum with negative values 2024-05-02 14:15:44 +00:00
Antonio Gomes
5571c03a5a Sema: Don't generate runtime instructions on zirSplat if dest_ty doesn't have runtime bits 2024-05-02 13:57:28 +03:00
Jacob Young
e8dd79ca67 cbe: fix ub with integer @abs 2024-04-30 22:09:54 -07:00
Andrew Kelley
1c9bb6a79d C backend: avoid memcpy when len=0
As of Clang 18, calling memcpy() with a misaligned pointer trips UBSAN,
even if the length is zero. This unfortunately includes any call to
`@memcpy` when source or destination are undefined and the length is
zero.

This patch makes the C backend avoid calling memcpy when the length is
zero, thereby avoiding undefined behavior.

A zig1.wasm update will be needed in the llvm18 branch to activate this
code.
2024-04-30 10:00:53 -07:00
Alain Greppin
956f53beb0 NetBSD: avoid ldd error on executables. zig cc produce 4 PT_LOAD segments,
wheras on NetBSD, only 2 PT_LOAD are usually produced by other compilers
(tested with host gcc and clang).

    $ ldd -v main_4segs
    .../main_4segs: wrong number of segments (4 != 2)
    .../main_4segs: invalid ELF class 2; expected 1
2024-04-29 12:48:56 -07:00
Julian
4303400e47
Sema+llvm: properly implement Interrupt callconv
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2024-04-28 22:43:00 +00:00
Alexandre Janon
25f1526fe6
Fix ELF alignment for freestanding targets (#19766)
* Fix the ELF binaries for freestanding target created with the self-hosted linker.

    The ELF specification (generic ABI) states that ``loadable process segments must have congruent
    values for p_vaddr and p_offset, modulo the page size''. Linux refuses to load binaries that
    don't meet this requirement (execve() fails with EINVAL).
2024-04-28 11:45:50 +02:00
Nameless
aecd9cc6d1 std.posix.iovec: use .base and .len instead of .iov_base and .iov_len 2024-04-28 00:20:30 -07:00
antlilja
c231d94960 LLVM: Remove deprecated or soon to be deprecated constant expressions 2024-04-25 22:58:47 -07:00
zhylmzr
3648d7df19 fix: object size error in archive 2024-04-25 18:27:11 +02:00
David Rubin
b87baad0ff error on undefined end index 2024-04-23 19:25:49 +03:00
Travis Staloch
8af59d1f98 ComptimeStringMap: return a regular struct and optimize
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-22 15:31:41 -07:00
Jacob Young
5d745d94fb x86_64: fix C abi for unions
Closes #19721
2024-04-22 15:24:29 -07:00
Jakub Konka
6fd09f8d2d link/macho: make --verbose-link represent the actual linker line 2024-04-22 15:14:56 +02:00
Jakub Konka
a7e4d17226 link/macho: introduce Atom extras for out-of-band data 2024-04-22 12:21:37 +02:00
Jakub Konka
3c5e840732
Merge pull request #19714 from ziglang/elf-merge-strings
link/elf: implement string merging
2024-04-21 10:37:49 +02:00
Jakub Konka
da55af1cae link/elf: fix 32bit build 2024-04-21 00:27:16 +02:00
Jakub Konka
bc46a4d51e link/elf: create .comment section for build-lib and no-llvm 2024-04-20 23:36:42 +02:00
Jakub Konka
66253e5b51 link/elf: populate current Zig version in .comment; test 2024-04-20 23:36:42 +02:00
Jakub Konka
4931a291f8 link/elf: keep track of sh_entsize per MergeSubsection 2024-04-20 23:36:42 +02:00
Jakub Konka
2cc1623925 link/elf: fix parsing SHF_STRINGS section 2024-04-20 23:36:42 +02:00
Jakub Konka
63a40bff47 link/elf: actually commit merge sections 2024-04-20 23:36:42 +02:00
Jakub Konka
b5a781d19d link/elf: fix generating invalid section symbol index for merged sections 2024-04-20 23:36:41 +02:00
Jakub Konka
65492b3d52 link/elf: skip empty merge sections when resolving 2024-04-20 23:36:41 +02:00
Jakub Konka
9e0bca73e2 link/elf: implement string merging 2024-04-20 23:36:41 +02:00
Jakub Konka
09820a96b6 link/elf: move relocs indexes into Atom extras 2024-04-20 23:36:41 +02:00
Jakub Konka
13b403cbf7 link/elf: move fde record indexes into Atom extras 2024-04-20 23:36:41 +02:00
Jakub Konka
d5fdb7315f link/elf: port macho symbol extras handling 2024-04-20 23:36:41 +02:00
Jakub Konka
700644d35d link/elf: introduce Atom extras for out-of-band storage 2024-04-20 23:36:41 +02:00
Jacob Young
4daeffab4a Elf: fix missing dynrelocs on haiku 2024-04-20 15:40:01 -04:00
Jacob Young
de68a3ad43 Elf: fix unaligned segments on non-linux
Linux isn't the only OS that `mmap`s segments.
2024-04-20 14:48:06 -04:00
Jacob Young
ebce190321 llvm: fix debug info when running tests 2024-04-19 12:13:29 -07:00
Andrew Kelley
22a97cd235 std.Build: revert --host-target, --host-cpu, --host-dynamic-linker
This is a partial revert of 105db13536b4dc2affe130cb8d2eee6c97c89bcd.

As we learned from Void Linux packaging, these options are not actually
helpful since the distribution package manager may very well want to
cross-compile the packages that it is building.

So, let's not overcomplicate things. There are already the standard
options: -Dtarget, -Dcpu, and -Ddynamic-linker.

These options are generally provided when the project generates machine
code artifacts, however, there may be a project that does no such thing,
in which case it makes sense for these options to be missing. The Zig
Build System is a general-purpose build system, after all.
2024-04-18 03:02:13 -07:00
mlugg
21a6a1b0f2 Sema: cap depth of value printing in type names
Certain types (notably, `std.ComptimeStringMap`) were resulting in excessively
long type names when instantiated, which in turn resulted in excessively long
symbol names. These are problematic for two reasons:

* Symbol names are sometimes read by humans -- they ought to be readable.
* Some other applications (looking at you, xcode) trip on very long symbol names.

To work around this for now, we cap the depth of value printing at 1, as opposed
to the normal 3. This doesn't guarantee anything -- there could still be, for
instance, an incredibly long aggregate -- but it works around the issue in
practice for the time being.
2024-04-17 22:47:54 -07:00
David Rubin
187f0c1e26
Sema: correctly make inferred allocs constant
Resolves: #19677
2024-04-18 04:45:14 +00:00