Commit Graph

15221 Commits

Author SHA1 Message Date
Andrew Kelley
f3ebfcae38 Merge remote-tracking branch 'origin/master' into llvm13
Conflicts:

 * cmake/Findclang.cmake
 * cmake/Findlld.cmake
 * cmake/Findllvm.cmake

In master branch, more search paths were added to these files with "12"
in the path. In this commit I updated them to "13".

 * src/stage1/codegen.cpp
 * src/zig_llvm.cpp
 * src/zig_llvm.h

In master branch, ZigLLVMBuildCmpXchg is improved to add
`is_single_threaded`. However, the LLVM 13 C API has this already, and
in the llvm13 branch, ZigLLVMBuildCmpXchg is deleted in favor of the C
API. In this commit I updated stage2 to use the LLVM 13 C API rather
than depending on an improved ZigLLVMBuildCmpXchg.

Additionally, src/target.zig largestAtomicBits needed to be updated to
include the new m68k ISA.
2021-09-15 14:51:08 -07:00
Andrew Kelley
0395b35cee stage2: implement cmpxchg and improve comptime eval
* Implement Sema for `@cmpxchgWeak` and `@cmpxchgStrong`. Both runtime
   and comptime codepaths are implement.
 * Implement Codegen for LLVM backend and C backend.
 * Add LazySrcLoc.node_offset_builtin_call_argX 3...5
 * Sema: rework comptime control flow.
   - `error.ComptimeReturn` is used to signal that a comptime function
     call has returned a result (stored in the Inlining struct).
     `analyzeCall` notices this and handles the result.
   - The ZIR instructions `break_inline`, `block_inline`,
     `condbr_inline` are now redundant and can be deleted. `break`,
     `block`, and `condbr` function equivalently inside a comptime scope.
   - The ZIR instructions `loop` and `repeat` also are modified to
     directly perform comptime control flow inside a comptime scope,
     skipping an unnecessary mechanism for analysis of runtime code.
     This makes Zig perform closer to an interpreter when evaluating
     comptime code.
 * Sema: zirRetErrValue looks at Sema.ret_fn_ty rather than sema.func
   for adding to the inferred error set. This fixes a bug for
    inlined/comptime function calls.
 * Implement ZIR printing for cmpxchg.
 * stage1: make cmpxchg respect --single-threaded
   - Our LLVM C++ API wrapper failed to expose this boolean flag before.
 * Fix AIR printing for struct fields showing incorrect liveness data.
