5229 Commits

Author SHA1 Message Date
Jimmi Holst Christensen
a0a2ce92ca std: Do not allocate the result for ChildProcess.init
Instead, just return ChildProcess directly. This structure does not
require a stable address, so we can put it on the stack just fine. If
someone wants it on the heap they should do.

  const proc = try allocator.create(ChildProcess);
  proc.* = ChildProcess.init(args, allocator);
2022-04-29 22:50:34 -04:00
Natalia Cholewa
0e49142ce4 std.SegmentedList: add constIterator 2022-04-29 14:48:49 -04:00
Stephen Gregoratto
2409041e62 Seccomp fixups re: #10717
- Add type annotation for AUDIT.current.
- Make unsupported archs a compile error.
2022-04-28 23:41:25 -04:00
Andrew Kelley
a242906696 compiler-rt: restore stage1 workaround
18d6523888ef08bc66eb808075d13c5e00b8fcf4 regressed compiler-rt tests for
stage1 because it removed a workaround. I updated the comment to better
explain what exactly the workaround is so that it won't happen again.
2022-04-28 20:39:33 -07:00
Andrew Kelley
18d6523888 compiler-rt: upgrade to stage2 fn ptr semantics 2022-04-28 17:11:14 -07:00
Andrew Kelley
c5e847744c Revert "Merge pull request #11214 from iddev5/ay-build-runner"
This reverts commit 75c9936737a6ba991d4ef187ddc9d51bc0ad0998, reversing
changes made to 7f13f5cd5f5a518638b15d7225eae2d88ec1efb5.

I don't think `runZigBuild` belongs in std.testing. We already have
`test/standalone/*` for this.

Additionally test names should explain what they are testing rather than
referencing GitHub issue numbers.
2022-04-28 14:12:32 -07:00
Andrew Kelley
3052597a73 Revert "std.testing: add writeZigFile for TmpDir"
This reverts commit 7f13f5cd5f5a518638b15d7225eae2d88ec1efb5.

I'd like to review this one before it goes in. This is an awfully
specific API that I don't think belongs in std.testing. Also I don't
want any code snippets in doc strings. We have doctests for that.
2022-04-28 11:20:53 -07:00
Andrew Kelley
9181c98225 std.build: fix dll-export-fns API
We have a pattern using `?bool` for the -f/-fno- style flags.

Fixup for 8e3add8736be683b450c2754bedb064811baed0e.
2022-04-28 11:13:33 -07:00
Andrew Kelley
360ecc1a2f
Merge pull request #11532 from ziglang/compiler-rt-math
compiler-rt math functions reorg
2022-04-28 13:34:38 -04:00
Jakub Konka
d5fcb50988 fmt: fix formatting of lib/std/x/net/bpf.zig 2022-04-28 18:34:37 +02:00
Veikka Tuominen
6d48600ea0
Merge pull request #10717 from gh-fork-dump/seccomp-bits
Add Seccomp bits for linux
2022-04-28 18:54:09 +03:00
Veikka Tuominen
75c9936737
Merge pull request #11214 from iddev5/ay-build-runner
std: explicitly handle error.UnexpectedExitCode in build_runner
2022-04-28 18:38:44 +03:00
matu3ba
7f13f5cd5f
std.testing: add writeZigFile for TmpDir
* remove need for manual string concatenation for building binaries in test blocks
* include small program snippet to show how to get binary path with subslicing
2022-04-28 18:37:30 +03:00
Erik Hugne
8e3add8736
std.build: make no_dll_export_fns accessible in build step 2022-04-28 18:34:15 +03:00
Erik Hugne
f7bc8900bf std.coff: parse out codebase and entrypoint from optionalheader 2022-04-28 18:31:20 +03:00
Andrew Kelley
f7f03c699d compiler-rt: provide actual sincos implementations 2022-04-27 22:37:07 -07:00
Andrew Kelley
0b2ed45f5f compiler-rt: inline sin and cos into sincos
This avoids the optimizer turning sincos into a recursive call to
itself.
2022-04-27 20:24:08 -07:00
Andrew Kelley
0ffe82e624 std: use float builtins instead of std.math 2022-04-27 19:35:28 -07:00
Andrew Kelley
1cd799317b compiler-rt: remove invalid test
This was leftover from testing std.math.sin
2022-04-27 18:28:33 -07:00
Andrew Kelley
51f8ce1825 compiler-rt: fix powerpc f128 suffix 2022-04-27 18:26:47 -07:00
Andrew Kelley
1ac21cdec5 compiler-rt: avoid symbol conflicts
Weak aliases don't work on Windows, so we avoid exporting the `l` alias
on this platform for functions we know will collide.
2022-04-27 18:14:44 -07:00
Andrew Kelley
09f1d62bdf add new builtin function @tan
The reason for having `@tan` is that we already have `@sin` and `@cos`
because some targets have machine code instructions for them, but in the
case that the implementation needs to go into compiler-rt, sin, cos, and
tan all share a common dependency which includes a table of data. To
avoid duplicating this table of data, we promote tan to become a builtin
alongside sin and cos.

