5280 Commits

Author SHA1 Message Date
joachimschmidt557
e088a17f56 stage2 AArch64: implement strb and strh 2021-03-31 23:26:49 +02:00
Evan Haas
ab9324e604 translate-c: intcast compound assignment operand if different-sized integer
Use transCCast to cast the RHS of compound assignment if necessary.
2021-03-28 15:21:12 +03:00
Michael Dusan
9f01598a49 zig build: use ZIG_GLOBAL_CACHE_DIR
- move ZIG_GLOBAL_CACHE_DIR to `introspect`
- cleanup some dead fields from stage1 codegen
2021-03-25 22:05:21 -04:00
Jakub Konka
f1e324216d zld: parse archive's table of contents 2021-03-25 22:48:04 +01:00
Veikka Tuominen
df0f7f4692 translate-c: stop creating unnamed decls for typedefs child types 2021-03-25 16:59:26 +02:00
Luuk de Gram
4b854b75d2
Fix getNot and add test cases 2021-03-22 19:56:38 +01:00
Luuk de Gram
803f9e5dd0
Implement more instructions for more control flow support 2021-03-22 19:56:35 +01:00
Jakub Konka
3b48ea874e zld: naively handle static initializers in C++ 2021-03-22 17:14:53 +01:00
Evan Haas
dce612ac2b translate-c: Ensure assignments are within a block when necessary
Ensures that if an assignment statement is the sole statement within a
C if statement, for loop, do loop, or do while loop, then when translated
it resides within a block, even though it does not in the original C.

Fixes the following invalid translation:

`if (1) if (1) 2;` -> `if (true) if (true) _ = @as(c_int, 2);`

To this:
```zig
    if (true) if (true) {
        _ = @as(c_int, 2);
    };
```

Fixes #8159
2021-03-22 10:48:08 +02:00
Jakub Konka
ba8ac46e1f stage1: add cmake flag for enabling logging
Now that we ship our own linker for MachO by default in both stage1
and stage2, we need a way to enable logs for verbose debugging.
This commit adds `ZIG_ENABLE_LOGGING` cmake option which is equivalent
to stage2's `-Dlog` flag.

To enable it when building stage1 with cmake, add:

```
cmake .. -DZIG_ENABLE_LOGGING=on
```
2021-03-21 18:03:55 -07:00
Jakub Konka
3913332145 Fix digest format specifier after std.fmt updates 2021-03-20 15:09:45 -07:00
Jakub Konka
f6ba810f27 zld: apply offset for DICE in archive 2021-03-19 23:37:16 +01:00
Jakub Konka
652842637c zld: continue on invalid/missing debug info 2021-03-19 20:05:02 +01:00
Jakub Konka
d1b376cac9 zld: fix parsing archive/object name from header 2021-03-19 11:06:51 +01:00
Andrew Kelley
5e5b35f107 stage1: small memory optimization for simple pointer types
Avoid storing extra IR instruction data for simple pointer types.
2021-03-18 14:04:02 -07:00
Andrew Kelley
a6f5aa71ac stage1: small IR memory optimization on CheckSwitchProngs 2021-03-18 14:04:02 -07:00
Veikka Tuominen
ac7217e1f5 translate-c: preserve zero fractional part in float literals 2021-03-18 22:46:00 +02:00
Andrew Kelley
5cbb642525 stage1: small mem usage improvement for IR
move a boolean field to be represented implicitly with the enum tag.
Just borrowing one of the many strategies of stage2.

