Commit Graph

1488 Commits

Author SHA1 Message Date
Andrew Kelley 3178807657 Merge remote-tracking branch 'origin/master' into llvm10 2020-03-04 15:35:46 -05:00
Timon Kruiper e095475d92 Fix docs generation
Commit edb210905d caused the docs generation
to fail, because all the type information in pass1 was already freed in
`zig_llvm_emit_output`.
2020-03-04 09:59:21 -05:00
Andrew Kelley d1cb16aace Merge remote-tracking branch 'origin/master' into llvm10 2020-03-03 09:44:13 -05:00
Andrew Kelley 7617610400 Merge pull request #4550 from ziglang/os-version-ranges
introduce operating system version ranges as part of the target; self-host native dynamic linker detection and native glibc version detection
2020-02-29 01:57:06 -05:00
Alexandros Naskos 1b41f2d77e C pointer slices are no longer allowzero (#4462)
* Slices from C pointers are no longer allowzero but instead insert a runtime assertion.

* Added a test, fixed code for cases with non-allowzero C pointers

* Create new type when flipping allow_zero, sometimes we get a cached value back from adjust_ptr_len.

* Added comments, changed panic message

* Added runtime safety test.
2020-02-29 01:36:42 -05:00
Andrew Kelley 500dde32d5 dynamic_linker becomes a field of std.zig.CrossTarget 2020-02-28 14:51:56 -05:00
Andrew Kelley ef24f2dd93 remove special darwin os version min handling
now it is integrated with zig's target OS range.
2020-02-28 14:51:56 -05:00
Andrew Kelley 4616af0ca4 introduce operating system version ranges as part of the target
* re-introduce `std.build.Target` which is distinct from `std.Target`.
   `std.build.Target` wraps `std.Target` so that it can be annotated as
   "the native target" or an explicitly specified target.
 * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a
   struct which has the tag as well as version range information.
 * `std.elf` gains some more ELF header constants.
 * `std.Target.parse` gains the ability to parse operating system
   version ranges as well as glibc version.
 * Added `std.Target.isGnuLibC()`.
 * self-hosted dynamic linker detection and glibc version detection.
   This also adds the improved logic using `/usr/bin/env` rather than
   invoking the system C compiler to find the dynamic linker when zig
   is statically linked. Related: #2084
   Note: this `/usr/bin/env` code is work-in-progress.
 * `-target-glibc` CLI option is removed in favor of the new `-target`
   syntax. Example: `-target x86_64-linux-gnu.2.27`

closes #1907
2020-02-28 14:51:53 -05:00
Andrew Kelley 62de32a18c call deinit on the hashmaps introduced in the prev commit 2020-02-26 11:21:10 -05:00
Vexu 215797749d fix @intToEnum on extern enums 2020-02-26 11:19:40 -05:00
Vexu d505ea6caf fix @tagName on extern and non-exhaustive enums 2020-02-26 11:19:39 -05:00
Andrew Kelley f33bf48af7 Merge remote-tracking branch 'origin/master' into llvm10 2020-02-25 16:30:40 -05:00
Vexu d56115ef41 remove @IntType and @ArgType (mostly) from the compiler 2020-02-25 01:27:34 +02:00
Vexu 3458fb891d remove @typeId, @memberCount, @memberName and @memberType from the compiler 2020-02-24 23:21:11 +02:00
Andrew Kelley 1d06c82c3b Merge pull request #4516 from xackus/remove-bytes-to-slice
remove @bytesToSlice, @sliceToBytes from the language
2020-02-24 13:51:47 -05:00
xackus 9c35f680f7 nuke @bytesToSlice, @sliceToBytes in stage1 2020-02-23 19:03:55 +01:00
Andrew Kelley 61c67a9833 remove sub-arch from stage1 2020-02-21 11:47:34 -05:00
Andrew Kelley 7c298c8c17 fix generation of builtin import 2020-02-19 22:09:25 -05:00
Andrew Kelley 84f1893c18 remove the concept of "sub-architecture"
in favor of CPU features. Also rearrange the `std.Target`
data structure.

 * note: `@import("builtin")` was already deprecated in favor of
   `@import("std").builtin`.
 * `std.builtin.arch` is now deprecated in favor of
   `std.builtin.cpu.arch`.
 * `std.Target.CpuFeatures.Cpu` is now `std.Target.Cpu.Model`.
 * `std.Target.CpuFeatures` is now `std.Target.Cpu`.
 * `std.Target` no longer has an `arch` field. Instead it has a
   `cpu` field, which has `arch`, `model`, and `features`.
 * `std.Target` no longer has a `cpu_features` field.
 * `std.Target.Arch` is moved to `std.Target.Cpu.Arch` and
   it is an enum instead of a tagged union.
 * `std.Target.parseOs` is moved to `std.Target.Os.parse`.
 * `std.Target.parseAbi` is moved to `std.Target.Abi.parse`.
 * `std.Target.parseArchSub` is only for arch now and moved
    to `std.Target.Cpu.Arch.parse`.
 * `std.Target.parse` is improved to accept CPU name and features.
 * `std.Target.Arch.getBaselineCpuFeatures` is moved to
   `std.Target.Cpu.baseline`.
 * `std.Target.allCpus` is renamed to `std.Target.allCpuModels`.
 * `std.Target.defaultAbi` is moved to `std.Target.Abi.default`.
 * Significant cleanup of aarch64 and arm CPU features, resulting in
   the needed bit count for cpu feature set going from 174 to 138.
 * Add `std.Target.Cpu.Feature.Set.addFeatureSet` for merging
   feature sets together.

`-target-feature` and `-target-cpu` are removed in favor of
`-mcpu`, to conform to established conventions, and it gains
additional power to support cpu features. The syntax is:
-mcpu=name+on1+on2-off1-off2

closes #4261
2020-02-19 21:30:36 -05:00
Andrew Kelley d7968c6d33 improvements which allow zig to emit multiple things at once
example: zig build-obj test.zig -femit-llvm-ir -femit-asm

this will generate all three: test.o test.s test.ll
2020-02-18 21:59:43 -05:00
Noam Preil 2502cb242a Improve support for generating LLVM IR/asm files 2020-02-18 18:59:45 -05:00
Andrew Kelley 99520c4e69 target_os_requires_libc implies dynamic linking 2020-02-17 19:49:19 -05:00
Andrew Kelley 9b02cab3da fix glibc not forcing dynamic link 2020-02-17 16:37:22 -05:00
Andrew Kelley a959e98273 target requiring PIC does not imply dynamic linking
Related: #3237
2020-02-17 16:16:58 -05:00
Andrew Kelley e26f063b22 support the concept of a target not having a dynamic linker 2020-02-17 15:46:53 -05:00
Andrew Kelley 2f9c5c0644 self-host dynamic linker detection 2020-02-17 15:23:59 -05:00
Andrew Kelley 20f3b0efff rename libuserland to libstage2 2020-02-16 19:16:08 -05:00
Andrew Kelley 4b02a39aa9 self-hosted libc detection
* libc_installation.cpp is deleted.
   src-self-hosted/libc_installation.zig is now used for both stage1 and
   stage2 compilers.
 * (breaking) move `std.fs.File.access` to `std.fs.Dir.access`. The API
   now encourages use with an open directory handle.
 * Add `std.os.faccessat` and related functions.
 * Deprecate the "C" suffix naming convention for null-terminated
   parameters. "C" should be used when it is related to libc. However
   null-terminated parameters often have to do with the native system
   ABI rather than libc. "Z" suffix is the new convention. For example,
   `std.os.openC` is deprecated in favor of `std.os.openZ`.
 * Add `std.mem.dupeZ` for using an allocator to copy memory and add a
   null terminator.
 * Remove dead struct field `std.ChildProcess.llnode`.
 * Introduce `std.event.Batch`. This API allows expressing concurrency
   without forcing code to be async. It requires no Allocator and does
   not introduce any failure conditions. However it is not thread-safe.
 * There is now an ongoing experiment to transition away from
   `std.event.Group` in favor of `std.event.Batch`.
 * `std.os.execvpeC` calls `getenvZ` rather than `getenv`. This is
   slightly more efficient on most systems, and works around a
   limitation of `getenv` lack of integration with libc.
 * (breaking) `std.os.AccessError` gains `FileBusy`, `SymLinkLoop`, and
   `ReadOnlyFileSystem`. Previously these error codes were all reported
   as `PermissionDenied`.
 * Add `std.Target.isDragonFlyBSD`.
 * stage2: access to the windows_sdk functions is done with a manually
   maintained .zig binding file instead of `@cImport`.
 * Update src-self-hosted/libc_installation.zig with all the
   improvements that stage1 has seen to src/libc_installation.cpp until
   now. In addition, it now takes advantage of Batch so that evented I/O
   mode takes advantage of concurrency, but it still works in blocking
   I/O mode, which is how it is used in stage1.
2020-02-16 13:25:30 -05:00
Andrew Kelley 7f7d1fbe5a Implement noasync awaits
Note that there is not yet runtime safety for this.

See #3157
2020-02-16 01:44:52 -05:00
Andrew Kelley 72805fd66e fix taking address of temporary async frame 2020-02-16 01:44:49 -05:00
Andrew Kelley a8b36fbe34 Merge remote-tracking branch 'origin/master' into llvm10 2020-02-14 10:27:44 -05:00
Michael Dusan edb210905d stage1: memory/report overhaul
- split util_base.hpp from util.hpp
- new namespaces: `mem` and `heap`
- new `mem::Allocator` interface
- new `heap::CAllocator` impl with global `heap::c_allocator`
- new `heap::ArenaAllocator` impl
- new `mem::TypeInfo` extracts names without RTTI
- name extraction is enabled w/ ZIG_ENABLE_MEM_PROFILE=1
- new `mem::List` takes explicit `Allocator&` parameter
- new `mem::HashMap` takes explicit `Allocator&` parameter
- add Codegen.pass1_arena and use for all `ZigValue` allocs
- deinit Codegen.pass1_arena early in `zig_llvm_emit_output()`
2020-02-10 21:08:08 -05:00
Andrew Kelley cdc5070f21 Merge remote-tracking branch 'origin/master' into llvm10 2020-02-10 00:26:33 -05:00
Andrew Kelley 014f66e6de Merge pull request #4404 from ziglang/async-std
a big step towards std lib integration with async I/O
2020-02-10 00:22:59 -05:00
Andrew Kelley 04ee3b01a1 fix defer interfering with return value spill 2020-02-09 17:19:28 -05:00
Andrew Kelley 884804dbc3 fix async runtime function call resolves target fn frame 2020-02-08 13:45:31 -05:00
Jared Miller b55bc5eb26 Add wWinMain and wWinMainCRTStartup to fix #4376 2020-02-07 22:52:40 -05:00
Andrew Kelley 877f39d227 fix async function call resolves target fn frame 2020-02-07 22:48:31 -05:00
Andrew Kelley 4a60689309 more carefully calculate llvm field indexes
more correctly solves #4403
2020-02-07 14:54:58 -05:00
LemonBoy 8d6536b50c codegen: Use the new frame-pointer fn attributes
no-frame-pointer-elim and no-frame-pointer-elim-non-leaf have been
deprecated for a while in favour of the newer (and clearer)
frame-pointer attribute.

Starting with LLVM10 the old attributes are silently ignored, leading to
no stack traces in debug mode.
2020-02-07 17:08:21 +01:00
Andrew Kelley 0b5bcd2f56 more std lib async I/O integration
* `zig test` gainst `--test-evented-io` parameter and gains the ability
   to seamlessly run async tests.
 * `std.ChildProcess` opens its child process pipe with O_NONBLOCK when
   using evented I/O
 * `std.io.getStdErr()` gives a File that is blocking even in evented
   I/O mode.
 * Delete `std.event.fs`. The functionality is now merged into `std.fs`
   and async file system access (using a dedicated thread) is
   automatically handled.
 * `std.fs.File` can be configured to specify whether its handle is
   expected to block, and whether that is OK to block even when in
   async I/O mode. This makes async I/O work correctly for e.g. the
   file system as well as network.
 * `std.fs.File` has some deprecated functions removed.
 * Missing readv,writev,pread,pwrite,preadv,pwritev functions are added
   to `std.os` and `std.fs.File`. They are all integrated with async
   I/O.
 * `std.fs.Watch` is still bit rotted and needs to be audited in light
   of the new async/await syntax.
 * `std.io.OutStream` integrates with async I/O
 * linked list nodes in the std lib have default `null` values for
   `prev` and `next`.
 * Windows async I/O integration is enabled for reading/writing file
   handles.
 * Added `std.os.mode_t`. Integer sizes need to be audited.
 * Fixed #4403 which was causing compiler to crash.

This is working towards:

./zig test ../test/stage1/behavior.zig --test-evented-io

Which does not successfully build yet. I'd like to enable behavioral
tests and std lib tests with --test-evented-io in the test matrix in the
future, to prevent regressions.
2020-02-06 18:05:50 -05:00
Andrew Kelley 704cd977bd ability to run tests in evented I/O mode
This adds `--test-evented-io` as a CLI parameter.

see #3117
2020-02-05 16:53:29 -05:00
Andrew Kelley 17c8f108a4 drop @newStackCall
this was causing unrelated behavior tests to fail.

if this commit is reverted, the docs are good, but `@newStackCall` is
already deprecated in favor of `@call`, supplying the `stack` property.
2020-01-30 17:51:55 -05:00
Andrew Kelley a95dce15ae Merge remote-tracking branch 'origin/master' into llvm10 2020-01-29 23:33:12 -05:00
Valentin Anger d448c3d38a Add support for code model selection 2020-01-29 16:09:07 -05:00
Andrew Kelley e0000c47bd fix regression of storing optional with 0-bit payload 2020-01-28 12:32:39 -05:00
Andrew Kelley c58633ef17 fix assertion with var debug loc not initialized 2020-01-27 20:56:24 -05:00
Andrew Kelley c0fee9dfc7 fix nested bitcast passed as tuple element 2020-01-27 17:30:39 -05:00
Andrew Kelley e2778c03e0 Merge branch 'master' into ir-clean-up-vars 2020-01-27 13:32:39 -05:00
Andrew Kelley 9dffc369f1 Merge remote-tracking branch 'origin/master' into layneson-cpus_and_features 2020-01-25 23:25:29 -05:00