60 Commits

Author SHA1 Message Date
Krzysztof Wolicki
14efbbfd89
std.Uri: change specifier for printing with scheme to semicolon ;
Fetch: print scheme when suggesting adding a ref to git URIs
2024-01-18 09:13:04 +02:00
cipharius
2e77956629 Accepts generic application/x-compressed in package fetch 2024-01-15 18:26:12 +02:00
Joel Gustafson
dbdee2d53c
ignore charset and boundary directives in content-type headers when fetching dependencies 2024-01-09 20:16:59 +00:00
Andrew Kelley
196ddf010c frontend: fix populateTestFunctions accessing the wrong module
The test runner reads the list of test function pointers from its own
builtin module, which is the root_mod, not main_mod.
2024-01-01 19:49:08 -07:00
Andrew Kelley
edccd68adf Package.Module: fix typo in default red-zone setting
oops, this was supposed to return true, not false.
2024-01-01 17:51:21 -07:00
Andrew Kelley
f256431838 fix compilation errors when enabling llvm 2024-01-01 17:51:20 -07:00
Andrew Kelley
0be97b5ae3 fix population of builtin.zig not making the parent dir 2024-01-01 17:51:20 -07:00
Andrew Kelley
a1236b32f9 libcxx: update to new Compilation API 2024-01-01 17:51:19 -07:00
Andrew Kelley
2596f5d925 update bin_file.options references in Sema
mainly pertaining to error return tracing
2024-01-01 17:51:19 -07:00
Andrew Kelley
f54471b54c compiler: miscellaneous branch progress
implement builtin.zig file population for all modules rather than
assuming there is only one global builtin.zig module.

move some fields from link.File to Compilation
move some fields from Module to Compilation

compute debug_format in global Compilation config resolution

wire up C compilation to the concept of owner modules

make whole cache mode call link.File.createEmpty() instead of
link.File.open()
2024-01-01 17:51:19 -07:00
Andrew Kelley
33cdf33b95 compiler: update many references to bin_file.options 2024-01-01 17:51:19 -07:00
Andrew Kelley
43720be04a frontend: fix stack protector option logic
Commit 97e23896a9168132b6d36ca22ae1af10dd53d80d regressed this behavior
because it made target_util.supportsStackProtector *correctly*
notice which zig backend is being used to generate code, while the
logic calling that function *incorrectly assumed* that .zig code is being
compiled, when in reality it might be only C code being compiled.

This commit adjusts the option resolution logic for stack protector so
that it takes into account the zig backend only if there is a zig
compilation unit. A separate piece of logic checks whether clang
supports stack protector for a given target.

closes #18009
closes #18114
closes #18254
2024-01-01 17:51:19 -07:00
Andrew Kelley
12de7e3472 WIP: move many global settings to become per-Module
Much of the logic from Compilation.create() is extracted into
Compilation.Config.resolve() which accepts many optional settings and
produces concrete settings. This separate step is needed by API users of
Compilation so that they can pass the resolved global settings to the
Module creation function, which itself needs to resolve per-Module
settings.

Since the target and other things are no longer global settings, I did
not want them stored in link.File (in the `options` field). That options
field was already a kludge; those options should be resolved into
concrete settings. This commit also starts to work on that, deleting
link.Options, moving the fields into Compilation and
ObjectFormat-specific structs instead. Some fields were ephemeral and
should not have been stored at all, such as symbol_size_hint.

The link.File object of Compilation is now a `?*link.File` and `null`
when -fno-emit-bin is passed. It is now arena-allocated along with
Compilation itself, avoiding some messy cleanup code that was there
before.

On the command line, it is now possible to configure the standard
library itself by using `--mod std` just like any other module. This
meant that the CLI needed to create the standard library module rather
than having Compilation create it.

There are a lot of changes in this commit and it's still not done. I
didn't realize how quickly this changeset was going to balloon out of
control, and there are still many lines that need to be changed before
it even compiles successfully.

* introduce std.Build.Cache.HashHelper.oneShot
* add error_tracing to std.Build.Module
* extract build.zig file generation into src/Builtin.zig
* each CSourceFile and RcSourceFile now has a Module owner, which
  determines some of the C compiler flags.