2021-09-14 21:58:22 -07:00
Travis Martin
5d14590ed1 Remove WIN16 version of WSAOVERLAPPED. Use LPWSAOVERLAPPED_COMPLETION_ROUTINE 2021-09-14 15:36:08 -04:00
Jacob G-W
370be12652 plan9 linker: fix for 32 bit 2021-09-14 19:04:09 +03:00
Jonathan Marler
010ca69864
add functions to decode an epoch timestamp (#9040)
* add functions to decode an epoch timestamp

The code added here is alternative to the libc gmtime function. This function takes a unix epoch timestamp and decodes it into things like the year/day/time/etc. I looked at various libc implementations to see how it was implemented and this appears to be correct. I reorganized it so that applications can choose which data they need rather than calcualting it all in a single function. The data structures layout the order of operations required to decode various things like the year/month or time of day.

* set Month.jan to 1 instead of 0 to avoid +1 in conversion to numeric

* add another test

* remove unnecessary comptimeMod
2021-09-14 19:02:23 +03:00
Jakub Konka
85f065a511
Merge pull request #9676 from ziglang/zld-incr
MachO: merges stage1 with self-hosted codepath
2021-09-14 14:20:11 +02:00
Philipp Lühmann
d1908c9f66
zig fmt: Keep callconv(.Inline) on function pointer types
Co-authored-by: Philipp Lühmann <mail@philipp.lu>
2021-09-14 11:36:26 +02:00
Jakub Konka
05763f43b3 macho: disable splitting sections into atoms in release
since we don't actually benefit from it just yet, and getting
it right for release and dead code stripping will require some more
thought put into it.
2021-09-14 10:28:58 +02:00
Andrew Kelley
264acfdf3c stage2: fix incorrect spelling of AtomicOrder 2021-09-13 22:01:40 -07:00
Andrew Kelley
97d69e3352 stage2: add array_to_slice AIR instruction 2021-09-13 21:37:11 -07:00
Andrew Kelley
a9a21c5988 stage2: Type/Value use an enum rather than usize
Makes debugging nicer when you want to look at Type/Value
2021-09-13 21:14:40 -07:00
Andrew Kelley
5529febab0 stage2: implement Value.copy for structs and unions
The stage2_os hack inside `@import("builtin")` is no longer needed.
2021-09-13 20:11:35 -07:00
Andrew Kelley
111a2dcf3a update libunwind to llvm release/13.x
upstream commit 2aa67b31faf087cd5a6df8aa4262b17bdc41bba7
2021-09-13 15:59:24 -07:00
Jakub Konka
a38b636045 Merge remote-tracking branch 'origin/master' into zld-incr 2021-09-13 23:40:38 +02:00
Jakub Konka
760241ce50 macho: use the cache system to know if need to relink objects
This applies to stage2 where we make use of the cache system to work
out if we need to relink objects when performing incremental updates.
When the process is restarted however, while in principle the idea is
to carry on where we left off by reparsing the prelinked binary from
file, the required machinery is not there yet, and therefore we always
fully relink upon restart.
2021-09-13 23:02:21 +02:00
Jakub Konka
46a10401f0 macho: fix logic for updating exports in incremental codepath 2021-09-13 22:11:20 +02:00
lucky
f011f13933
fix missing paths (#9754)
increase bcrypt benchmark rounds

Co-authored-by: lucky <>
2021-09-13 17:31:17 +02:00
Jakub Konka
4c36da1047 macho: fix incremental compilation 2021-09-13 17:00:36 +02:00
Jakub Konka
1965465ced macho: split resolveSymbols into standalone functions 2021-09-13 13:19:08 +02:00
Jakub Konka
50e34a063c
Merge pull request #9734 from Andoryuuta/macho-zld-win-filepath
link/include: fix invalid file path concatenation when cross-compiling for Windows -> Mac
2021-09-13 09:04:11 +02:00
Kenta Iwasaki
c4f97d3365 os: usingnamespace fixes for std.x.os.Socket and std.os.TCP
Extract existing constants to do with TCP socket options into a 'TCP'
namespace.

Export 'MSG' and 'TCP' from std.os.{linux, windows} into std.c.

Fix compile errors to do with std.x.os.Socket methods related to setting
TCP socket options.

Handle errors in the case that an interface could not be resolved in an
IPv6 address on Windows. Tested using Wine with the loopback interface
disabled.

Have all instantiations of std.x.os.Socket on Windows instantiate an
overlapped socket descriptor. Fixes the '1ms read timeout' test in
std.x.net.tcp.Client. The test would previously deadlock, as read
timeouts only apply to overlapped sockets.

Windows documentation by default recommends that most instantiations of
sockets on Windows be overlapped sockets (s.t. they may operate in both
blocking or nonblocking mode when operated with WSA* syscalls). Refer to
the documentation for WSASocketA for more info.
2021-09-12 23:36:44 -04:00
Andrew Gutekanst
ffb9891695 Fix same issue with dir/sysroot dir concatenation with includes on Windows 2021-09-12 19:35:03 -04:00
Andrew Gutekanst
62a6d83da1 Address feedback 2021-09-12 19:34:06 -04:00
Silver
2118566931 std: publicize ArrayListUnmanaged.allocatedSlice to match ArrayList 2021-09-12 19:32:40 +03:00
Jakub Konka
7aa6064638 macho: insert rpaths upon parsing
Also, insert empty data-in-code lc in populateMissingMetadata fn.
2021-09-11 14:18:09 +02:00
Jakub Konka
054fe96bcd macho: enable tracy in more places within the linker 2021-09-11 12:25:00 +02:00
Andrew Gutekanst
6734271eb0 link: fix invalid file path used when cross-compiling for Windows -> Mac
While investigating hexops/mach#8 with @slimsag,
we found that zld is forming invalid file paths (absolute paths concatenated together),
which hits the unreachable `OBJECT_NAME_INVALID` case in `openDirAccessMaskW`:
0c091feb5a/lib/std/fs.zig (L1522)

This is caused by appending `dir` (which is guaranteed to be absolute) to `root`,
an obviously incorrect operation:
0c091feb5a/src/link/MachO.zig (L494-L499)

Fixes hexops/mach#8

Co-authored-by: Stephen Gutekanst <stephen@hexops.com>
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Signed-off-by: Andrew Gutekanst <andrew.gutekanst@gmail.com>
2021-09-10 23:55:13 -04:00
Jakub Konka
31dcb0dde7 macho: change all occurrences of TextBlock into Atom
and unify allocateAtom with allocateTextBlock.
2021-09-11 02:03:25 +02:00
Jakub Konka
6e0c3950b8 macho: rename blocks to atoms in Object.zig 2021-09-10 22:42:39 +02:00
Mr. Paul
0c091feb5a Improve HTML semantics and a11y of language reference
The language reference's HTML has been updated to be more semantically correct.
This also helps to improve the document's accessibility concerns.

* Document structure has single h1, other header sections start at h2, nav sections w/ aria labels, main section
* Zig's homepage is linked, Zig Standard Library section link to it
* Tables have caption and scoping rows and columns
* Code blocks are figures with figure captions citing source files
* Change line height 1.5 to include table of contents as well
* Luminosity contrast ratios have been adjusted to 7:1
* Dark mode colors adjusted to reduce eye strain
* Links have default browser underline with hover and focus effects
* Asides, definition lists, keyboard inputs, program outputs are represented semantically

Tools used to check:
WAVE plugin https://wave.webaim.org/
Firefox Accessibility Developer Tool
Lighthouse Accessibility Tool
2021-09-10 14:23:32 -04:00
Luuk de Gram
9e24727062
Fix compile error for p256 scalar arithmetic (#9715) 2021-09-10 15:41:15 +02:00
Jakub Konka
8e5f7f5fe8 macho: write adjacent atoms to in-memory buffer
and then commit the large buffer into file.
2021-09-10 15:37:51 +02:00
Martin Wickham
93c6e31cf1 Fix unmatched close brace in zir dump 2021-09-09 15:34:58 -04:00
Jakub Konka
aaacfc0d0a macho: init process of renaming TextBlock to Atom
Initially, internally within the linker.
2021-09-09 18:32:03 +02:00
Jakub Konka
56fdada577 macho: properly adjust section sizes 2021-09-09 16:55:56 +02:00
lucky
3611487952
reexport crypto/phc_encoding (#9712)
Co-authored-by: lucky <>
2021-09-09 14:25:44 +02:00
Jakub Konka
1efdb137d1 macho: don't allocate atoms when parsing objects 2021-09-09 14:18:28 +02:00
Jakub Konka
23be9cae34 macho: padToIdeal each parsed section size before storing
This way, we should not need to grow at all when allocating atoms
representing objects' sections as atoms.
2021-09-09 01:13:07 +02:00
Jakub Konka
9fb44e8e1f macho: precompute total required size when parsing objects
This way, we can preallocate the necessary sizes for segments and
sections upfront rather than doing it per parsed atom.
2021-09-09 00:25:55 +02:00
FnControlOption
23c25c5eaf cmake: also check Homebrew install paths when looking for LLVM
- On Intel Macs, the path is /usr/local/opt/llvm@12
- On Silicon Macs, the path is /opt/homebrew/opt/llvm@12

This makes specifying CMAKE_PREFIX_PATH optional for Homebrew LLVM.
2021-09-08 13:48:16 -04:00
Sébastien Marie
175d95b591 openbsd: readapt event loop after usingnamespace changes 2021-09-08 13:40:43 -04:00
Andrew Kelley
6237dc0ab8
Merge pull request #9700 from marler8997/bootstrapAarch64Windows
changes to build zig-bootstrap aarch64-windows
2021-09-08 13:32:20 -04:00
Jakub Konka
e00b9d6192 macho: use smaller padding until we have branch islands on arm64
Without branch islands, it is impossible to link self-hosted using
the common linker path.
2021-09-08 13:17:43 +02:00
Jonathan Marler
343547d4a4 finalize windows_sdk paths based on snickler suggestions 2021-09-07 21:49:08 -06:00
Andrew Kelley
501e6cf2f3 ci: add 0.8.1 release to download page 2021-09-07 14:36:08 -07:00
Jakub Konka
e229202cb8 macho: store source section address of relocs in context
This is particularly relevant for x86_64 and C++ when relocating
StaticInit sections containing static initializers machine code.
Then, in case of SIGNED_X relocations, it is necessary to have the
full image of the VM address layout of the sections in the object
file as this is how the addend needs to be adjusted for non-extern
relocations.
2021-09-07 23:21:08 +02:00
Jonathan Marler
375619820e changes to build zig-bootstrap aarch64-windows 2021-09-07 14:27:50 -06:00
Andrew Kelley
d305ba7f2d
Merge pull request #9636 from ehaas/hexfiles
stdlib: Add Intel HEX support to InstallRawStep
2021-09-07 15:12:00 -04:00
Martin Wickham
3d5ff91441
Fix libc file to check against compilation target instead of native (#9670) 2021-09-07 15:11:28 -04:00
Jacob G-W
88e0f81eef plan9: change output executable name
Now object files have the `name.<target char>`
Executables are just `name`
Libs are `name.a`
2021-09-07 15:08:51 -04:00