ZIR: The tag enum is at capacity so this commit moves
`field_call_bind_named` to be `extended`. I measured this as one of
the least used tags in the zig codebase.

Fix libc math suffix for `f32` being wrong in both stage1 and stage2.
stage1: add missing libc prefix for float functions.
2022-04-27 16:45:23 -07:00
Andrew Kelley
087aedfa38 stage2: fix recent LLVM backend code
* std.math.snan: fix compilation error. Also make it and nan inline.
 * LLVM: use a proper enum type for float op instead of enum literal.
   Also various cleanups.
 * LLVM: use LLVMBuildVectorSplat for vector splat AIR instruction.
   - also the bindings had parameter order wrong
 * LLVM: additionally handle f16 lowering. For now all targets report OK
   but I think we will need to add some exceptions to this list.
2022-04-27 14:18:34 -07:00
Andrew Kelley
41dd2beaac compiler-rt: math functions reorg
* unify the logic for exporting math functions from compiler-rt,
   with the appropriate suffixes and prefixes.
   - add all missing f128 and f80 exports. Functions with missing
     implementations call other functions and have TODO comments.
   - also add f16 functions
 * move math functions from freestanding libc to compiler-rt (#7265)
 * enable all the f128 and f80 code in the stage2 compiler and behavior
   tests (#11161).
 * update std lib to use builtins rather than `std.math`.
2022-04-27 12:20:44 -07:00
Isaac Freund
6f4343b61a std: replace usage of std.meta.bitCount() with @bitSizeOf() 2022-04-27 11:10:52 +02:00
Isaac Freund
6c0719fd5f std.meta: deprecate bitCount() for @bitSizeOf() 2022-04-27 11:10:52 +02:00
Jimmi Holst Christensen
cea310c908 Remove usage of inline for from print_targets.cmdTargets
This function was one of the biggest zig functions in a debug build of
the compiler.

  $ bloaty stage3-debug/bin/zig -d symbols --tsv -n 10000000 |
      rg -v '(llvm|clang|std|lld|\(anonymous namespace\))::|\[section ' |
      sort -h -k 3

  ...
  translate_c.ast.renderNode                    86168   86219
  main.buildOutputType                         177959  178004
  InfoTable                                    184832  184870
  AArch64SVEIntrinsicMap                       188544  188596
  print_targets.cmdTargets__anon_4735          319156  319216
  __static_initialization_and_destruction_0()  486666  489582
  MatchTable1                                  621884  621997
  OperandMatchTable                           1139622 1139861
  MatchTable0                                 1899764 1900141
2022-04-26 17:52:21 -04:00
protty
18f3034629
std.Thread: ResetEvent improvements (#11523)
* std: start removing redundant ResetEvents

* src: fix other uses of std.Thread.ResetEvent

* src: add builtin.sanitize_thread for tsan detection

* atomic: add Atomic.fence for proper fencing with tsan

* Thread: remove the other ResetEvent's and rewrite the current one

* Thread: ResetEvent docs

* zig fmt + WaitGroup.reset() fix

* src: fix build issues for ResetEvent + tsan

* Thread: ResetEvent tests

* Thread: ResetEvent module doc

* Atomic: replace llvm *p memory constraint with *m

* panicking: handle spurious wakeups in futex.wait() when waiting for abort()

* zig fmt
2022-04-26 16:48:56 -05:00
Cody Tapscott
28c05b0a53 compiler_rt: Bypass fmodx impl. on stage2
This function is codegen'd incorrectly in stage2, since it fails to
generate the correct soft-float operations. This will be fixed once
issue #11161 is implemented
2022-04-25 19:38:59 -07:00
Cody Tapscott
96d86e3465 compiler_rt: Fix rounding edge case for __mulxf3 2022-04-25 17:21:09 -07:00
Cody Tapscott
f5540778b5 stdlib: Fix hex-float printing for f80 2022-04-25 17:21:09 -07:00
Cody Tapscott
d930e015c7 compiler_rt: Implement __divxf3 for f80 2022-04-25 17:21:09 -07:00
Cody Tapscott
6c0114e044 compiler_rt: Implement fmodx for f80 2022-04-25 17:21:05 -07:00
jagt
76311aebff std: fix crypto and hash benchmark 2022-04-24 23:01:06 -04:00
protty
963ac60918
std.Thread: Mutex and Condition improvements (#11497)
* Thread: minor cleanups

* Thread: rewrite Mutex

* Thread: introduce Futex.Deadline

* Thread: Condition rewrite + cleanup

* Mutex: optimize lock fast path

* Condition: more docs

* Thread: more mutex + condition docs

* Thread: remove broken Condition test

* Thread: zig fmt

* address review comments + fix Thread.DummyMutex in GPA

* Atomic: disable bitRmw x86 inline asm for stage2

* GPA: typo mutex_init

* Thread: remove noalias on stuff

* Thread: comment typos + clarifications
2022-04-23 19:35:56 -05:00
Morritz
daef82d06f
add GetProcessTimes binding to the kernel32.zig (#11488) 2022-04-23 16:58:27 -05:00
Jakub Konka
5da0e03553
Merge pull request #11480 from rabingaire/fix-child-process-hang-on-macos
Fix child process spawn on macos hangs with stdin, stdout behavior set to pipe
2022-04-22 07:26:51 +02:00
Jakub Konka
5c501e8dad
Merge pull request #11485 from ziglang/fix-4353 2022-04-22 06:34:06 +02:00
Jakub Konka
74bfb8ba07 pdb: fix resource mgmt 2022-04-21 21:53:29 +02:00
Yusuf Bham
41654a318d std.mem: add concatWithSentinel 2022-04-21 14:39:41 -04:00
Jakub Konka
bedd7efa2b debug: add smoke test 2022-04-21 11:51:38 +02:00
Jakub Konka
28ca203b71 debug: fix resource (de)allocation for Elf and Coff targets
With this change, it is now possible to safely call
`var di = std.debug.openSelfDebugInfo(gpa)`. Calling then
`di.deinit()` on the object will correctly free all allocated
resources.

Ensure we store the result of `mmap` with correct alignment.
2022-04-21 11:48:15 +02:00
Rabin Gaire
50ec55faaf ran zig fmt on changes 2022-04-21 14:12:08 +05:45
Rabin Gaire
4ece507b5a update test message and using unreachable keyword for unintended test code path 2022-04-21 13:28:41 +05:45
Andrew Kelley
f7596ae942 stage2: use indexes for Decl objects
Rather than allocating Decl objects with an Allocator, we instead allocate
them with a SegmentedList. This provides four advantages:
 * Stable memory so that one thread can access a Decl object while another
   thread allocates additional Decl objects from this list.
 * It allows us to use u32 indexes to reference Decl objects rather than
   pointers, saving memory in Type, Value, and dependency sets.
 * Using integers to reference Decl objects rather than pointers makes
   serialization trivial.
 * It provides a unique integer to be used for anonymous symbol names,
   avoiding multi-threaded contention on an atomic counter.
2022-04-20 17:37:35 -07:00
Andrew Kelley
4f527e5d36 std: fix missing hash map safety
There was a missing compile error for calling ensureUnusedCapacity
without a Context in the case that the Context is non-void.
2022-04-20 17:18:06 -07:00
Jakub Konka
96c1314443 debug: fix resource (de)allocation for MachO targets
With this change, it is now possible to safely call
`var di = std.debug.openSelfDebugInfo(gpa)`. Calling then
`di.deinit()` on the object will correctly free all allocated
resources.
2022-04-21 00:45:01 +02:00
Jakub Konka
26153ce73a dwarf: clean up allocations in std.dwarf module
While this code probably could do with some love and a redesign,
this commit fixes the allocations by making sure we explicitly
pass an allocator where required, and we use arenas for temporary
or narrowly-scoped objects such as a `Die` (for `Die` in particular,
not every `FormValue` will be allocated - we could duplicate, or
we can use an arena which is the proposal of this commit).
2022-04-21 00:06:52 +02:00
Rabin Gaire
d976456ef6 add test case for child_process spawn logic
tests creating a child process with stdin/stdout behavior set to
StdIo.Pipe.
2022-04-20 18:37:10 +05:45
Andrew Kelley
99112b63bd std.SegmentedList: breaking API changes
* Remove the Allocator field; instead it must be passed in as a
   parameter to any function that needs it.
 * Rename `push` to `append` and `pushMany` to `appendSlice` to match
   the conventions set by ArrayList.
2022-04-20 05:31:24 -07:00