Commit Graph

9911 Commits

Author SHA1 Message Date
Andrew Kelley
4e023c6fa8 stage2: dwarf: fix standard opcode length of LNS_fixed_advance_pc 2020-08-03 00:54:30 -07:00
Andrew Kelley
eccbb03063 downgrade .debug_info to DWARFv4
gdb, notice me senpai
2020-08-03 00:42:08 -07:00
Andrew Kelley
bf85d3db3f downgrade .debug_line to DWARFv4
apparently gdb 8.3.1 which is still a commonly distributed version of gdb,
does not support v5.
2020-08-03 00:34:12 -07:00
Andrew Kelley
659603c621 codegen: emit .debug_line ops for IR instructions 2020-08-02 21:28:06 -07:00
Andrew Kelley
42d331b58a .debug_line: avoid DW_FORM_strp to work around readelf/gdb
These tools do not support DWARFv5 yet apparently.
2020-08-02 20:22:41 -07:00
Andrew Kelley
1ce6e201aa .debug_line: don't rely on header_length field
Empirically, debug info consumers do not respect this field, or otherwise
consider it to be an error when it does not point exactly to the end of the header.
Therefore we rely on the NOP jump at the beginning of the Line Number Program for
padding rather than this field.

llvm-dwarfdump says the line number data is fine; gdb and
binutils-readelf crap out.
2020-08-02 19:57:42 -07:00
Andrew Kelley
1a3f250f19 .debug_line incremental compilation initial support
Supports writing the first function. Still TODO is:
 * handling the .debug_line header growing too large
 * adding a new file to an existing compilation
 * adding an additional function to an existing file
 * handling incremental updates
 * adding the main IR debug ops for IR instructions

There are also issues to work out:
 * readelf --debug-dump=rawline is saying there is no .debug_str section
   even though there is
 * readelf --debug-dump=decodedline is saying the file index 0 is bad
   and reporting some other kind of corruption.
2020-08-02 19:25:26 -07:00
Andrew Kelley
ba6e5cbfd2 stage2: add the .debug_line header and associated data types
* the .debug_line header is written properly
 * link.File.Elf gains:
   - SrcFn, which is now a field in Module.Fn
   - SrcFile, which is now a field in Module.Scope.File
 * link.File.Elf gets a whole *Package field rather than only
   root_src_dir_path.
 * the fields first_dbg_line_file and last_dbg_line_file tell where the
   Line Number Program begins and ends, which alows moving files when
   the header gets too big, and allows appending files to the end.
 * codegen is passed a buffer for emitting .debug_line
   Line Number Program opcodes for functions.

See #5963

