5856 Commits

Author SHA1 Message Date
Andrew Kelley
a9cd9b021b Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
I want the updated Drone CI stuff to get the CI green.
2021-05-18 12:37:03 -07:00
Andrew Kelley
ab8f8465a3 stage2: fix deletion of Decls that get re-referenced
When scanDecls happens, we create stub Decl objects that
have not been semantically analyzed. When they get referenced,
they get semantically analyzed.

Before this commit, when they got unreferenced, they were completely
deleted, including deleted from the containing Namespace.

However, if the update did not cause the containing Namespace to get
deleted, for example, if `std.builtin.ExportOptions` is no longer
referenced, but `std.builtin` is still referenced, and then `ExportOptions`
gets referenced again, the Namespace would be incorrectly missing the
Decl, so we get an incorrect "no such member" error.

The solution is to, when dealing with a no longer referenced Decl
objects during an update, clear them to the state they would be in
on a fresh scanDecl, rather than completely deleting them.
2021-05-18 12:35:36 -07:00
Jakub Konka
cb45c5521a zld: refactor warnings 2021-05-18 09:28:00 +02:00
Jakub Konka
daaec68aec zld: apply @mikdusan's suggestions
Library search paths now should be closer to what ld64 does.
Also, cwd now has to be specified explicitly to be considered.
2021-05-18 09:28:00 +02:00
Jakub Konka
1dac5f5214 zld: parse dylibs as positionals
* add preliminary rpath support
* enable shared_library test on x86_64 macOS
2021-05-18 09:28:00 +02:00
Jakub Konka
ca772735c3 zld: refactor order of searching for the dylibs
Current assumed order is:
* cwd
* `self.base.options.lib_dirs`
* finally, if `self.base.options.syslibroot` is defined,
  `self.base.options.lib_dirs` prefixed with syslibroot
2021-05-18 09:28:00 +02:00
Jakub Konka
73c015b956 zld: parse dylib id 2021-05-18 09:28:00 +02:00
Jakub Konka
17b2588598 zld: refactor out logic for dylib LC creation 2021-05-18 09:28:00 +02:00
Jakub Konka
138cecc028 zld: add prelim way of linking dylibs
The support is minimalistic in the sense that we only support actual
dylib files and not stubs/tbds yet, and we also don't support re-exports
just yet.
2021-05-18 09:28:00 +02:00
Evan Haas
35c694d614 translate-c: Demote initialization of opaque types
This fixes a segfault in translate-c that would previously occur when
initializing structs with unnamed bitfields, due to a failed assertion in
`transInitListExprRecord`. Unnamed bitfields do not have initializers,
so `transInitListExprRecord` erroneously assumes that `init_count` equals
the number of fields in the record.

Since attempting to initialize an opaque type is a syntax error in Zig,
we can just demote any attempts to initialize them.
2021-05-18 09:04:19 +03:00
Andrew Kelley
615d45da77 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * src/codegen/spirv.zig
 * src/link/SpirV.zig