2024-01-01 17:51:18 -07:00
Jacob Young
3f2a65594e Compilation: cleanup hashmap usage 2024-01-01 13:38:30 -08: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
Andrew Kelley
a0c8d54823 add Package.Manifest.copyErrorsIntoBundle 2023-11-26 19:41:00 -07:00
Andrew Kelley
e357550610 update for the std.fs.Dir changes 2023-11-22 15:24:57 -07:00
mlugg
b355893438
compiler: correct unnecessary uses of 'var' 2023-11-19 11:11:49 +00:00
Ian Johnson
7048e93665 Package.Fetch.git: handle optional pkt-line LF
Addresses a comment in #17779 pointing out the inability to fetch the
upstream BoringSSL sources over Git. The reason for this is because the
Git server used in this case did not include the optional (but
recommended) LF terminator for textual pkt-line data. This commit
adjusts handling of textual pkt-line data so that it works both with and
without the optional trailing LF.
2023-11-12 05:11:23 -05:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young
d890e81761 mem: fix ub in writeInt
Use inline to vastly simplify the exposed API.  This allows a
comptime-known endian parameter to be propogated, making extra functions
for a specific endianness completely unnecessary.
2023-10-31 21:37:35 -04:00
Tobias Simetsreiter
d1230842ac add Fetch support for short compressed tar ext
these short extensions are common in a lot of
places, and should be treated like their double
versions
2023-10-24 13:49:28 -04:00
Nameless
363d0ee5e1
std.http: rename start->send and request->open to be more inline with operation 2023-10-21 20:52:59 -05:00
Andrew Kelley
777af14b57 Package.Manifest: fix bitrotted unit tests 2023-10-18 18:59:13 -07:00
DraagrenKirneh
1882ff95e7 Package.Manifest: add minimum_zig_version field 2023-10-18 18:58:58 -07:00
dweiller
f58811a58a package fetching: support .tar.zst archives 2023-10-17 19:02:00 -04:00
Andrew Kelley
ba656e5c9f zig fetch: add --debug-hash argument
This argument causes zig to print verbose hashing information to stdout,
which can be used to diff two different fetches and find out why the
hashes do not equal each other.
2023-10-16 18:15:47 -07:00
Andrew Kelley
b171a6f25d Package.Fetch: normalize path separators in symlinks
closes #17549
2023-10-16 16:47:47 -07:00
Andrew Kelley
b9f75a39d3 Package.Manifest: fix error message for paths
closes #17491
2023-10-12 10:47:22 -07:00
Andrew Kelley
1d1e5a8617 Package.Fetch: fix empty path and "." not including all
Related to #17491
2023-10-12 10:47:22 -07:00
Krzysztof Wolicki
8c6b0271cc Package.Fetch: wrap operations involving tmp_directory in a block
This makes tmp_directory close before calling renameTmpIntoCache which fixes occurences of those AccessDenied errors that aren't synonymous with PathAlreadyExists on Windows
2023-10-11 20:28:07 -07:00
Andrew Kelley
2ca7cc46c4 Package.Fetch: fix inclusions not working for directories
Oops, the loop was checking the wrong variable! Added a unit test.
2023-10-10 02:29:29 -07:00
Andrew Kelley
fa08e49f83 Package.Fetch: allow relative paths outside project root
Only for packages that come from the main package. Fetched packages
still cannot depend on paths outside their package root.
2023-10-09 22:01:18 -07:00
Andrew Kelley
95907cb795 restore progress reporting for package fetching 2023-10-08 21:14:30 -07:00
Andrew Kelley
5eb5d523b5 give modules friendly names for error reporting 2023-10-08 20:58:04 -07:00
Andrew Kelley
cd4397783f Package.Fetch: improved deletion algorithm
Instead of every file deletion being followed by a recursive attempt to
remove the parent directory, while walking the directory, every
directory that will have nonzero files deleted from it is tracked in an
array hash map.

After all the threads have finished deleting and hashing, the parent
thread sorts the "suspicious" directories by length, descending,
ensuring that children appear before parents, and then iterates over the
array hash map, attempting a rmdir operation on each. Any rmdir that
succeeds appends the parent directory to the map so that it will be
removed if empty.
2023-10-08 20:03:40 -07:00
Andrew Kelley
4a2cf38844 Package.Fetch: apply inclusion rules from build.zig.zon 2023-10-08 19:29:17 -07:00
Andrew Kelley
5e7c44a321 Package.Fetch: tighten up check for path outside root 2023-10-08 17:42:49 -07:00
Andrew Kelley
6d84caf727 move some package management related source files around 2023-10-08 17:29:55 -07:00
Andrew Kelley
7bae6d9064 fix dependencies.zig generation with no dependencies 2023-10-08 17:26:02 -07:00
Andrew Kelley
f0cc6f17a0 Package.Fetch: fix not making directory paths for symlinks 2023-10-08 17:21:08 -07:00
Andrew Kelley
1ad33f53fe give build.zig modules access to their dependencies' build.zig modules 2023-10-08 16:54:31 -07:00
Andrew Kelley
47a413361d Package.Fetch: fix handling of relative paths 2023-10-08 16:54:31 -07:00
Andrew Kelley
1fd95fc005 Package.Fetch: resolve instead of join relative paths
This prevents bogus "error: file exists in multiple modules" errors due
to file paths looking like:
```
note: root of module foo/freetype/
note: root of module foo/fontconfig/../freetype/
```

It also enables checking for dependency paths outside the root package.
2023-10-08 16:54:31 -07:00
Andrew Kelley
29156de120 CLI: fix only_core_functionality logic 2023-10-08 16:54:31 -07:00
Andrew Kelley
b2fefc8473 dependencies.zig: omit deps without hashes 2023-10-08 16:54:31 -07:00
Andrew Kelley
7b25d050e6 std.tar: fix creation of symlinks with omit_empty_directories 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
a232f7e8ec finish implementing the auto-generated dependencies.zig module 2023-10-08 16:54:31 -07:00
Andrew Kelley
e86b7fcca3 fix detection of build.zig file inside packages 2023-10-08 16:54:31 -07:00