Commit Graph

12404 Commits

Author SHA1 Message Date
Julian Maingot
384ccaa27a stage2: use %type not @type for libc stubs
Missed a couple places last time so just doing the rest.
2021-01-18 11:04:33 -08:00
Julian Maingot
4c5f69a065 update error return doc
Docs were out of sync with code
2021-01-18 11:04:33 -08:00
Jakub Konka
61b8d42d5c
Merge pull request #7808 from joachimschmidt557/stage2-aarch64
Stage2 AArch64: Fix genSetStack
2021-01-18 20:01:44 +01:00
joachimschmidt557
458011f21f
stage2 AArch64: update function prologue and epilogue to include stack
offsets
2021-01-17 23:12:04 +01:00
joachimschmidt557
ea6f3e3fd1
stage2 AArch64: add add/subtract (immediate) instructions 2021-01-17 22:40:14 +01:00
joachimschmidt557
c6cb02c226
stage2 AArch64: fix stack offsets in genSetStack 2021-01-17 22:22:47 +01:00
Jakub Konka
8118336585 macho: refactor undef symbol handling
Now, we don't erroneously write to the string table on every
write of global and undef symbols.
2021-01-17 21:01:52 +01:00
Jakub Konka
3562edf137 macho: improve x86_64 tests; clean fixups on error
When codegen ends in failure, we need to manually clean up any fixups
that may have been gathered during that `codegen.generateSymbol` call.
Otherwise, we will end trapping.
2021-01-17 16:01:16 +01:00
Jakub Konka
b25cf7db02 stage2 aarch64: add basic function pro/epilogue
Fix typo in `nop` implementation.
Simplify `aarch64` macOS tests.
2021-01-17 14:57:53 +01:00
Jakub Konka
e292f33de7 stage2 aarch64: add basic genSetStack 2021-01-17 14:57:36 +01:00
Andrew Kelley
44135ea84e Merge branch 'stage2 error notes'
Closes #7555

There was still some extra work @Vexu did in that PR having to do with
adding more compile errors and notes for switch expressions, but that
can be added in a follow-up commit.
2021-01-17 00:16:10 -07:00
Andrew Kelley
8deb21c58a stage2: add compile error for label redefinition
Also fix incorrectly destroying notes.

This work is based on Vexu's patch in #7555.
2021-01-17 00:15:25 -07:00
Andrew Kelley
629d3bea1b stage2: slight cleanup of Module by calling astgen functions 2021-01-16 23:24:00 -07:00
Andrew Kelley
8c9ac4db97 stage2: implement error notes and regress -femit-zir
* Implement error notes
   - note: other symbol exported here
   - note: previous else prong is here
   - note: previous '_' prong is here
 * Add Compilation.CObject.ErrorMsg. This object properly converts to
   AllErrors.Message when the time comes.
 * Add Compilation.CObject.failure_retryable. Properly handles
   out-of-memory and other transient failures.
 * Introduce Module.SrcLoc which has not only a byte offset but also
   references the file which the byte offset applies to.
 * Scope.Block now contains both a pointer to the "owner" Decl and the
   "source" Decl. As an example, during inline function call, the
   "owner" will be the Decl of the caller and the "source" will be the
   Decl of the callee.
 * Module.ErrorMsg now sports a `file_scope` field so that notes can
   refer to source locations in a file other than the parent error
   message.
 * Some instances where a `*Scope` was stored, now store a
   `*Scope.Container`.
 * Some methods in the `Scope` namespace were moved to the more specific
   type, since there was only an implementation for one particular tag.
   - `removeDecl` moved to `Scope.Container`
   - `destroy` moved to `Scope.File`
 * Two kinds of Scope deleted:
   - zir_module
   - decl
 * astgen: properly use DeclVal / DeclRef. DeclVal was incorrectly
   changed to be a reference; this commit fixes it. Fewer ZIR
   instructions processed as a result.
   - declval_in_module is renamed to declval
   - previous declval ZIR instruction is deleted; it was only for .zir
     files.
 * Test harness: friendlier diagnostics when an unexpected set of errors
   is encountered.
 * zir_sema: fix analyzeInstBlockFlat by properly calling resolvingInst
   on the last zir instruction in the block.

Compile log implementation:
 * Write to a buffer rather than directly to stderr.
 * Only keep track of 1 callsite per Decl.
 * No longer mutate the ZIR Inst struct data.
 * "Compile log statement found" errors are only emitted when there are
   no other compile errors.

-femit-zir and support for .zir source files is regressed. If we wanted
to support this again, outputting .zir would need to be done as yet
another backend rather than in the haphazard way it was previously
implemented.

For parsing .zir, it was implemented previously in a way that was not
helpful for debugging. We need tighter integration with the test harness
for it to be useful; so clearly a rewrite is needed. Given that a
rewrite is needed, and it was getting in the way of progress and
organization of the rest of stage2, I regressed the feature.
2021-01-16 22:51:01 -07:00
Andrew Kelley
8436134499 std.ArrayHashMap: add "AssertDiscard" function variants
* Add `swapRemoveAssertDiscard`
 * Add `orderedRemoveAssertDiscard`
 * Deprecate `removeAssertDiscard`
2021-01-16 22:49:20 -07:00
Andrew Kelley
1f65828ec6
Merge pull request #7716 from koachan/sparc64-libs
stage1: SPARCv9 f128 enablement
2021-01-16 12:10:03 -08:00
joachimschmidt557
d2a297c2b3 stage2 ARM: add extra load/store instructions 2021-01-16 12:06:31 -08:00
joachimschmidt557
fbd5fbe729 stage2 AArch64: add very basic return values 2021-01-16 12:05:38 -08:00
Jakub Konka
b204ea0349 macho: ensure that strtab always follows symtab
In rare occassions, it may happen that string table is allocated free
space preceeding symbol table. This is an error in the eyes of the `dyld`
dynamic loader and thus has to forbidden by the linker.
2021-01-15 23:22:28 +01:00
Guillaume Ballet
f7d7cb6268 crypto: add legacy keccak hash functions 2021-01-15 12:36:38 -08:00
Evan Haas
1702b413f7 translate-c: ensure bools are cast to int when necessary
Fixes two scenarios where @boolToInt() calls were missing:

