Commit Graph

12946 Commits

Author SHA1 Message Date
Jakub Konka
3df2ae1f9d macho: clean up writing of stub helper section 2021-03-17 12:10:39 +01:00
Jakub Konka
643b4898f5 macho: handle all jumps in stubs on aarch64 2021-03-17 12:10:39 +01:00
Jakub Konka
3019676440 macho: apply some renames to bring closer to zld 2021-03-17 12:10:39 +01:00
Ersikan
36db4b7cc4 test-cli: Remove temporary directory after tests 2021-03-17 10:27:41 +01:00
Ersikan
8942243f7a zig fmt: factorize source file reading and decoding
Now reading a source file and decoding it from UTF-16LE to UTF-8 is
done in a single function. Error messages are improved, and an error is
emitted when the source file has a BOM not supported (UTF-16BE, UTF-32).

Please note that the BOM of UTF-32 is composed of the same bytes as the
BOM of UTF-16 followed by a null character. Therefore a source file in
UTF-16LE starting with a null byte will be interpreted as an UTF-32, and
rejeted because of an invalid format. In pratice this is not a problem,
as the code would have been rejected later anyway because of the null
character.
2021-03-17 10:27:26 +01:00
Ersikan
a354000090 zig fmt: fix non-UTF-8 encoding #2820
Fixes #2820

After reading the source code, the first two bytes are inspected, and
if they correspond to a UTF-16 BOM in little-endian order, the source
code is converted to UTF-8.
2021-03-17 10:26:47 +01:00
Frank Denis
6d9b3e7b19 pbkdf2: use std.math.divCeil() 2021-03-17 10:11:47 +01:00
Evan Haas
f76bd56588 translate-c: fix __builtin_object_size
Previous code assumed `c_long` and `usize` were the same size.
Use `isize` instead.
2021-03-17 09:06:47 +02:00
Evan Haas
715370a10a translate-c: demote usage of un-implemented builtins 2021-03-17 09:06:47 +02:00
Andrew Kelley
4683de1e91
Merge pull request #8252 from tadeokondrak/llvm-bool
stage2 llvm bindings: use correct type for LLVMBool for ABI compat
2021-03-16 21:56:00 -07:00
Tadeo Kondrak
e8aa6f90d6
stage2 llvm bindings: use correct type for LLVMBool for ABI compat 2021-03-16 17:05:36 -06:00
Evan Haas
c558a1ae26 translate-c: Implement generic selection expressions
Enables translation of C code that uses the `_Generic` keyword
2021-03-17 00:07:33 +02:00
xackus
9a94415680 translate-c: improve std.meta.cast 2021-03-17 00:05:42 +02:00
jacob gw
83d0c2ed67 std: make all errors in os.zig public 2021-03-16 14:48:31 -07:00
Frank Denis
f609c4ddb3 crypto/pbkdf2: use snake_case for variables like everywhere else 2021-03-16 19:08:38 +01:00
Frank Denis
d1b1e542a0 crypto/pbkdf2: simplify the check for the max number of iterations 2021-03-16 18:55:58 +01:00
Lewis Gaul
6787f163eb
zig fmt: don't add trailing whitespace on switch case 2021-03-16 09:26:28 +01:00
LemonBoy
5ecf8bddae
zig fmt: Respect line breaks in struct default value decls
Bring this in line with how variable declarations are handled.

Open a new indentation level for the initialization expression to handle
nested expressions like blocks.

Closes #7618
2021-03-16 09:22:16 +01:00
Anders Conbere
f16f25047c
std: support optional getaddrinfo arguments 2021-03-16 01:10:32 +01:00
Lewis Gaul
aa1c780560 Add test for multi-line while cont expr with same-line then expr 2021-03-15 20:44:45 +01:00
Isaac Freund
48efa3bcb6 zig fmt: simplify and improve consistency of if/for/while handling
The main realization here was that getting rid of the early returns
in renderWhile() and rewriting the logic into a mostly unified execution
path took things from ~200 lines to ~100 lines and improved consistency
by deduplicating code.

Also add several test cases and fix a few issues along the way:

Fixes https://github.com/ziglang/zig/issues/6114
Fixes https://github.com/ziglang/zig/issues/8022
2021-03-15 14:55:34 +01:00
Lewis Gaul
b4db03d8bb zig fmt: fix extra newline before if nested in for
Add failing testcase to reproduce issue 8088

Tidy up renderWhile(), factoring out renderWhilePayload()

Ensure correct newline is used before 'then' token in while/for/if

Handle indents for 'if' inside 'for' or 'while'

Stop special-casing 'if' compared to 'for' and 'while'
2021-03-15 14:55:34 +01:00
Tadeo Kondrak
277b01a089
stage2 llvm bindings: rename LLVMBool to Bool 2021-03-14 22:32:26 -06:00
Michael Dusan
a502c160cd macho: fix various linker flags
fix drivers: zig {cc,c++}
  - `-dynamiclib` is an alias to `-shared`
  - associate `-dynamiclib` with zig `.shared` semantics

fix drivers: zig {cc,c++,build-lib,build-exe}
  - use `-dynamic` for {exe,dylib}
  - for dylib this fixes a regression
  - for exe this replaces incorrect use of `-static`