We're going to want to improve the stage2 test harness to print
the source file name when a compile error occurs otherwise std lib
contributors are going to see some confusing CI failures when they cause
stage2 AstGen compile errors.
2021-05-17 19:30:38 -07:00
Andrew Kelley
1d808d0dd2 stage2: fix crash in switch compile error
when the AST for the switch has never been loaded
2021-05-17 19:11:11 -07:00
Andrew Kelley
0dd0c9620d
Merge pull request #8796 from Snektron/spirv
SPIR-V: Codegen basis
2021-05-17 21:25:02 -04:00
Andrew Kelley
67f5a28257 Sema: use a hash map for ZIR->AIR mapping
Previously, ZIR was per-function so we could simply allocate a slice for
all ZIR instructions. However now ZIR is whole-file, so we need a sparse
mapping of ZIR to AIR instructions in order to not waste memory.
2021-05-17 17:39:52 -07:00
Andrew Kelley
5cacc446c4 stage2: update @import("builtin") API usage 2021-05-17 17:39:26 -07:00
Andrew Kelley
731c35f15a stage2: get rid of NameHash
Previously, stage2 used a global decl_table for all Decl objects, keyed
by a 16-byte name hash that was hopefully unique. Now, there is a tree
of Namespace objects that own their named Decl objects.
2021-05-17 16:09:20 -07:00
Andrew Kelley
3d99fb3352 stage2: get rid of DeclRef 2021-05-17 16:09:20 -07:00
Andrew Kelley
d5e894a9a7 stage2: get rid of failed_root_src_file 2021-05-17 16:09:20 -07:00
joachimschmidt557
65cee0b3fd stage2 ARM: correct spilling in genArmMul as well 2021-05-17 17:18:01 -04:00
LemonBoy
fe1a166589 translate-c: Add @truncate where needed
Make getLimitedValue API much easier to use with zig.
Fixes the compilation on 32bit hosts.
2021-05-17 17:15:22 -04:00
Andrew Kelley
23fd15fd76 link/Elf: remove unintended link again libunwind
This was a merge conflict with master branch. The logic for linking
libunwind is already handled above.
2021-05-17 13:56:17 -07:00
Andrew Kelley
8405d6f7e2 link/MachO: bring in some of the Elf logic
There was missing incremental compilation logic in the MachO linker
code, causing test failures. With this logic ported over from the
corresponding ELF logic, tests pass again.
2021-05-17 13:46:54 -07:00
Andrew Kelley
3697022a41 stage2: avoid calling freeDecl when hasCodeGenBits == false
Previously the frontend incorrectly called freeDecl for structs, which
never got allocateDecl called for them. There was simply a missing check
for hasCodeGenBits().
2021-05-17 13:44:20 -07:00
Andrew Kelley
d839835273 stage2: add some debug logs for when link functions are called 2021-05-17 11:33:21 -07:00
Andrew Kelley
751bb12a96 stage2: fix error message coloring
After 7a4b53fdee89f2d61cedbb3cef3bda24dacf2a57, bold no longer changes
the color back, so we need an extra reset.
2021-05-16 14:31:55 -07:00
Andrew Kelley
f4ee46e839 MachO/DebugSymbols: fix debug line offset
In c8b78706b74d16ed21113096d2b47717abb53d4d I incorrectly made it be the
line offset from Decl to function lbrace; it needed to be line offset
from lbrace to rbrace.
2021-05-16 14:20:51 -07:00
Robin Voetter
880473dc3f SPIR-V: Unary not operation 2021-05-16 14:55:09 +02:00
Robin Voetter
489b3ef7d4 SPIR-V: bool binary operations 2021-05-16 14:52:11 +02:00
Robin Voetter
585122b1ac SPIR-V: comparison and equality operations 2021-05-16 14:46:58 +02:00
Robin Voetter
f14000c7e1 SPIR-V: More bitwise binary operations 2021-05-16 14:20:18 +02:00
Robin Voetter
4735e95d16 SPIR-V: More binary operations 2021-05-16 14:20:12 +02:00
Robin Voetter
10678af876 SPIR-V: genBinOp setup 2021-05-16 14:13:23 +02:00
Robin Voetter
ae2e21639a SPIR-V: Some initial floating point constant generation 2021-05-16 14:13:23 +02:00
Robin Voetter
cbf5280f54 SPIR-V: Some instructions + constant generation setup 2021-05-16 14:13:23 +02:00
Robin Voetter
da0cc732ea SPIR-V: Function parameter generation 2021-05-16 14:13:23 +02:00
Robin Voetter
074cb9f1da SPIR-V: OpFunction/OpFunctionEnd generation 2021-05-16 14:13:23 +02:00
Robin Voetter
4403f3598a SPIR-V: Proper floating point type generation 2021-05-16 14:13:23 +02:00
Robin Voetter
38cdfebad3 SPIR-V: Function prototype generation 2021-05-16 14:13:23 +02:00
Robin Voetter
458c338aeb SPIR-V: Compute backing integer bits 2021-05-16 14:13:23 +02:00
Robin Voetter
de6df2bc12 SPIR-V: Restructure codegen a bit 2021-05-16 14:13:23 +02:00
Andrew Kelley
c8b78706b7 linker: update MachO DebugSymbols to use the new line/column Decl API 2021-05-16 00:04:16 -07:00
Andrew Kelley
ae04ec776d Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Need that _main -> main improvement
2021-05-16 00:00:36 -07:00
Jakub Konka
6461b95163 macho: fix DWARF in dSYM and sym naming more consistent
* Advance line and PC prior to ending sequence in debug line program
  for a fn_decl. This is equivalent to closing scope in the debugger
  and without it, the debugger will not map source-to-address info
  as a result will not print the source when breaking at a symbol.
* Fix debug aranges sentinels to be of the size as the actual tuple
  descriptor (assuming segment selector to be ommitted). In summary,
  the sentinels were 32bit 0s, whereas they ought to be 64bit 0s.
* Make naming of symbols in the binary more consistent by prefixing
  each symbol name with an underscore '_'.
2021-05-16 08:12:29 +02:00
Andrew Kelley
597082adf4 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * src/Compilation.zig
 * src/codegen/spirv/spec.zig
 * src/link/SpirV.zig
 * test/stage2/darwin.zig
   - this one might be problematic; start.zig looks for `main` in the
     root source file, not `_main`. Not sure why there is an underscore
     there in master branch.
2021-05-15 21:44:38 -07:00
Andrew Kelley
07606d12da stage2: remove SPU Mark II backend
As it stands, the backend is incomplete, and there is no active contributor,
making it dead weight.

However, anyone is free to resurrect this backend at any time.
2021-05-15 21:25:42 -07:00
Andrew Kelley
7cd94d2123 stage2: omit Decl compile errors from failed AstGen files
Just like when new parse errors occur during an update, when new AstGen
errors occur during an update, we do not reveal compile errors for Decl
objects which are inside of a newly failed File. Once the File passes
AstGen successfully, it will be compared with the previously succeeded
ZIR and the saved Decl compile errors will be handled properly.
2021-05-15 21:20:06 -07:00
Andrew Kelley
dc036f5b6f codegen: implement const value rendering for ints <= 64 bits 2021-05-15 21:00:15 -07:00
Isaac Freund
d98e39fa68 stage2: make failure to find native libc verbose 2021-05-15 22:13:28 +02:00
Evan Haas
36da8d02b5 translate-c: translate global (file scope) assembly 2021-05-15 11:53:01 +03:00
Andrew Kelley
5769ed2d44 stage2: compile log stores node offset
Previously, compile log stored full SrcLoc info, which included absolute
AST node index. This becomes invalid after an incremental compilation.
To make it survive incremental compilation, store an offset from parent
Decl instead.
2021-05-14 23:10:38 -07:00