Commit Graph

22259 Commits

Author SHA1 Message Date
Veikka Tuominen
6e067dc050 llvm: do not offset packed struct field pointers if they have a host size
Closes #14261
2023-01-17 20:28:42 +02:00
Manlio Perillo
06e9b2c4e3 langref: document UTF-8 BOM handling
The current compiler ignores the UTF-8 BOM if it is at the start of the
file, and disallows it anywhere else.  Document it in the Source Encoding
section.
2023-01-17 20:07:53 +02:00
Andrew Kelley
7b68b76326 CI: additionally test debug builds on Windows 2023-01-17 13:06:07 -05:00
Manlio Perillo
0973f36389 langref: add the new addrspace keyword
Add the new addrspace keyword in the Keyword Reference section, without
documentation.

Move the linksection keyword in order to keep the keywords list sorted.
2023-01-17 20:04:37 +02:00
Andrew Kelley
f3107e2cb2
Merge pull request #14344 from ziglang/config-header-step
zig build: enhance LibExeObjStep and ConfigHeaderStep
2023-01-17 08:10:36 -05:00
Andrew Kelley
f4b4e570d8
Merge pull request #14229 from star-tek-mb/wincerts
windows root certificate scanning
2023-01-17 07:35:25 -05:00
Andrew Kelley
65586b9869 std.build.LibExeObjStep: change installHeader API
Now it always takes a dest_rel_path parameter, making it slightly more
verbose, and much more useful.
2023-01-17 00:45:04 -07:00
Andrew Kelley
6db3869fc7 std.build.ConfigHeaderStep: support cmake syntax
It's not fully implemented yet, for example `@FOO@` syntax is not
handled.
2023-01-17 00:44:57 -07:00
Andrew Kelley
d35d086ae6 std.crypto.Certificate: add more object id 2023-01-17 00:09:38 -07:00
Andrew Kelley
7623f3fad0 std.crypto.Certificate: skip unknown attributes 2023-01-17 00:09:34 -07:00
Andrew Kelley
86308ba1e1 std.net.getAddressList: call WSAStartup on Windows 2023-01-17 00:08:42 -07:00
Andrew Kelley
62e3fdcf4f std.crypto.Certificate: add more object ids 2023-01-17 00:08:42 -07:00
Andrew Kelley
09560bc69a clean up windows cert scanning
* keep helper functions out of the DLL bindings APIs
 * unify the logic for linux and windows certificate scanning with
   regards to error handling
2023-01-17 00:08:42 -07:00
star-tek-mb
1f9fa82235 windows root certificate scanning 2023-01-17 00:08:42 -07:00
Andrew Kelley
d56a65a8c4 std.http.Client: default to lazy root cert scanning
After this change, the system will be inspected for root certificates
only upon the first https request that actually occurs. This makes the
compiler no longer do SSL certificate scanning when running `zig build`
if no network requests are made.
2023-01-17 01:44:56 -05:00
Andrew Kelley
e646becd04
Merge pull request #14336 from Vexu/field-reorder
Sema: automatically optimize order of struct fields
2023-01-16 21:19:48 -05:00
Andrew Kelley
37424fd11a add std.build.LibExeObjStep.installHeadersDirectoryOptions
For when you need options such as excluding certain extensions.
2023-01-16 16:09:24 -07:00
fn ⌃ ⌥
e45b471ad3
Find system-installed root SSL certificates on macOS (#14325) 2023-01-16 22:34:04 +00:00
Veikka Tuominen
b2c85464be std.os.linux.io_uring: fix ABI error
`register_files_update` was passing a pointer to a Zig struct to the kernel.
2023-01-16 22:25:34 +02:00
Veikka Tuominen
342bae02d8 Sema: automatically optimize order of struct fields
This is a simple starting version of the optimization described in #168
where the fields are just sorted by order of descending alignment.
2023-01-16 19:46:41 +02:00
Loris Cro
b42bd759a7 autodoc: missing fmt on Autodoc.zig 2023-01-16 18:04:31 +01:00
Krzysztof Wolicki
ae69dfe6e7
autodoc: Better handling of variable decls (#14301) 2023-01-16 17:28:07 +01:00
Michael Bartnett
31a2b8c364
std: Handle field struct defaults in std.mem.zeroInit
I originally started monkeying with this because std.mem.zeroes doesn't support sentinel-terminated const slices even with defaults in 0.10.x.

I see that std.mem.zeroes was modified in #13256 to allow setting these slices to "".

That got me partway to where I wanted, but there was still an issue fields whose types are structs, they wouldn't get their defaults.

So when iterating struct fields looking for default values, when there is no default value and the type is .Struct, it will delegate to a call to zeroInit.

* Initialize struct fields in zeroInit exactly once

In my changes, similar to the previous implementation, the priority order for fields being initialized is:

1. If the `init` argument is a tuple, the nth element corresponding to the nth field of the struct.
2. Otherwise, if the `init` argument is not a tuple, try to find a matching field name on `init` and use that field.
3. Is the field has a default value, initalize with that value.
4. Fall back to what the field would have been initialized to via a recursive call to `std.mem.zeroInit`.

But instead of initializing a default instance of the struct and then running multiple passes over it, the init method is chosen per-field and each field is initialized exactly once.
2023-01-16 14:24:47 +02:00
Michael Bartnett
99febb54d3 Add fromOwnedSliceSentinel to ArrayList ArrayList and ArrayListUnmanaged, add fromOwnedSlice to ArrayListUnmanaged 2023-01-16 14:22:38 +02:00
r00ster91
3dd8f43ad3 std.Thread: make Id smaller where possible 2023-01-16 14:20:57 +02:00
Veikka Tuominen
4aa33da189
Merge pull request #14303 from perillo/improve-docgen
Improve docgen
2023-01-16 14:19:58 +02:00
Techatrix
32544ed56c
swap align and callconv in function typeName 2023-01-16 14:04:03 +02:00
Andrew Kelley
d389dba04f
Merge pull request #14329 from ziglang/v1-ssl-certificates
support v1/v2 SSL certificates and search more Linux directories for certificates
2023-01-16 00:24:03 -05:00
kcbanner
9856bea34e build: avoid zig's libc++ on *-windows-msvc 2023-01-15 18:29:02 -05:00
Andrew Kelley
e3505c0a5a std.crypto.Certificate.Bundle: add more Linux directories
Thanks to the Go project for finding all these paths.
2023-01-15 15:01:42 -07:00
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