Commit Graph

5650 Commits

Author SHA1 Message Date
Evan Haas
fdb8870852 translate-c: promote large integer macros to unsigned long long if necessary
Closes #10793

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-31 15:52:53 +03:00
biexelar
59e33b447b
std.Thread: fix freeAndExit on x86_64-linux (#12693)
Previously, this function used incorrect registers for the munmap syscall, leading to detached threads not cleaning up.

closes #12690

Co-authored-by: bxlr <biexelar@diroot.org>
2022-08-30 22:31:47 -04:00
Jakub Konka
d3eaabd285 coff: add base relocation related types 2022-08-30 23:07:28 +02:00
Jakub Konka
aa5568beb6 coff: move Symtab and Strtab out of coff.Coff
This should ease interfacing with different std.coff functionalities.
2022-08-30 15:51:49 +02:00
Jakub Konka
7ef0c9d298
Merge pull request #12677 from ziglang/coff-linker
coff: initial rewrite of the COFF/PE linker
2022-08-30 14:29:41 +02:00
Jakub Konka
69d6931be7
Merge pull request #12662 from wsengir/coff-fix
coff: fix reading COFF header offset
2022-08-30 12:26:35 +02:00
Veikka Tuominen
e6be6d9768 std.rand: make weightedIndex proportions param a const slice
The function does not mutate the proportions and the signature should reflect that.
2022-08-30 13:02:17 +03:00
Jakub Konka
db1a3bb0e7 coff: fallback to _start as default entry point for now
This is not technically correct, but given that we are not yet able
to link against the CRT, it's a good default until then.

Add basic logging of generated symbol table in the linker.
2022-08-30 10:42:21 +02:00
Jakub Konka
30baba899c coff: add missing bits required for minimal PE example 2022-08-30 10:42:21 +02:00
Jakub Konka
ed481e3837 coff: write headers to file 2022-08-30 10:42:21 +02:00
Jakub Konka
90b3599c68 coff: reorganize the linker 2022-08-30 10:42:21 +02:00
Jakub Konka
06371950cf start: allow for explicitly defined entry point for Win 2022-08-30 10:42:21 +02:00
William Sengir
91b9f295d3
coff: publicize and flesh out more image constants 2022-08-28 06:20:18 -07:00
Justin Whear
5bb8c03697
std.random: add weightedIndex function
`weightedIndex` picks from a selection of weighted indices.
2022-08-28 14:19:51 +03:00
William Sengir
3860e664c5
coff: fix reading COFF header offset 2022-08-28 03:10:39 -07:00
antlilja
ae8d26a6a0 Sema: add error for non-comptime param in comptime func
Adds error for taking a non comptime parameter in a function returning a
comptime-only type but not when that type is dependent on a parameter.

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-08-27 11:17:48 +03:00
Sébastien Marie
8bcb962ada openbsd: fix sigcontext struct and avoid defining fxsave64
`sc_fpstate` member of `struct sigcontext` is a `struct fxsave64 *`.
use *anyopaque to represent it.

avoid to defining `fxsave64` as it is a packed struct with some arrays.
2022-08-26 17:30:07 +02:00
Jakub Konka
02e6960966 coff: do not pull in std.log into coff.zig definitions 2022-08-26 16:14:44 +02:00
Motiejus Jakštys
9038528187 copy_file_range: fix zigification of TXTBSY
From `copy_file_range(2)` errors:

    ETXTBSY
           Either fd_in or fd_out refers to an active swap file.

Same error will be used in the upcoming `ioctl_ficlonerange(2)`:

    ETXTBSY
           One of the files is a swap file.  Swap files cannot share storage.
2022-08-26 15:36:40 +03:00
Andrew Kelley
7453f56e67 stage2: explicitly tagged enums no longer have one possible value
Previously, Zig had inconsistent semantics for an enum like this:

`enum(u8){zero = 0}`

Although in theory this can only hold one possible value, the tag
`zero`, Zig no longer will treat the type this way. It will do loads and
stores, as if the type has runtime bits.

Closes #12619

Tests passed locally:
 * test-behavior
 * test-cases
2022-08-24 22:20:31 -07:00
Jonas Gollenz
07afd5bdba docs: remove confusion about align[For|Back]ward 2022-08-24 17:18:29 -04:00
max
d8e22fcb20 fix coff.zig with const qualifier convert problem 2022-08-24 22:49:47 +02:00
Sébastien Marie
397099b7ee pthread_key_create: make it build with stage2 2022-08-24 16:35:01 -04:00
Andrew Kelley
2a96209c40
Merge pull request #12574 from Vexu/remove-bit-op-type-param
stage2+stage1: remove type parameter from bit builtins
2022-08-24 15:57:44 -04:00
Felix "xq" Queißner
b466f8c817 Enables std.build.TranslateCStep to use stage1/stage2 selectively. Unbreaks projects using stage1 and manual TranslateC 2022-08-24 15:41:27 -04:00
Felix "xq" Queißner
5696cc8ab6 Adds std.meta.FnPtr for easier stage1/stage2 compatibility 2022-08-24 03:13:44 -04:00
Andrew Kelley
5db80a051f Revert "std.os: add INVALID_SOCKET (#12081)"
This reverts commit 0f01e812ff.

This does not belong in `std.posix`, and it is already provided at
`std.os.windows.ws2_32.INVALID_SOCKET`.

See related issue #5019.
2022-08-23 21:30:23 -07:00
Andrew Kelley
60722261fa std.debug: DWARFv5 fixes
handle str_offsets_base and addr_base correctly.
handle data16
fix compilation on 32-bit hosts
remove stray debug print statement

closes #12120
2022-08-23 21:11:02 -07:00
yyny
0f01e812ff
std.os: add INVALID_SOCKET (#12081)
This constant returns an invalid `socket_t` that can be used as a sentinel
value.
2022-08-23 19:44:42 -05:00
Jakub Konka
f907f74282 coff: fix compile errors in std.debug 2022-08-23 22:01:05 +02:00
Jakub Konka
cf9f6fd7f0 macho: fix compile errors in std.debug 2022-08-23 22:01:05 +02:00
Andrew Kelley
1ce71c86bf std.debug: implement support for DWARFv5 2022-08-23 00:28:45 -07:00
Jakub Konka
c84e5ee878 coff: improve default COFF/PE object parser
We now do not allocate memory for headers and other metadata unless
requested by the caller. Instead, we read-in the entire contents
of the image into memory and operate on pointers and casts wherever
possible. I have a left a TODO to hook up Windows' memory-mapped API
here in-place of standard `readToEndAlloc` which should be more memory
proof on memory constrained hosts.

This commit also supplements our `std.coff` with a lot missing basic
extern structs required to make our COFF linker.
2022-08-23 08:55:04 +02:00
Ryan Liptak
95c43e20b4 Windows: Fix incorrect output when .pdb file is not found during stack trace
This `pdb.Pdb.init` call can return `error.FileNotFound`, which was previously resulting in:

    Unable to print stack trace: FileNotFound

which also aborts the stack trace printing (so any deeper stack traces are not printed).

It makes more sense to treat it as `MissingDebugInfo` which then gets printed as:

    ???:?:?: 0x7fffa8817033 in ??? (???)

and allows the stack trace to continue printing.

Note: locally, the error.FileNotFound was being triggered for me when looking for kernel32.pdb and ntdll.pdb
2022-08-22 20:51:55 -04:00
Keith Chambers
96737ef499
Dwarf: Added stroffsetsptr support (#12270)
* Added support for stroffsetsptr class in Dwarf stdlib

* Proper initializion of debug_str_offsets in DwarfInfo

* Added missing null initializer to DwarfInfo in Macho

* Added missing is_64 field to getAttrString in DwarfInfo

* Fixed formatting

* Added missing is_64 param to getAttrString

* Added required cast to usize

* Adding missing .debug_str_offsets initialization

* getAttrString now uses the str_offsets_base attr
2022-08-22 20:50:06 -04:00
Andrew Kelley
ecdd4a9fe8 build system: add flag for -fstack-protector 2022-08-22 15:11:34 -07:00
Veikka Tuominen
8667d6d61e
Merge pull request #12563 from Vexu/stage2-fixes
Stage2 fixes
2022-08-22 14:32:31 +03:00
InKryption
f1999712b0 std.io.Reader: bounded array functions
* Add readIntoBoundedBytes
 * Add readBoundedBytes
2022-08-22 14:07:22 +03:00
Justas Zabulionis
24d718e7eb
std.valgrind.callgrind: fix string type
Fixes the error when using std.vallgrind.callgrind:
error: expected type '[2]u8', found '*const [2:0]u8'
2022-08-22 13:55:00 +03:00
Veikka Tuominen
62ff8871ed stage2+stage1: remove type parameter from bit builtins
Closes #12529
Closes #12511
Closes #6835
2022-08-22 11:19:20 +03:00
Veikka Tuominen
b55a5007fa Sema: fix parameter of type 'T' must be comptime error
Closes #12519
Closes #12505
2022-08-22 11:16:36 +03:00
Jakub Konka
6c020cdb76
Merge pull request #12557 from Luukdegram/wasm-archive
wasm-linker: Improve archive linking
2022-08-22 08:38:41 +02:00
John Schmidt
9cf667a21b Enable unexpectedErrno error tracing for stage2 LLVM
Stage2 seems to be able to handle this now.
2022-08-21 23:41:01 +03:00
Luuk de Gram
d4c56804df
std: fix EmulatableRunStep
Fixes a compilation error when using the `EmulatableRunStep`
that is being generated from a step directly using `runEmulatable`.
2022-08-21 16:42:11 +02:00
Luuk de Gram
7fe2a3d104
test/link: add wasm linker-test for archives
Adds a test case that will pull-in compiler-rt symbols,
and therefore link with the compiler-rt archive file.
2022-08-20 15:46:39 +02:00
Andrew Kelley
4a27d2aac6 std.os.linux.bpf: fix compile error 2022-08-19 16:45:16 -07:00
Jakub Konka
10b95d89f8 coff: change improperly used packed struct into extern struct 2022-08-19 16:45:16 -07:00
Andrew Kelley
445b33cfc0 fix std.os.windows.PathSpace.span
it was returning a pointer to a parameter.
2022-08-19 16:45:16 -07:00
Andrew Kelley
507aae4a1a make self-hosted the default compiler
stage1 is available behind the -fstage1 flag.

closes #89
2022-08-19 16:45:15 -07:00
Andrew Kelley
cee82c7ce4 improved ABI alignment/size for >= 128-bit integers
* riscv64: adjust alignment and size of 128-bit integers.
 * take ofmt=c into account for ABI alignment of 128-bit integers and
   structs.
 * Type: make packed struct support intInfo
 * fix f80 alignment for i386-windows-msvc
2022-08-18 20:34:36 -07:00