This simple change took the peak mem usage from std lib tests on
my machine from 8.21 GiB to 8.11 GiB.
2021-03-18 13:14:26 -07:00
Jakub Konka
17c066e925
Merge pull request #8282 from kubkon/zld
macho: upstream zld linker
2021-03-18 19:14:17 +01:00
Evan Haas
b54514d9dd
translate-c: Use [N:0] arrays when initializer is a string literal (#8264)
* translate-c: Use [N:0] arrays when initializer is a string literal

Translate incomplete arrays as [N:0] when initialized by a string literal.
This preserves a bit more of the type information from the original C program.

Fixes #8215
2021-03-18 14:41:04 +02:00
Veikka Tuominen
bcc97bc1ed
Merge pull request #8247 from Ersikan/fmt-fix-encoding
zig fmt: fix non-UTF-8 encoding #2820
2021-03-18 14:30:11 +02:00
Jakub Konka
f3b4f79c7f zld: temporarily disable testing shared lib linking 2021-03-18 11:10:31 +01:00
Jakub Konka
2cf1c1b96b macho: honor verbose_link when linking with zld 2021-03-18 11:10:09 +01:00
Jakub Konka
861ea64009 macho: remove now obsolete LLD fixups 2021-03-18 11:09:47 +01:00
Dimenus
dfeca48e35 @intCast takes two args 2021-03-17 22:58:52 -07:00
Jakub Konka
7516dfff83 zld: use zld when linking aarch64 by default and cross-comp 2021-03-18 00:37:13 +01:00
Jakub Konka
900658a85d rebase with master 2021-03-17 20:05:29 +01:00
Jakub Konka
1ec620be62 zld: fix GOT loads and indirection on x86_64 2021-03-17 19:59:57 +01:00
Jakub Konka
ac0c669473 zld: add/fix more issues
* fix debug info for static archives
* allow handling of empty object files
* fix some relocs for GOT loads
2021-03-17 19:59:13 +01:00
Jakub Konka
de209afbba zld: fix TLV initializers 2021-03-17 19:59:13 +01:00
Jakub Konka
349f878ecf zld: mimick Apple and add __DATA_CONST seg 2021-03-17 19:59:13 +01:00
Jakub Konka
62f43fbc06 zld: clean up use of commands.zig module 2021-03-17 19:59:13 +01:00
Jakub Konka
d484b3b3cb zld: use aarch64 for opcodes 2021-03-17 19:59:13 +01:00
Jakub Konka
dc34ac2b9e zld: fix incorrect offset calc for DICE 2021-03-17 19:59:13 +01:00
Jakub Konka
5d8944edc1 Revert log.warn hack 2021-03-17 19:59:13 +01:00
Jakub Konka
a1b0ec5277 zld: start bringing x64 up to speed 2021-03-17 19:59:13 +01:00
Jakub Konka
066c1386a3 zld: demote logs from warn to debug 2021-03-17 19:59:13 +01:00
Jakub Konka
b0ee480177 zld: merge and sort sections 2021-03-17 19:59:13 +01:00
Jakub Konka
44ebf48631 zld: fix handling of section alignment 2021-03-17 19:59:13 +01:00
Jakub Konka
7c22f4f851 zld: pass test-std and test-compiler-rt 2021-03-17 19:59:13 +01:00
Jakub Konka
7cbdbab376 zld: differentiate locals from globals 2021-03-17 19:59:13 +01:00
Jakub Konka
7e32947871 zld: add nop to reloc module 2021-03-17 19:59:13 +01:00
Jakub Konka
d2008db623 zld: bullet-proof stubs for long jumps 2021-03-17 19:59:13 +01:00
Jakub Konka
14590795b1 zld: cleanup section alignment when allocating 2021-03-17 19:59:13 +01:00
Jakub Konka
586c704212 zld: pass stage2 tests linked with zld! 2021-03-17 19:59:13 +01:00
Jakub Konka
e825a15b05 zld: replace ldr with add if indivisible 2021-03-17 19:59:13 +01:00
Jakub Konka
f52f23618d macho: start upstreaming zld 2021-03-17 19:59:13 +01:00
Jakub Konka
e5234c0e9e macho: offset table part of GOT 2021-03-17 12:16:36 +01:00
Jakub Konka
b9fa80e588 macho: use latest bind functionality 2021-03-17 12:10:39 +01:00
Jakub Konka
1181543dad macho: extract writing stub helper preamble into fn 2021-03-17 12:10:39 +01:00