Commit Graph

10662 Commits

Author SHA1 Message Date
John Benediktsson
4adb10df47 std.builtin: removing unused arena allocator in StackTrace.format 2024-08-22 21:23:53 -07:00
John Benediktsson
c690537154 std.debug: remove allocator from std.debug.writeStackTrace() 2024-08-22 21:23:53 -07:00
Andrew Kelley
ee84deda98
Merge pull request #21095 from alexrp/mips64-tests
Get `mips64(el)-linux` working and start testing it
2024-08-22 20:09:08 -07:00
Andrew Kelley
205e17a73c
Merge pull request #21161 from jedisct1/mlkem-update
Update ML-KEM to the final specification
2024-08-22 12:54:40 -07:00
Josh Wolfe
febfcbd49d
std.json.WriteStream supports streaming long values directly to the underlying stream (#21155) 2024-08-22 08:26:14 -04:00
Jacob Young
31220b50b5 Dwarf: cleanup emitted debug info
* reduce iteration cost by not tracking unused entries
 * avoid emitting unused abbrevs to `.debug_abbrev`
 * get the compiler executable passing `llvm-dwarfdump --verify`
 * make it possible to skip `.debug_line` padding much more quickly
2024-08-22 08:44:08 +02:00
Frank Denis
b131b6dd36 Rename the namespace for ml_kem variants of Kyber to nist 2024-08-22 07:54:12 +02:00
Frank Denis
067ae04e0b Update ML-KEM to the final specification
NIST has published the final specification of ML-KEM, which adds
domain separation to the seed used to create the inner secret key.
2024-08-22 01:00:12 +02:00
mlugg
a0b03d7fff
std.Build.Step.TranslateC: propagate target, optimize, link_libc to created module 2024-08-21 19:13:26 +01:00
mlugg
7bbbbf8ffa compiler: fix losing ZIR instructions in main_struct_inst fields 2024-08-21 16:24:57 +01:00
mlugg
018262d537
std: update eval branch quotas after bdbc485
Also, update `std.math.Log2Int[Ceil]` to more efficient implementations
that don't use up so much damn quota!
2024-08-21 01:30:46 +01:00
mlugg
43fdd061f7
AstGen: incorporate extra information into source hashes
* Indices of referenced captures
* Line and column of `@src()`

The second point aligns with a reversal of the "incremental compilation"
section of https://github.com/ziglang/zig/issues/2029#issuecomment-645793168.
This reversal was already done as #17688 (46a6d50), with the idea to
push incremental compilation down the line. My proposal is to keep it as
comptime-known, and simply re-analyze uses of `@src()` whenever their
line/column change.

I think this decision is reasonable for a few reasons:

* The Zig compiler is quite fast. Occasionally re-analyzing a few
  functions containing `@src()` calls is perfectly acceptable and won't
  noticably impact update times.
* The system described by Andrew in #2029 is currently vaporware.
* The system described by Andrew in #2029 is non-trivial to implement.
  In particular, it requires some way to have backends update a single
  global in certain cases, without re-doing semantic analysis. There is
  no other part of incremental compilation which requires this.
* Having `@src().line` be comptime-known is useful. For instance, #17688
  was justified by broken Tracy integration because the source line
  couldn't be comptime-known.
2024-08-21 01:30:46 +01:00
mlugg
9cf8a7661f
compiler: handle eval branch quota in memoized calls
In a `memoized_call`, store how many backwards braches the call
performs. Add this to `sema.branch_count` when using a memoized call. If
this exceeds the quota, perform a non-memoized call to get a correct
"exceeded X backwards branches" error.

Also, do not memoize calls which do `@setEvalBranchQuota` or similar, as
this affects global state which must apply to the caller.

Change some eval branch quotas so that the compiler itself still builds correctly.

This commit manually changes a file in Aro which is automatically
generated. The sources which generate the file are not in this repo.
Upstream Aro should make the suitable changes on their end before the
next sync of Aro sources into the Zig repo.
2024-08-21 01:26:55 +01:00
Ian Johnson
0a70455095 Fix handling of empty XDG environment variables
Closes #21132

According to the XDG Base Directory specification
(https://specifications.freedesktop.org/basedir-spec/latest/#variables),
empty values for these environment variables should be treated the same
as if they are unset. Specifically, for the instances changed in this
commit,

> $XDG_DATA_HOME defines the base directory relative to which
> user-specific data files should be stored. If $XDG_DATA_HOME is either
> not set **or empty**, a default equal to $HOME/.local/share should be
> used.

and

> $XDG_CACHE_HOME defines the base directory relative to which
> user-specific non-essential data files should be stored. If
> $XDG_CACHE_HOME is either not set **or empty**, a default equal to
> $HOME/.cache should be used.

(emphasis mine)

In addition to the case mentioned in the linked issue, all other uses of
XDG environment variables were corrected.
2024-08-19 23:30:14 -07:00
Andrew Kelley
dffc8c44f9
Merge pull request #21115 from Snektron/build-system-asm
compilation and build system fixes
2024-08-19 21:49:29 -07:00
Meghan Denny
7071d1b3c2
std: add native cpu detection for apple m3 (#21116)
* std.c.darwin: add missing CPUFAMILY fields

* std.zig.system.detectNativeCpuAndFeatures: add missing darwin fields

* add comment so the prong isnt lost and easily discoverable during next llvm upgrade
2024-08-19 11:49:02 -07:00
Mohanavel S K
82b676ef79
Added Constants Related To Ioctl (sockios.h) 2024-08-19 20:21:26 +03:00
Robin Voetter
43f73af359
fix various issues related to Path handling in the compiler and std
A compilation build step for which the binary is not required could not
be compiled previously. There were 2 issues that caused this:

- The compiler communicated only the results of the emitted binary and
  did not properly communicate the result if the binary was not emitted.

  This is fixed by communicating the final hash of the artifact path (the
  hash of the corresponding /o/<hash> directory) and communicating this
  instead of the entire path. This changes the zig build --listen protocol
  to communicate hashes instead of paths, and emit_bin_path is accordingly
  renamed to emit_digest.

- There was an error related to the default llvm object path when
  CacheUse.Whole was selected. I'm not really sure why this didn't manifest
  when the binary is also emitted.

  This was fixed by improving the path handling related to flush() and
  emitLlvmObject().

In general, this commit also improves some of the path handling throughout
the compiler and standard library.
2024-08-19 19:09:11 +02:00
Matthew Lugg
54e48f7b7d
Merge pull request #21128 from mlugg/incremental
incremental: more progress
2024-08-19 06:30:54 +01:00
Andrew Kelley
cf9f8de661 update comment in init template
Unit tests are not run from the install step.

closes #21123
2024-08-18 14:23:49 -07:00
mlugg
de49a9a173
Zir: add instructions to fetch std.builtin types
This replaces the constant `Zir.Inst.Ref` tags (and the analagous tags
in `Air.Inst.Ref`, `InternPool.Index`) referring to types in
`std.builtin` with a ZIR instruction `extended(builtin_type(...))` which
instructs Sema to fetch such a type, effectively as if it were a
shorthand for the ZIR for `@import("std").builtin.xyz`.

Previously, this was achieved through constant tags in `Ref`. The
analagous `InternPool` indices began as `simple_type` values, and were
later rewritten to the correct type information. This system was kind of
brittle, and more importantly, isn't compatible with incremental
compilation of std, since incremental compilation relies on the ability
to recreate types at different indices when they change. Replacing the
old system with this instruction slightly increases the size of ZIR, but
it simplifies logic and allows incremental compilation to work correctly
on the standard library.

This shouldn't have a significant impact on ZIR size or compiler
performance, but I will take measurements in the PR to confirm this.
2024-08-18 18:10:59 +01:00
Alex Rønne Petersen
4320611e6d std.debug: Also disable stack traces on mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
812a444d55 std.c: Fix Sigaction struct for glibc on mips/mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
e2a4d7acfc std.c: Fix Stat struct for mips/mips64 on linux. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
ea38009f3d std.os.linux: Fix Stat struct for mips/mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
ed9a502dff std.os.linux: Fix rlimit_resource for mips64; move out of arch bits.
It is usually generic, so no point having it in arch bits.
2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
d4973c9922 std.os.linux: Fix syscall errno value handling for mips.
The kernel sets r7 to 0 (success) or -1 (error), and stores the result in r2.
When r7 is -1 and the result is positive, it needs to be negated to get the
errno value that higher-level code, such as errnoFromSyscall(), expects to see.

The old code was missing the check that r2 is positive, but was also doing the
r7 check incorrectly; since it can only be set to 0 or -1, the blez instruction
would always branch.

In practice, this fix is necessary for e.g. the ENOSYS error to be interpreted
correctly. This manifested as hitting an unreachable branch when calling
process_vm_readv() in std.debug.MemoryAccessor.
2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
bcf41c8594 std.os.linux: Fix E definition for mips64. 2024-08-18 07:27:23 +02:00
mlugg
7f2466e65f std.BoundedArray: add clear() 2024-08-17 18:50:10 -04:00
mlugg
89f02d1c10 std.zig.Zir: fix declaration traversal
The old logic here had bitrotted, largely because there were some
incorrect `else` cases. This is now implemented correctly for all
current ZIR instructions. This prevents instructions being lost in
incremental updates, which is important for updates to be minimal.
2024-08-17 18:50:10 -04:00
Jacob Young
f601aa780e Dwarf: fix and test allowzero pointers 2024-08-17 05:57:45 -04:00
Jacob Young
e9df5ab7f1 std: disable failing debug info test for self-hosted 2024-08-16 16:23:53 -04:00
Jacob Young
ef11bc9899 Dwarf: rework self-hosted debug info from scratch
This is in preparation for incremental and actually being able to debug
executables built by the x86_64 backend.
2024-08-16 15:22:55 -04:00
Andrew Kelley
11176d22f8
Merge pull request #21073 from alexrp/test-changes
`test`: QoL for port work, more mips re-enablement
2024-08-15 22:23:48 -07:00
Andrew Kelley
05c7968920
Merge pull request #21020 from alexrp/target-fixes
`std.Target`: Assorted corrections, plus cleanup around ELF/COFF machine types
2024-08-15 22:13:31 -07:00
Andrew Kelley
b917d778c6
Merge pull request #21056 from alexrp/start-fix-precedence
`start`: Avoid string concatenation in inline asm.
2024-08-15 22:10:59 -07:00
Igor Anić
72bcc3b7a5
std.tar: add writer (#19603)
Simplifies code in docs creation where we used `std.tar.output.Header`.
Writer uses that Header internally and provides higher level interface.
Updates checksum on write, handles long file names, allows setting mtime and file permission mode. Provides handy interface for passing `Dir.WalkerEntry`.
2024-08-15 22:05:53 -07:00
Linus Groh
708414aaf4 std.time.epoch: Fix comments referring to epoch as 1970-10-01 2024-08-15 17:54:27 -07:00
YANG Xudong
8e91c229e1
loongarch: fix asm to set thread pointer (#21086)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-15 15:40:44 -07:00
Alex Rønne Petersen
ab9628dd2c
start: Avoid concatenating strings for inline asm.
For csky, we can just always do the gb initialization. For riscv, the gp code is
temporarily pulled above the main switch until the blocking issue is resolved.
2024-08-15 10:56:32 +02:00
Alex Rønne Petersen
6db9ad7798
std.Target: Return the correct value for 32-bit sparc v9 in toElfMachine(). 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
9b5c992d31
std.Target: Return the correct value for elfiamcu in toElfMachine(). 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
550438653d
std.Target: Pull toCoffMachine()/toElfMachine() up from Arch to Target.
This enables them to give more correct results.

Contributes to #20771.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
b01c595d4a
std.coff: Capitalize MachineType.{Unknown,Thumb} for consistency. 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
ac9ca7d30c
std.coff: Remove MachineType.fromTargetCpuArch().
This does the same thing as std.Target.Cpu.Arch.toCoffMachine(). Just use that.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
65affb1c22
std.Target: Don't match PowerPC in Arch.toCoffMachine().
It's entirely unclear whether this should map to POWERPC or POWERPCFP, and as I
can find no evidence of people producing PE files for PowerPC since Windows NT,
let's just not make a likely-wrong guess. We can revisit this if the need ever
actually arises.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
b24fc35eeb
std.Target: Don't match big endian architectures in Arch.toCoffMachine().
All of these were mapping to types that are little endian. In fact, I can find
no evidence that either Windows or UEFI have ever been used on big endian
systems.
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
8516a6ab57
std.Target: Clean up Arch.toCoffMachine(). 2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
490b328127
std.Target: Fix Arch.toElfMachine() for mips.
EM_MIPS_RS3_LE is obsolete; all mips targets just use EM_MIPS.

Also, fun fact: EM_MIPS_RS3_LE is actually big endian!
2024-08-15 10:55:46 +02:00
Alex Rønne Petersen
6c27cab5b3
std.Target: Fix Arch.toElfMachine() for arc.
The arc tag means ARCv2.
2024-08-15 10:55:46 +02:00