There is some work-in-progress code here, but I need to go make some
experimental changes to changing how to represent source locations and I
want to do that in a separate commit.
2020-08-02 12:02:43 -07:00
Andrew Kelley
c0654d2db2 std.dwarf: add LNCT constants from DWARF v5 2020-08-02 11:09:39 -07:00
Andrew Kelley
d4bb2b1513 std: add function for writing fixed width ULEB128 2020-08-02 11:09:35 -07:00
Isaac Freund
6123201f06 stage2: move format-specific code to link.File.X
This makes the code outside of link.File.Elf less elf-specific and will
allow for easier implementation of other formats such as wasm.
2020-08-02 18:07:10 +00:00
S0urc3C0de
5ae88e919b Add rdynamic option to build.zig 2020-08-02 17:50:06 +00:00
Vexu
6bba7c702b add compile error for alignCasting zero sized types 2020-08-02 17:49:16 +00:00
Andrew Kelley
35391f1709
Merge pull request #5968 from haliucinas/blake2
Blake2 improvements
2020-08-02 17:47:06 +00:00
Andrew Kelley
6df35c5877
Merge pull request #5960 from kubkon/windows-dir-refactor
Refactor out file and dir creation routines in Windows
2020-08-02 17:41:47 +00:00
Jakub Konka
4b0ab0c186
Apply suggestions from code review
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-08-02 19:36:49 +02:00
Jay Petacat
cf15b4c269 elf: Iterate over headers w/o need for allocator 2020-08-01 16:01:48 +00:00
Mantas Jonytis
1df33936d6 remove unnecessary operations 2020-08-01 17:15:53 +03:00
Mantas Jonytis
8286cc77f8 implement keyed blake2 2020-08-01 16:56:11 +03:00
Mantas Jonytis
36ed4623a8 make blake2 public 2020-08-01 16:05:20 +03:00
Mantas Jonytis
42dd737c9e compute blake2 at compile time 2020-08-01 16:00:22 +03:00
Mantas Jonytis
1ae40146e6 blake2b: off-by-one on update 2020-08-01 15:31:46 +03:00
Mantas Jonytis
eee9abe1b4 add more blake2b test cases 2020-08-01 15:31:36 +03:00
Mantas Jonytis
b1cf0196df blake2s: off-by-one on update 2020-08-01 15:15:45 +03:00
Mantas Jonytis
fad87bef9a add more blake2s tests 2020-08-01 15:15:04 +03:00
Jakub Konka
f6ae2505d9 Fix opening NUL device on Windows 2020-07-31 19:16:04 +02:00
Jakub Konka
4d9eff4bdb Add prelim openW and openatW
Added POSIX functions targeting Windows pass `open` and `openat`
smoke tests.
2020-07-31 16:41:25 +02:00
Jakub Konka
a694f575ad Add some os.open and os.openat smoke tests 2020-07-31 16:33:02 +02:00
Jakub Konka
390194431e Use NtCreateFile directly in ReadLink
This shaves off one syscall (we use one instead of two if we were to
use `windows.OpenFile` wrapper). Clean up flag generation in `OpenFile`.
Hopefully, we're in a much better place to *almost* support `openW`
and `openatW`.
2020-07-31 16:32:21 +02:00
Jakub Konka
8981b18fee Move delete file logic into windows.DeleteFile fn
This way, we can remove more `kernel32` calls such as `RemoveDirectoryW`
or `DeleteFileW`, and use `std.os.windows.DeleteFile` instead which
is purely NT-based.
2020-07-31 16:31:51 +02:00
Jakub Konka
66bbe4ec4c Refactor internal Win routines to reuse OpenFile
This covers mainly `ReadLink` and `CreateSymolicLink` functions.
2020-07-31 16:31:44 +02:00
Jakub Konka
a89d5cfc3e Remove CreateDirectoryW and CreateFileW calls
Replace them with `std.os.windows.OpenFile` instead. To allow
creation/opening of directories, `std.os.windows.OpenFileOptions`
now features a `.expect_dir: bool` member which is meant to emualate
POSIX's `O_DIRECTORY` flag.
2020-07-31 16:31:23 +02:00
Sam Tebbs
0d31877444
Print } as format argument in enum build option (#5953)
Co-authored-by: Veikka Tuominen <git@vexu.eu>
Co-authored-by: Joachim Schmidt <joachim.schmidt557@outlook.com>
2020-07-31 11:37:40 +03:00
Andrew Kelley
0962cc5a32 stage2: implement .debug_aranges DWARF 2020-07-31 01:16:34 -07:00
Andrew Kelley
9d0872a625 std.ArrayList: add appendNTimesAssumeCapacity 2020-07-31 01:16:17 -07:00
Andrew Kelley
acd0dabab2 stage2: add some tracy calls to link.zig functions 2020-07-30 23:51:14 -07:00
Andrew Kelley
f1c1b8c02d stage2: add DWARF info for the main compilation unit 2020-07-31 06:48:17 +00:00
Vexu
f962315363
fix missing parser error for missing comma before eof
Closes #5952
2020-07-30 13:10:55 +03:00
Vexu
1f8f434b9c
compiler_rt: add floatditf 2020-07-29 18:03:44 +03:00
Jakub Konka
547e520359 Split DeviceIoControl path into two fn call paths
As discussed in the previous commit, it would be better to avoid
function pointers to syscalls and explicitly split the control
path into two function calls instead. This commit addresses that
for `std.os.windows.DeviceIoControl`.
2020-07-29 14:17:49 +02:00
Andrew Kelley
b3b00ec62f Merge branch 'more-stage2-locals' 2020-07-29 02:29:46 -07:00
Andrew Kelley
8899e6e334 stage2: codegen: fix off-by-one stack variable offsets 2020-07-29 02:29:37 -07:00
Andrew Kelley
606f157a6b stage2: register-aliasing-aware codegen
* unify duplicated register allocation codepath
 * support the x86_64 concept of register aliasing
 * slightly improved memset codegen, supports sizes 1, 2, 4, 8
2020-07-29 02:29:37 -07:00
Andrew Kelley
1bbfa36b76 stage2: improved codegen
* multiple returns jump to one canonical function exitlude. This is in
   preparation for the defer feature.
 * simple elision of trivial jump relocs.
 * omit prelude/exitlude for naked calling convention functions.
 * fix not switching on arch for prelude/exitlude
 * fix swapped registers when setting stack mem from a register
2020-07-29 02:29:37 -07:00
Andrew Kelley
64a1a280ef stage2: fix superfluous returnvoid ZIR 2020-07-29 02:29:37 -07:00
Andrew Kelley
4beff80b2f stage2: codegen handles undefined values
* `optimize_mode` is passed to `link.File` and stored there
 * improve the debugging function `Module.dumpInst`
 * get rid of `Value.the_one_possible_value` in favor of a few more
   specific values for different types. This is less buggy, one less
   footgun.
 * `Type.onePossibleValue` now returns a `?Value` instead of `bool`.
 * codegen handles undefined values. `undef` is a new `MCValue` tag.
   It uses 0xaa values depending on optimization mode. However
   optimization mode does not yet support scope overrides.
 * link.zig: move the `Options` field from `File.Elf` and `File.C` to
   the base struct.
   - fix the Tag enum to adhere to style conventions
 * ZIR now supports emitting undefined values.
 * Fix the logic of comptime math to properly compare against zero using
   the `compareWithZero` function.
2020-07-29 02:29:37 -07:00
Andrew Kelley
2b8e7deeda stage2: add ZIR emitType support for simple pointer types 2020-07-29 02:29:37 -07:00
Andrew Kelley
99d2d9bf64 stage2: fix format() of mutable pointer types 2020-07-29 02:29:37 -07:00
Andrew Kelley
cb3e8e323d stage2: x86_64 codegen for movs to/from stack variables 2020-07-29 02:29:37 -07:00
Andrew Kelley
5ccee4c986 stage2: more progress towards mutable local variables
* implement sema for runtime deref, store pointer, coerce_to_ptr_elem,
   and store
 * identifiers support being lvalues, except for decls is still TODO
 * codegen supports load, store, ref, alloc
 * introduce more MCValue union tags to support pointers
 * add load, ref, store typed IR instructions
 * add Type.isVolatilePtr
2020-07-29 02:29:36 -07:00