Commit graph

76 commits

Author SHA1 Message Date
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Andrew Kelley
47a413361d Package.Fetch: fix handling of relative paths 2023-10-08 16:54:31 -07:00
Andrew Kelley
e5c2a7dbca finish hooking up new dependency tree logic
* add Module instances for each package's build.zig and attach it to the
  dependencies.zig module with the hash digest hex string as the name.
* fix incorrectly skipping the wrong packages for creating
  dependencies.zig
* a couple more renaming of "package" to "module"
2023-10-08 16:54:31 -07:00
Andrew Kelley
d0bcc390e8 get zig fetch working with the new system
* start renaming "package" to "module" (see #14307)
  - build system gains `main_mod_path` and `main_pkg_path` is still
    there but it is deprecated.
* eliminate the object-oriented memory management style of what was
  previously `*Package`. Now it is `*Package.Module` and all pointers
  point to externally managed memory.
* fixes to get the new Fetch.zig code working. The previous commit was
  work-in-progress. There are still two commented out code paths, the
  one that leads to `Compilation.create` and the one for `zig build`
  that fetches the entire dependency tree and creates the required
  modules for the build runner.
2023-10-08 16:54:31 -07:00
Ryan Liptak
020105d0dd Cache: Fix findPrefix when paths are slightly out of the ordinary
This makes Cache.findPrefix/findPrefixResolved use `std.fs.path.relative` instead of `std.mem.startsWith` when checking if a file is within a prefix. This fixes multiple edge cases around prefix detection:

- If a prefix path ended with a path separator, then the first character of the 'sub_path' would get cut off because the previous implementation assumed it was a path separator. Example: prefix: `/foo/`, file_path: `/foo/abc.txt` would see that they both start with `/foo/` and then slice starting from one byte past the common prefix, ending up with `bc.txt` instead of the expected `abc.txt`
- If a prefix contained double path separators after any component, then the `startsWith` check would erroneously fail. Example: prefix: `/foo//bar`, file_path: `/foo/bar/abc.txt` would not see that abc.txt is a sub path of the prefix `/foo//bar`
- On Windows, case insensitivity was not respected at all, instead the UTF-8 bytes were compared directly

This fixes all of the things in the above list (and possibly more).
2023-08-19 22:32:24 -07:00
Sahnvour
2ceeade99a std.Build: add support for deps .d file in Step.Run 2023-08-13 12:15:47 -07:00
mlugg
f26dda2117 all: migrate code to new cast builtin syntax
Most of this migration was performed automatically with `zig fmt`. There
were a few exceptions which I had to manually fix:

* `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten
* `@truncate`'s fixup is incorrect for vectors
* Test cases are not formatted, and their error locations change
2023-06-24 16:56:39 -07:00
r00ster91
6e84f46990 std: replace builtin.Version with SemanticVersion 2023-06-17 13:17:34 -07:00
Andrew Kelley
629f0d23b5
Merge pull request #15579 from squeek502/mem-delimiters
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-06-03 13:51:02 -07:00
kcbanner
9244e4fe2d cache: handle 0-length prefix paths in findPrefixResolved 2023-05-30 01:21:01 -07:00
Linus Groh
ba35eeb417 std.fs.file: Rename File.Lock enum values to snake case 2023-05-25 20:17:07 +01:00
Andrew Kelley
728ce2d7c1 tweaks to --build-id
* build.zig: the result of b.option() can be assigned directly in many
   cases thanks to the return type being an optional
 * std.Build: make the build system aware of the
   std.Build.Step.Compile.BuildId type when used as an option.
   - remove extraneous newlines in error logs
 * simplify caching logic
 * simplify hexstring parsing tests and use a doc test
 * simplify hashing logic. don't use an optional when the `none` tag
   already provides this meaning.
 * CLI: fix incorrect linker arg parsing
2023-05-16 20:39:01 -07:00
Ryan Liptak
815e53b147 Update all std.mem.tokenize calls to their appropriate function
Everywhere that can now use `tokenizeScalar` should get a nice little performance boost.
2023-05-13 13:45:04 -07:00
Jacob Young
6e292f66db Cache: fix unnecessary cache misses
With the old logic, it was possible for a bunch of processes to queue up
to update a cache entry, and then each to do so one at a time.  Now, it
rechecks whether there still a cache miss or another process has
completed the work in the interim.
2023-05-11 00:55:40 -04:00
Jacob Young
fae6290387 Cache: fix race condition
When checking a cache entry with no input files for a hit, if
`createFile` returned `error.WouldBlock` we would forget about the fact
that the file has been created, and all future checks will assume that a
cache hit has happened, even though one never has or does, leading to
rare `FileNotFound` errors trying the access the protected files.

This fix works by writing an extra byte to the manifest file to
distinguish hits and misses when there no input files to write.
2023-05-11 00:55:40 -04:00
Andrew Kelley
6261c13731 update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
zooster
bc8e1e1de4
Improvements to docs and text
* docs(std.math): elaborate on difference between absCast and absInt

* docs(std.rand.Random.weightedIndex): elaborate on likelihood

I think this makes it easier to understand.

* langref: add small reminder

* docs(std.fs.path.extension): brevity

* docs(std.bit_set.StaticBitSet): mention the specific types

* std.debug.TTY: explain what purpose this struct serves

This should also make it clearer that this struct is not supposed to provide unrelated terminal manipulation functionality such as setting the cursor position or something because terminals are complicated and we should keep this struct simple and focused on debugging.

* langref(package listing): brevity

* langref: explain what exactly `threadlocal` causes to happen

* std.array_list: link between swapRemove and orderedRemove

Maybe this can serve as a TLDR and make it easier to decide.

* PrefetchOptions.locality: clarify docs that this is a range

This confused me previously and I thought I can only use either 0 or 3.

* fix typos and more

* std.builtin.CallingConvention: document some CCs

* langref: explain possibly cryptic names

I think it helps knowing what exactly these acronyms (@clz and @ctz) and
abbreviations (@popCount) mean.

* variadic function error: add missing preposition

* std.fmt.format docs: nicely hyphenate

* help menu: say what to optimize for

I think this is slightly more specific than just calling it
"optimizations". These are speed optimizations. I used the word
"performance" here.
2023-04-23 21:06:21 +03:00
Andrew Kelley
34286530b7 Cache: fix multi-process race condition on macOS
This fixes `.INVAL => unreachable` being triggered by the cache system
on macOS when multiple processes race to create the same compilation.
The problem is that when two processes race to create a file, it
sometimes returns ENOENT even though that error code is nonsensical for
this situation.

Commit 2b0929929d purportedly solved this,
but it did not open the file with write permissions, leading to the
EINVAL panic later on. This commit remedies the situation by introducing
a loop and simply retrying when the ENOENT occurs.
2023-04-18 17:53:47 -07:00
mlugg
ccf670c2b0 Zir: implement explicit block_comptime instruction
Resolves: #7056
2023-04-12 12:06:19 -04:00
Andrew Kelley
717e2c8718 std.Build.Cache: make unit tests not depend on cwd
This makes them more resilient to being run multiple times by multiple
different processes at the same time.
2023-03-15 10:48:15 -07:00
Andrew Kelley
11de55d0dd std.Build.Cache: handle ENOENT on createFile race
Companion commit to 628fec41593a2d2eca8b504e4fe90de9823aeded
2023-03-15 10:48:15 -07:00
Andrew Kelley
2b0929929d std.Build.Cache: handle ENOENT on createFile race
There are no dir components, so you would think that this was
unreachable, however we have observed on macOS two processes racing
to do openat() with O_CREAT manifest in ENOENT.
2023-03-15 10:48:15 -07:00
Andrew Kelley
e0561ad79b std.Build.Cache.Directory: add a format() method 2023-03-15 10:48:13 -07:00
Ali Chraghi
75ff34db9e std.Build.Cache: remove 'test-filetimestamp.tmp' once timestamp returned 2023-03-03 13:50:44 -05:00
Andrew Kelley
0666322614 std.Build.Cache: remove debug log statements
Now that this API is used by the build system, these debug logs are
problematic because build scripts run in debug mode, making these logs
noisy output.
2023-02-13 06:42:25 -07:00
Andrew Kelley
9cb52ca6ce move the cache system from compiler to std lib 2023-02-13 06:42:25 -07:00
Renamed from src/Cache.zig (Browse further)