Commit Graph

12874 Commits

Author SHA1 Message Date
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
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
LemonBoy
f2b96782ec stage2: Fix glibc lookup path for MIPS crt files
Add some more rules to let the compiler find the correct startup files
for the selected target and ABI.
2021-03-09 18:20:34 -05:00
LemonBoy
1a5d0cea15 stage2: Use correct ELF emulation for mips64
The n32 ABI requires a different emulation string than n64.
2021-03-09 18:20:34 -05:00
Loris Cro
a033735c8d update to latest fetch-them-macos-headers 2021-03-09 22:43:16 +01:00
Loris Cro
767eb2d469 update to latest fetch-them-macos-headers 2021-03-09 22:15:01 +01:00
Evan Haas
c760532be0 translate-c: Add compound literal support 2021-03-08 10:09:12 +02:00
Isaac Freund
b988815bf0 parser: fix parsing/rendering of a[b.. :c] slicing
The modification to the grammar in the comment is in line with the
grammar in the zig-spec repo.

Note: checking if the previous token is a colon is insufficent to tell
if a block has a label, the identifier must be checked for as well. This
can be seen in sentinel terminated slicing: `foo[0..1:{}]`
2021-03-08 01:37:28 +01:00
Evan Haas
d01bb21173 translate-c: Explicitly cast decayed array to pointer with @ptrCast
This enables translation of code that uses pointer arithmetic with arrays
2021-03-08 00:35:17 +02:00
Veikka Tuominen
fc62ff77c3
stage2: error union payload must also be a valid variable type 2021-03-08 00:33:59 +02:00
jacob gw
d9e46a4b90
stage2: fix memory leak in the cbe 2021-03-08 00:33:59 +02:00
jacob gw
30ffa052f2
stage2 cbe: add error union and error union operations 2021-03-08 00:33:59 +02:00
jacob gw
6467ef6d3b
cbe: add error comparison support 2021-03-08 00:33:59 +02:00
Veikka Tuominen
0a7be71bc2
stage2 cbe: non pointer optionals 2021-03-08 00:33:56 +02:00
Veikka Tuominen
cfc19eace7
stage2 cbe: errors 2021-03-08 00:33:07 +02:00
Veikka Tuominen
c22f010fdd
stage2 cbe: regular optional types 2021-03-08 00:33:07 +02:00
Veikka Tuominen
ca20d0ea26
stage2 cbe: pointer like optionals 2021-03-08 00:32:52 +02:00
jacob gw
5d215cc76b stage2 Elf linker: fill in bswapAllFields
I moved it to std.elf since it could be used there and added test
2021-03-07 23:18:26 +02:00
LemonBoy
4fc2e92876 std: Better handling of line-wrapping in Progress
In order to update the printed progress string the code tried to move
the cursor N cells to the left, where N is the number of written bytes,
and then clear the remaining part of the line.
This strategy has two main issues:
 - Is only valid if the number of characters is equal to the number of
   written bytes,
 - Is only valid if the line doesn't get too long.

The second point is the main motivation for this change, when the line
becomes too long the terminal wraps it to a new physical line. This
means that moving the cursor to the left won't be enough anymore as once
the left border is reached it cannot move anymore.

The wrapped line is still stored by the terminal as a single line,
despite now taking more than a single one when displayed. If you try to
resize the terminal you'll notice how the contents are reflowed and are
essentially illegible.

Querying the cursor position on non-Windows systems (plot twist,
Microsoft suggests using VT escape sequences on newer systems) is
extremely cumbersome so let's do something different.

Before printing anything let's save the cursor position and clear the
screen below the cursor, this way we ensure there's absolutely no trace
of stale data on screen, and after the message is printed we simply
restore it.
2021-03-07 15:23:20 +01:00
Jonathan Knezek
0447a2c041
Implement fmtDuration using Formatter (#8137)
* Implement fmtDuration using Formatter

Deprecate Duration, duration

* fmtDuration: Fixed ns remainder

* fmtDuration: Fixed visibility; removed [Dd]uration
2021-03-07 15:00:15 +02:00
LemonBoy
72664df491 std: Deprecate the B and Bi format specifiers
Following #8007 and #8137 let's get rid of the last weird format.
2021-03-07 14:58:45 +02:00
LemonBoy
e47b754b28 std: Prevent null pointer deref in mem.len{,Z}
Closes #8140
2021-03-07 14:58:45 +02:00
Evan Haas
6d69a29d75 translate-c: Support compound assignment of pointer and signed int
This handles `ptr += idx` and `ptr -= idx` when `idx` is a
signed integer expression.
2021-03-07 14:54:04 +02:00
Evan Haas
874c63f89c translate-c: translate align attribute for block scoped variables 2021-03-07 14:53:33 +02:00