Commit graph

22529 commits

Author SHA1 Message Date
Andrew Kelley
9a0e1704ae std.crypto.Certificate: support v1
closes #14304
2023-01-15 14:59:49 -07:00
Veikka Tuominen
bb15e4057c
Merge pull request #14271 from Vexu/c-abi
float related C ABI fixes
2023-01-14 21:42:29 +02:00
Luuk de Gram
18191b80b6
Merge pull request #14302 from Luukdegram/wasm-ctor
wasm-linker: implement linking with WASI-libc
2023-01-14 17:58:09 +01:00
Veikka Tuominen
0013042cbd llvm: correctly handle C ABI structs with f32/f64 alignment differences
Closes #13830
2023-01-14 16:26:50 +02:00
Veikka Tuominen
5572c67e73 add C ABI tests for exotic float types 2023-01-14 16:26:50 +02:00
Veikka Tuominen
474848ac0b also run C ABI tests with -OReleaseFast 2023-01-14 16:26:50 +02:00
Manlio Perillo
29d7da519c build.zig: update the docs step
Update the docs step to use the new docgen command line.
2023-01-14 11:54:28 +01:00
Motiejus Jakštys
6b3f59c3a7 zig run/cc: recognize "-x language"
This commit adds support for "-x language" for a couple of hand-picked
supported languages. There is no reason the list of supported languages
to not grow (e.g. add "c-header"), but I'd like to keep it small at the
start.

Alternative 1
-------------

I first tried to add a new type "Language", and then add that to the
`CSourceFile`. But oh boy what a change it turns out to be. So I am
keeping myself tied to FileExt and see what you folks think.

Alternative 2
-------------

I tried adding `Language: ?[]const u8` to `CSourceFile`. However, the
language/ext, whatever we want to call it, still needs to be interpreted
in the main loop: one kind of handling for source files, other kind of
handling for everything else.

Test case
---------

*standalone.c*

    #include <iostream>

    int main() {
        std::cout << "elho\n";
    }

Compile and run:

    $ ./zig run -x c++ -lc++ standalone.c
    elho
    $ ./zig c++ -x c++ standalone.c -o standalone && ./standalone
    elho

Fixes #10915
2023-01-13 21:38:11 -05:00
Manlio Perillo
fde57330fa docgen: improve command-line argument parsing
Implement a simple command-line argument parser, adapted from the Zig
compiler implementation.

Promote the zig positional argument to an option.
2023-01-13 17:24:10 +01:00
Luuk de Gram
5468684456
wasm-linker: implement the __heap_end symbol
When any of the object files reference the __heap_end symbol, we will
create it as a synthetic symbol. The symbol only exists within the
linker and will not be emit within the binary as it's solely used for
relocations. The symbol represents where the heap ends, so allocators
can determine whether to allocate a new page or not.
2023-01-13 16:41:27 +01:00
Robert Burke
d813cef42a Fix buffer overflow in fmt when DAZ is set 2023-01-13 16:45:10 +02:00
Manlio Perillo
c5351a8d49 docgen: remove unnecessary and incorrect deallocations
The deallocations of the process arguments are unnecessary, since the
memory will be deallocated by arena.deinit().