1. Boolean expression cast to different-size int (char, long, etc)
2. Boolean expression used as parameter for function with int argument
2021-01-15 12:35:54 -08:00
Andrew Kelley
35686262f5
Merge pull request #7785 from ziglang/std-thread-primitives
organize std lib concurrency primitives and add RwLock
2021-01-15 12:31:17 -08:00
Koakuma
1d67ab8823 Fix _Qp_cmp definition 2021-01-15 19:07:39 +07:00
Koakuma
b531caac02 Fix f128 codegen on BE hosts 2021-01-15 19:07:38 +07:00
Koakuma
bbb58b10f6 Add compiler-rt stub for SPARC CPUs 2021-01-15 19:07:38 +07:00
Jakub Konka
2faf8c53d2 macho: use target arch page_size for codesig
It turns out I was wrong and we can set the page size to the actual
page size used by the target architecture when dividing the binary
into chunks and calculating a hash of each chunk for embedding within
the adhoc code signature. This shaves of a considerable amount of bytes
since we divide the code signature section by at least 2x.

I've also unified the `write` interface of `CodeSignature` struct to
follow that used in every other bit of `MachO`; namely, the functions
now accept a writer instead of a buffer, therefore, there is no need
to manually track where to write each struct field anymore.
2021-01-15 08:16:47 +01:00
Andrew Kelley
19f893c6bb std.Thread: avoid compile errors for single-threaded OS's 2021-01-14 22:42:29 -07:00
Andrew Kelley
ad301d687a fix namespace of kernel32 function calls 2021-01-14 21:42:49 -07:00
Andrew Kelley
9e1aeda3bf std.Thread.StaticResetEvent: call spinLoopHint appropriately 2021-01-14 21:34:30 -07:00
Andrew Kelley
9698ea3173 std.Thread.Mutex: restore the "Held" API
so that std.Thread.Mutex.Dummy can be used as a drop in replacement.
2021-01-14 21:28:22 -07:00
Andrew Kelley
a9667b5a85 organize std lib concurrency primitives and add RwLock
* move concurrency primitives that always operate on kernel threads to
   the std.Thread namespace
 * remove std.SpinLock. Nobody should use this in a non-freestanding
   environment; the other primitives are always preferable. In
   freestanding, it will be necessary to put custom spin logic in there,
   so there are no use cases for a std lib version.
 * move some std lib files to the top level fields convention
 * add std.Thread.spinLoopHint
 * add std.Thread.Condition
 * add std.Thread.Semaphore
 * new implementation of std.Thread.Mutex for Windows and non-pthreads Linux
 * add std.Thread.RwLock

Implementations provided by @kprotty
2021-01-14 20:41:37 -07:00
Asherah Connor
2b0e3ee228
std.os.uefi.protocols.FileProtocol: fix and expose get_position, set_position (#7762) 2021-01-13 21:46:22 -05:00
Andrew Kelley
ec1541de26
Merge pull request #7746 from kubkon/macho-extern-fn
macho: extern functions come to MachO!
2021-01-13 15:11:35 -08:00
Jakub Konka
2128149325 macho: update DebugSymbols to include DATA_CONST seg 2021-01-13 23:56:05 +01:00
Jakub Konka
4ffa8952cc macho: add x86_64 tests 2021-01-13 23:55:56 +01:00
Jakub Konka
2ea0901dd6 macho: properly populate offset into lazy bind info 2021-01-13 23:55:48 +01:00
Jakub Konka
f0d7ec6f33 macho: add x86_64 support 2021-01-13 23:55:37 +01:00
Jakub Konka
1b91a9f4c8 macho: bring back lld cc hot-fix 2021-01-13 23:55:28 +01:00
Jakub Konka
7d40aaad2b macho: document more code + add test case 2021-01-13 23:55:18 +01:00
Jakub Konka
b86d0e488b macho: refactor writing and managing externs 2021-01-13 23:55:06 +01:00
Jakub Konka
21c7217e09 macho: memorize start of stubs in helper 2021-01-13 23:54:56 +01:00
Jakub Konka
44a052a65f macho: write out stubs for new externs only 2021-01-13 23:54:46 +01:00
Jakub Konka
2f7cd71193 macho: fully working PoC with main and exit 2021-01-13 23:54:31 +01:00
Jakub Konka
bb691ea16b macho: first working draft of externs on macOS 2021-01-13 23:54:22 +01:00
Jakub Konka
6d2a6513f9 macho: write out binding info 2021-01-13 23:54:11 +01:00
Jakub Konka
5ae82956aa macho: write out rebase info 2021-01-13 23:54:01 +01:00
Jakub Konka
f44732c1b0 macho: populate stubs and stub_helper 2021-01-13 23:53:46 +01:00
Jakub Konka
51a13f8ea6 macho: add missing data sections 2021-01-13 23:53:36 +01:00
Jakub Konka
3d07f057b1 macho: prealloc DATA_CONST and DATA segments 2021-01-13 23:53:25 +01:00
Jakub Konka
5487dd13ea stage2: lay the groundwork in prep for extern fn
This commit lays the groundwork in preparation for implementing
handling of extern functions in various backends.
2021-01-13 14:51:23 -08:00