2021-03-14 17:26:24 -04:00
LemonBoy
27d07c6c4d std: Replace testing fns for floating-point values
Beside handling NaNs and other non-numeric values better we finally
offer the same pair of testing predicates in math and testing.
2021-03-14 17:23:47 -04:00
LemonBoy
d33f0d3375 docgen: Use Progress API
Really slow as usual but now looks slightly better.
2021-03-14 17:22:48 -04:00
Frank Denis
b98d7747fa Use a unified error set for std/crypto/*
This ensures that errors are used consistently across all operations.
2021-03-14 20:51:31 +01:00
Ersikan
f69305f865 stage2: Warn when using --debug-log without logging enabled
A warning is emitted when using the debug option --debug-log when the compiler
was not compiled using the build option -Dlog. Additionnaly, the scopes are not
added to log_scopes as they have no effect.
2021-03-14 17:48:02 +01:00
Andrew Kelley
4e9894cfc4 cmake build: allow overriding whether to use llvm-config
Previously, there was an option ZIG_PREFER_LLVM_CONFIG which would
override the default of not using llvm-config when cross compiling.

That option is now removed in favor of the more powerful
ZIG_USE_LLVM_CONFIG which defaults to OFF for cross compiling and ON for
native compilation. The option overrides the default.

This will be used in zig-bootstrap to improve support for native builds.
2021-03-13 14:30:56 -07:00
Michael Dusan
cc650abf09 lld: handle error instead of abort
closes #6675
2021-03-13 18:14:59 +01:00
Andrew Kelley
ce14bc7176
Merge pull request #8152 from LemonBoy/fix-riscv-ret
stage1: Follow the C ABI for return types
2021-03-12 20:12:36 -05:00
Dave Gauer
95eb711ca8
langref: Use "single-item pointer" and "many-item pointer" (#8217)
These terms give short, descriptive names for the two pointer
types which reflect the names used in src/type.zig.
2021-03-12 20:10:55 -05:00
LemonBoy
8ebb18d9da std: Use more common escape sequences in Progress
This should fix the badly-rendered progress message when run in
Terminal.app.
2021-03-12 19:31:59 -05:00
Isaac Freund
b83ef595a5 std/linux: sync io_uring library with liburing
liburing commit: 1bafb3ce5f

As stated in the liburing commit message, this fixes a regression,
reverting code that was added specutively to avoid a syscall in some
cases.
2021-03-12 22:22:06 +01:00
Andrew Kelley
f950489ed9
Merge pull request #8174 from LemonBoy/progress-line-wrap
std: Better handling of line-wrapping in Progress
2021-03-12 15:45:11 -05:00
Jakub Konka
a745e704f6 macos: add missing x86_64 libc headers 2021-03-12 18:05:50 +01:00
LemonBoy
b0724a350f Handle some weird edge cases of Win32 API
Sometimes the viewport srWindow may report an invalid rectangle where
the top row is below the bottom one.
2021-03-12 17:14:50 +01:00
LemonBoy
b5a50a26eb Fix many thinkos
Somehow I forgot to save after copy-pasting some code and changing it.
2021-03-12 15:08:48 +01:00
Sébastien Marie
89e522b935 make std.c.getErrno() return same type as _errno() aka c_int
adjust std.os.unexpectedErrno() to be correct for all std.os.system.errno (c_int, u12, usize, ...)
2021-03-12 15:04:36 +01:00
LemonBoy
36c4037144 stage1: Add tests for C ABI integer return types 2021-03-12 11:50:56 +01:00
LemonBoy
7813068e21 stage1: Follow the C ABI for return types
The current implementation of the target C ABI rules is hopelessly bad,
let's tack some more rules on top in order to prevent some
miscompilations.

Truth to be told the same rule should be applied also to parameters, but
I really can't stand stage1.
2021-03-12 11:50:56 +01:00
LemonBoy
3010bfb08a Fix Progress printing on Windows systems
The cursor must be restored after the line is printed, not before.
Take into account the visible viewport to correctly compute the terminal
size.
2021-03-12 10:15:38 +01:00
Andrew Kelley
e9a038c33b
Merge pull request #7934 from Vexu/stage2-cbe
Stage2 cbe: optionals and errors
2021-03-11 22:02:35 -05:00
Isaac Freund
a5cb4ab95e parser: disallow ptr modifiers on array types 2021-03-12 00:18:30 +01:00
LemonBoy
482424e2b1 std: Handle empty MultiArrayList in items()
Closes #8211
2021-03-12 00:17:35 +01:00
Andrew Kelley
4fc6f631e0
Merge pull request #8126 from xackus/translate_c_int_literal_promotion
translate-c: promote int literals to bigger types
2021-03-11 14:32:37 -05:00
joachimschmidt557
bdb917006c stage2 tzir: Add wrapping integer arithmetic instructions 2021-03-11 14:31:21 -05:00
Andrew Kelley
b1a22fdbab
Merge pull request #8193 from kivikakk/elf-expose-em
elf: expose machine field in ELF header
2021-03-11 14:30:06 -05:00
Asherah Connor
24e5959840 elf: make EM non-exhaustive 2021-03-11 10:09:51 +11:00
Asherah Connor
c5eb15526d expose machine field in ELF header 2021-03-10 16:26:41 +11:00