The deallocations are incorrect, since ArgIterator.next() returns a
slice pointing to the iterator's internal buffer, that should be
deallocated with args_it.deinit().
2023-01-13 15:20:00 +01:00
kcbanner
0e659042ac ci: run the behaviour tests using the cbe and msvc 2023-01-13 04:05:49 -05:00
Andrew Kelley
7cb2f9222d
Merge pull request #14265 from ziglang/init-package-manager
Package Manager MVP
2023-01-12 18:49:15 -05:00
Luuk de Gram
c77ca91749
wasm-linker: implement __heap_base symbol
When any object files provides an undefined reference to the __heap_base
symbol, we create a new defined symbol for it. During setupMemory we
set the virtual address of this symbol so it can be used for relocations.
This symbol represents where the heap starts and allocators can use
this value for its allocations when it needs to determine where the heap
lives.
2023-01-12 20:50:18 +01:00
Luuk de Gram
f8d1efd99a
wasm-linker: implement __wasm_call_ctors symbol
This implements the `__wasm_call_ctors` symbol. This symbol is
automatically referenced by libc to initialize its constructors.
We first retrieve all constructors from each object file, and then
create a function body that calls each constructor based on its
priority. Constructors are not allowed to have any parameters, but are
allowed to have a return type. When a return type does exist, we simply
drop its value from the stack after calling the constructor to ensure
we pass the stack validator.
2023-01-12 20:50:18 +01:00
Luuk de Gram
1072f82acb
wasm-linker: Fix symbol name on undefined symbol
When emitting errors for undefined symbols, rather than
unconditionally always using the name from an import, we must verify
it's a symbol type that could have such an import. e.g. undefined
data symbols do not have a corresponding import. For this reason we
must use the regular name.
2023-01-12 20:50:18 +01:00
Luuk de Gram
2339b25fd4
wasm-linker: discard symbol when both undefined
During symbol resolution when both symbols are undefined, we must
discard the new symbol with a reference to the existing symbol. This
ensures the original symbol remains undefined. This fixes symbol
resolution when linking with WASI-libC.
2023-01-12 20:50:15 +01:00
Frank Denis
cbbf8c8a2d
wasi-libc: use __heap_end if available (#14273)
The symbol was introduced in LLD 15.0.7, as a way to know how
much memory can be allocated:

1095870e8c
https://github.com/WebAssembly/wasi-libc/pull/377
2023-01-12 13:48:14 +00:00
Loris Cro
4b32917646
Merge pull request #14275 from EspeuteClement/master
autodoc: use js instead of details for collapsing descriptions
2023-01-12 13:41:21 +01:00
Clement Espeute
66569c7ec6 autodoc: use js instead of details for collapsing descriptions 2023-01-12 13:38:26 +01:00
antlilja
4971df8572 UEFI pool allocator changes
* Changed the interface to align with the new allocator interface.
* Fixed bug where not enough memory was allocated for the header or to
  align the pointer.
2023-01-12 03:46:15 -05:00
Andrew Kelley
2a92b04b9d
Merge pull request #14257 from Vexu/compile-errors
compile error improvements and bug fixes
2023-01-12 03:39:01 -05:00
Andrew Kelley
f4d6b37068 Package: handle Windows PathAlreadyExists error code
Unfortunately, error.AccessDenied is ambiguous on Windows when it is
returned from fs.rename.
2023-01-11 17:54:34 -08:00
Andrew Kelley
2de0863380 use local cache dir for dependencies-listing package 2023-01-11 17:06:10 -08:00
Andrew Kelley
741445ce29 build.zig: use zig-provided libc++ by default on Windows 2023-01-11 17:05:14 -08:00
Andrew Kelley
4d306ebd32 fix std.io.Reader regression
oops. #14264
2023-01-11 15:39:49 -08:00
Andrew Kelley
476cbe871a fix build failures on 32-bit arm due to u64/usize coercion 2023-01-11 15:39:49 -08:00
Andrew Kelley
fe8951cc94 zig build: add Artifact.installHeadersDirectory
This one is useful for when the C library has a "include" directory but
it needs to get renamed to, e.g. "lame" when being installed.
2023-01-11 15:39:49 -08:00
Andrew Kelley
416717d04e zig build: support libraries aware of installed headers 2023-01-11 15:39:49 -08:00
Andrew Kelley
cfcf9771c1 zig build: support dependencies
The `zig build` command now makes `@import("@dependencies")` available
to the build runner package. It contains all the dependencies in a
generated file that looks something like this:

```zig
pub const imports = struct {
    pub const foo = @import("foo");
    pub const @"bar.baz" = @import("bar.baz");
};
pub const build_root = struct {
    pub const foo = "<path>";
    pub const @"bar.baz" = "<path>";
};
```

The build runner exports this import so that `std.build.Builder` can
access it. `std.build.Builder` uses it to implement the new `dependency`
function which can be used like so:

```zig
const libz_dep = b.dependency("libz", .{});
const libmp3lame_dep = b.dependency("libmp3lame", .{});
// ...
lib.linkLibrary(libz_dep.artifact("z"));
lib.linkLibrary(libmp3lame_dep.artifact("mp3lame"));
```

The `dependency` function calls the build.zig file of the dependency as
a child Builder, and then can be ransacked for its build steps via the
`artifact` function.

This commit also renames `dependency.id` to `dependency.name` in the
`build.zig.ini` file.
2023-01-11 15:39:49 -08:00
Andrew Kelley
a0f2e6a29f Package: complete the package-fetching logic 2023-01-11 15:39:49 -08:00
Andrew Kelley
876ab99f5c disable package manager code when bootstrapping
This makes building from source go faster and avoids tripping over
unimplemented things in the C backend.
2023-01-11 15:39:49 -08:00
Andrew Kelley
e0401498e9 package manager: compute hash, move tmp dir into global cache 2023-01-11 15:39:49 -08:00
Andrew Kelley
d4e829d0a0 std.tar: add strip_components option 2023-01-11 15:39:49 -08:00
Andrew Kelley
f104cfa1eb compiler: add package manager skeleton
see #943
2023-01-11 15:39:48 -08:00
Andrew Kelley
585b9970ef add std.tar for tar file unpacking 2023-01-11 15:39:48 -08:00
Andrew Kelley
4f6981bbe3 add std.Ini for basic .ini file parsing 2023-01-11 15:39:48 -08:00
Andrew Kelley
f945c2a1c8 expose std.io.bufferedReaderSize
This allows setting a custom buffer size. In this case I wanted it
because using a buffer size large enough to fit a TLS ciphertext record
elides a memcpy().

This commit also adds `readAtLeast` to the Reader interface.
2023-01-11 15:39:48 -08:00
Andrew Kelley
c50f65304f std.http.Client: support the Reader interface 2023-01-11 15:39:48 -08:00
Andrew Kelley
da6d79c47c water cooler complaint about gzip stream namespace 2023-01-11 15:39:48 -08:00
Eckhart Köppen
c2d37224c8 zig objcopy: Fix corrupted hex output
Do not return stack local data for hex record payload data.
2023-01-11 21:15:20 +02:00
Veikka Tuominen
d8128c272a Sema: fix typeInfo decls with usingnamespace
Closes #12403
2023-01-11 21:11:21 +02:00
Veikka Tuominen
1658e4893d AstGen: add note pointing to tuple field
Closes #14188
2023-01-11 21:11:21 +02:00
Veikka Tuominen
e2adf3b61a parser: add helpful note for missing const/var before container level decl
Closes #13888
2023-01-11 21:11:21 +02:00
Veikka Tuominen
8b1780d939 Sema: fix condition for omitting comptime arg from function type
Closes #14164
2023-01-11 21:11:21 +02:00
Loris Cro
0e66df2094 autodoc: scroll up when collapsing long fn description 2023-01-11 18:14:56 +01:00
Veikka Tuominen
ad259736e2 Value: implement more pointer eql cases
Closes #14234
2023-01-11 19:08:49 +02:00
Loris Cro
a88679453a
Merge pull request #14263 from der-teufel-programming/master
autodoc: Fix function pointers rendering issue
2023-01-11 17:33:09 +01:00
Der Teufel
669982c145 autodoc: Fix function pointers rendering issue 2023-01-11 03:31:16 +01:00