Commit Graph

1206 Commits (555a2c03286507ffe4bd3bea2154dbfb719ebef1)

Author SHA1 Message Date
LemonBoy c5885f012a std: Fix version detection on x86
Call xgetbv only if X{SAVE,RESTORE} and AVX are detected.

Closes #4670
2020-03-07 18:53:34 -05:00
Andrew Kelley c25d9417d3
fix std.fs.makeDirAbsolute
closes #4671
2020-03-07 15:14:47 -05:00
Andrew Kelley 80ff549e26
fix detectNativeCpuAndFeatures including foreign asm 2020-03-06 21:03:23 -05:00
Andrew Kelley e0d5f94a70
simplify the inline assembly 2020-03-06 20:02:08 -05:00
Andrew Kelley 49817c6add
cleanup CPU model & feature detection
Add std.Target.Cpu.Model.generic which is even more empty than baseline.
CPU model and feature detection uses this rather than baseline.

Rename cpu_detected to cpu_detection_unimplemented and flip the logic.
It can be relied on by stage2.zig to decide whether the LLVM workaround
is needed without also checking the CrossTarget.

Move the CPU detection to after the OS detection, and use the detected
OS for the CPU detection. This is relevant because operating systems
sometimes emulate certain CPU features, so knowing the OS and version is
relevant for determining CPU features.

Prepare for #4592 by passing the CPU arch to the detection code, instead
of having it rely on Target.current.

The CPU model & feature detection logic is modified. Before:

 * Detect actual features
 * Use as hint when detecting CPU model
 * Populate dependencies of CPU model features
 * Merge that into the actual features set

After:

 * Detect actual features
 * Use as hint when detecting CPU model
 * Add known CPU model features to actual features
 * Detect actual features again, overriding known CPU model features
 * Populate dependencies
2020-03-06 19:47:03 -05:00
alichay f199182567
Cleaned up CPU detection and fixed incorrect detection bits. 2020-03-06 18:52:09 -05:00
alichay e24f29bbad
Added self-hosted x86 CPU detection. 2020-03-06 18:52:09 -05:00
Andrew Kelley 231a4b8fde
fixups & make some API decisions
Removed:
  std.io.InStream.readUntilDelimiterBuffer

Deprecated:
  std.ArrayList.toSlice
  std.ArrayList.toSliceConst
  std.ArrayList.at
  std.ArrayList.ptrAt
  std.ArrayList.setOrError
  std.ArrayList.set
  std.ArrayList.swapRemoveOrError
  std.Buffer.toSlice
  std.Buffer.toSliceConst
  std.io.InStream.readFull => std.io.InStream.readAll
  std.io.InStream.readAllBuffer

New:
  std.ArrayList.span
  std.ArrayList.expandToCapacity
  std.Buffer.span
  std.io.InStream.readUntilDelimiterArrayList
2020-03-06 18:49:13 -05:00
daurnimator 4114b63d75
std: use std.ArrayList instead of std.Buffer in std/fmt.zig tests 2020-03-06 18:49:13 -05:00
daurnimator 1cbf352cfb
Remove unused std.Buffer imports 2020-03-06 18:49:13 -05:00
daurnimator 5c0d6ef5ec
std: use ArrayList instead of Buffer from std/process.zig 2020-03-06 18:49:12 -05:00
daurnimator d136c795af
Fix bug where stdout was checked instead of stderr 2020-03-06 18:49:12 -05:00
daurnimator 8f627593eb
Use in_stream.readAllAlloc where sensible 2020-03-06 18:49:12 -05:00
daurnimator bcf56c32eb
std: use ArrayList rather than Buffer for in_stream helper functions
Buffer's behaviour of retaining a trailing 0 isn't helpful here
2020-03-06 18:49:12 -05:00
daurnimator fd23decbd9
std: add ArrayList.eql for parity with std.Buffer 2020-03-06 18:49:12 -05:00
daurnimator 119ac13eda
std: add .startsWith and .endsWith to std.ArrayList 2020-03-06 18:49:10 -05:00
Andrew Kelley fa46bcb368
stage1: make get_optional_type more robust
Now it will emit a compile error rather than crashing when the child
type has not been resolved properly.

Introduces `get_optional_type2` which should be used generally inside
ir.cpp.

Fix some std lib compile errors noticed by the provided test case.

Thanks @LemonBoy for the test case. Closes #4377.

Fixes #4374.
2020-03-06 18:30:30 -05:00
Andrew Kelley 7df9169081
Merge pull request #4651 from LemonBoy/fix-4645
std: Nicer way to access the PEB
2020-03-06 17:33:05 -05:00
Andrew Kelley 3163a16617
?HMODULE instead of HMODULE 2020-03-06 16:57:59 -05:00
LemonBoy 2e04b61275 std: Work around unexported NtCurrentTeb
Apparently NtCurrentTeb is only exported for i386 and some other
platforms but not for x86_64 nor AArch64. Let's go with the flow and
provide our own NtCurrentTeb like the Windows headers do.

Thank you Microsoft.
2020-03-06 09:17:14 +01:00
LemonBoy b9a1d67637 std: Nicer way to access the PEB
Use the NtCurrentTeb API instead of using some inline asm, this is much
nicer and also more portable.

Closes #4645
2020-03-06 09:06:26 +01:00
Michael Dusan d31b65e762 std: fix sendfile on macOS and FreeBSD
- fix std.os.sendfile/FreeBSD use correct in/out fd_t
- fix std.os.sendfile/macOS use correct in/out fd_t
- undo 1141bfb21b (no longer needed)
- fix c.freebsd.sendfile use off_t value
- fix c.freebsd.sendfile decl correct in/out fd_t
- fix c.darwin.sendfile decl correct in/out fd_t

fix signature param names
2020-03-05 20:46:28 -05:00
Michaël Larouche f5954dad83 Fix crash when freeing empty string as null-terminated sentinel 2020-03-05 17:08:12 -05:00
Michael Dusan 1091fee242 std: format enum-literals 2020-03-05 16:03:12 -05:00
daurnimator e9c3b65bf4
std: use testing.expectEqual in math.absCast tests 2020-03-05 16:02:26 +11:00
daurnimator 488ba1560f
std: fix math.absCast on i1 2020-03-05 16:00:19 +11:00
daurnimator 4f58bfe1a8
std: fix formatting of i1 integers 2020-03-05 15:52:19 +11:00
daurnimator d5359ea541
std: use testing.expectEqualSlices from tests 2020-03-05 15:51:21 +11:00
LemonBoy e029032251
std: Use @TypeOf(x,y) as return value for max 2020-03-04 17:21:10 -05:00
Andrew Kelley 6cbd1ac51a
zig is now aware of DragonflyBSD versions 2020-03-04 15:34:32 -05:00
pfg e3b37fc9c1 Generated documentation mobile support 2020-03-04 10:47:21 -05:00
Andrew Kelley 1cf3209cb8
Merge pull request #4623 from ziglang/update-glibc
Update glibc to 2.31
Closes #4459.
2020-03-04 09:01:19 -05:00
Andrew Kelley 447a89cd4d
update self-hosted `zig targets` to print correct glibc availability 2020-03-04 01:05:42 -05:00
Andrew Kelley cd33c5bfe8
zig build: update InstallRawStep to new std.fs API
closes #4622
2020-03-04 00:00:42 -05:00
Andrew Kelley 3b235cfa80
std.zig.CrossTarget: fix compile errors
closes #4620
2020-03-03 21:09:32 -05:00
Andrew Kelley 1141bfb21b Darwin can return EBADF for sendfile on non-files 2020-03-03 16:52:32 -05:00
Andrew Kelley 4a67dd04c9
breaking changes to std.fs, std.os
* improve `std.fs.AtomicFile` to use sendfile()
   - also fix AtomicFile cleanup not destroying tmp files under some
     error conditions
 * improve `std.fs.updateFile` to take advantage of the new `makePath`
   which no longer needs an Allocator.
 * rename std.fs.makeDir to std.fs.makeDirAbsolute
 * rename std.fs.Dir.makeDirC to std.fs.Dir.makeDirZ
 * add std.fs.Dir.makeDirW and provide Windows implementation of
   std.os.mkdirat. std.os.windows.CreateDirectory is now implemented
   by calling ntdll, supports an optional root directory handle,
   and returns an open directory handle. Its error set has a few more
   errors in it.
 * rename std.fs.Dir.changeTo to std.fs.Dir.setAsCwd
 * fix std.fs.File.writevAll and related functions when len 0 iovecs
   supplied.
 * introduce `std.fs.File.writeFileAll`, exposing a convenient
   cross-platform API on top of sendfile().
 * `NoDevice` added to std.os.MakeDirError error set.
 * std.os.fchdir gets a smaller error set.
 * std.os.windows.CloseHandle is implemented with ntdll call rather than
   kernel32.
2020-03-03 15:23:27 -05:00
daurnimator 1ca5f06762
Update callers of fs.makePath 2020-03-03 13:25:43 -05:00
daurnimator 695b0976c3
std: move makePath to be a Dir method 2020-03-03 13:25:43 -05:00
daurnimator a19a30bb17
std: move null byte check into toPosixPath
Note that windows NT paths *can* contain nulls
2020-03-03 13:25:43 -05:00
daurnimator d8f966a04b
std: fix fs.makePath
The previous behaviour of using path.resolve has unexpected behaviour around symlinks.
This more simple implementation is more correct and doesn't require an allocator
2020-03-03 13:25:43 -05:00
daurnimator bfc569bc98
std: add os.fstatat 2020-03-03 13:25:43 -05:00
daurnimator 627618a38d
std: add Dir.changeDir as wrapper around fchdir 2020-03-03 13:25:43 -05:00
daurnimator dfb420e6d7
std: add fs.Dir.makeDir 2020-03-03 13:25:43 -05:00
daurnimator 88e27f01c8
std: add mkdirat 2020-03-03 13:25:40 -05:00
Andrew Kelley 582db68a15
remove superfluous comptime keyword 2020-03-03 12:01:17 -05:00
LemonBoy a6fb6dcfc9 linux: Correct pread64 syscall for ARM/MIPS
Closes #4615
2020-03-03 11:59:16 -05:00
Andrew Kelley 226b801830
Merge pull request #4612 from ziglang/os-read-write-sendfile
std.os read/write functions + sendfile
2020-03-03 10:15:37 -05:00
Andrew Kelley 9d6cc75ce3
disable sendfile test on mips 2020-03-03 09:49:46 -05:00
Andrew Kelley 387418277a
Merge pull request #4601 from alexnask/fix_3997
Allow wrapping in VDSO lookup
2020-03-03 09:15:40 -05:00
Alexandros Naskos 7559418305 Added comment justifying wrapping operations 2020-03-03 12:41:11 +02:00
Andrew Kelley a66c72749a more macos fixes 2020-03-03 03:10:56 -05:00
Ryan Liptak d7579a2fcb Fix std.os.unlinkatW for absolute paths
RootDirectory can't be set in ObjectAttributes if ObjectName is an absolute path.

Fixes #4606
2020-03-03 03:07:12 -05:00
Andrew Kelley 859fc856d3
fix macosx and freebsd build failures 2020-03-03 02:57:11 -05:00
Andrew Kelley c81345c8ae
breaking: std.os read/write functions + sendfile
* rework os.sendfile and add macosx support, and a fallback
   implementation for any OS.
 * fix sendto compile error
 * std.os write functions support partial writes. closes #3443.
 * std.os pread / pwrite functions can now return `error.Unseekable`.
 * std.fs.File read/write functions now have readAll/writeAll variants
   which loop to complete operations even when partial reads/writes
   happen.
 * Audit std.os read/write functions with respect to Linux returning
   EINVAL for lengths greater than 0x7fff0000.
 * std.os read/write shim functions do not unnecessarily loop. Since
   partial reads/writes are part of the API, the caller will be forced
   to loop anyway, and so that would just be code bloat.
 * Improve doc comments
 * Add a non-trivial test for std.os.sendfile
 * Fix std.os.pread on 32 bit Linux
 * Add missing SYS_sendfile bit on aarch64
2020-03-03 02:25:26 -05:00
Terin Stock bd287dd194
std: implement sendfile on linux
This changset adds a `sendfile(2)` syscall bindings to the linux bits
component. Where available, the `sendfile64(2)` syscall will be
transparently called.

A wrapping function has also been added to the std.os to transform
errno returns to Zig errors.

Change-Id: I86769fc4382c0771e3656e7b21137bafd99a4411
2020-03-02 12:54:50 -05:00
Alexandros Naskos a48cd1cf58 Allow wrapping in VDSO lookup 2020-03-02 11:44:21 +02:00
xackus 00be934569 short std.builtin enum literals in std lib 2020-03-01 13:57:41 -05:00
Andrew Kelley ef3d761da5
breaking: std.mem.len no longer takes a type argument
also update fmt code to use std.mem.span.
2020-03-01 13:21:39 -05:00
Andrew Kelley 5b26128bac
add new functions to std.mem and deprecate others
add std.mem.Span
add std.mem.span
add std.mem.length
add std.mem.indexOfSentinel

deprecate std.mem.len
deprecate std.mem.toSlice
deprecate std.mem.toSliceConst
2020-03-01 13:07:55 -05:00
Andrew Kelley 4505857e30
revert changes outside std.fmt 2020-03-01 13:07:31 -05:00
daurnimator 0b0de22fd1
std: format contents of sentinel terminated many pointers
std: add std.meta.Sentinel to get sentinel of a type
2020-03-01 13:04:29 -05:00
Andrew Kelley ae99fabfe4
Merge pull request #4585 from LemonBoy/fix-4581
target: Implement OS version detection for Windows
2020-03-01 02:53:51 -05:00
Andrew Kelley f082e253b5 fix native OS version detection on macOS
closes #4583
2020-03-01 01:17:50 -05:00
Andrew Kelley 2246812184
use an explicit error set to fix a compilation error
this function has conditionally compiled out code in it about looking
for native glibc.
2020-02-29 22:20:44 -05:00
Andrew Kelley 6fcf6716be
std.Thread.cpuCount on Windows uses the PEB
rather than calling GetSystemInfo from kernel32.dll. Also remove
OutOfMemory from the error set.
2020-02-29 22:13:09 -05:00
Andrew Kelley d951e0402a
Merge pull request #4586 from daurnimator/windows-PEB
Fill out windows PEB definition
2020-02-29 22:05:56 -05:00
Andrew Kelley 48cef8d5be
refactor std.zig.system.NativeTargetInfo functions
to make them a bit easier to test.
2020-02-29 21:31:03 -05:00
LemonBoy 845af5c552 Handle one more error 2020-02-29 23:11:36 +01:00
LemonBoy 3b29a72b3b Use .len instead of @sizeOf 2020-02-29 23:08:57 +01:00
LemonBoy 84549b3955 target: Implement OS version detection for OSX
Closes #4583
2020-02-29 21:46:07 +01:00
LemonBoy 278f0f8fa9 Change how the build-id is checked
Address review comment by @rocksnest
2020-02-29 18:31:03 +01:00
Andrew Kelley 3c7f030a60
add CrossTarget.getObjectFormat
closes #4588

thanks Michaël Larouche for the suggested fix
2020-02-29 12:27:13 -05:00
daurnimator d0c22619f5
Complete windows PEB_LDR_DATA definition 2020-03-01 02:10:29 +11:00
LemonBoy 5822220435 Address review comments 2020-02-29 14:19:13 +01:00
daurnimator 513076ee9c
Fill out PEB definition 2020-03-01 00:12:08 +11:00
LemonBoy f072b0c056 target: Implement OS version detection for Windows
Closes #4581
2020-02-29 12:02:40 +01:00
Andrew Kelley 7e6b68a534
std.Target.standardDynamicLinkerPath: delete bad doc comment 2020-02-29 02:08:26 -05:00
Andrew Kelley 1aef0bef75
std.Target.Os.WindowsVersion: non-exhaustive enum 2020-02-28 19:24:52 -05:00
Andrew Kelley e683eee415
fix CrossTarget.isNative, setGnuLibCVersion, zigTriple 2020-02-28 19:18:27 -05:00
Andrew Kelley 4bc893c346
update test to newer API 2020-02-28 19:05:14 -05:00
Andrew Kelley 7e3bb00a0e
don't choose native ld path when os is non native 2020-02-28 18:48:19 -05:00
Andrew Kelley 4591236ae1
CrossTarget.cpu_model: communicate intent precisely 2020-02-28 18:31:46 -05:00
Andrew Kelley aa13f339d4
fix handling of CrossTarget.cpu_model 2020-02-28 18:09:33 -05:00
Andrew Kelley 8691d3c50d
improve std.zig.system.NativeTargetInfo.detect
It now takes a std.zig.CrossTarget parameter, and only resolves
native things, leaving explicitly overridden things alone.
2020-02-28 17:23:16 -05:00
Andrew Kelley 500dde32d5
dynamic_linker becomes a field of std.zig.CrossTarget 2020-02-28 14:51:56 -05:00
Andrew Kelley 07f52119de
implement native OS version detection for linux 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 d45ea4d89d
stage1: make get_native_target go through self-hosted 2020-02-28 14:51:56 -05:00
Andrew Kelley 3683ba87ac
complete the native target detection based on /usr/bin/env 2020-02-28 14:51:56 -05:00
Andrew Kelley fd006c1c74
std.zig.system.NativeTargetInfo.detect: almost no Allocator 2020-02-28 14:51:55 -05:00
Andrew Kelley 60f2f3457d
getStandardDynamicLinkerPath renamed and no allocator
* `std.Target.getStandardDynamicLinkerPath` =>
   `std.Target.standardDynamicLinkerPath`
 * it now takes a pointer to fixed size array rather than an allocator
 * `std.zig.system.NativeTargetInfo.detect` now supports reading
   PT_INTERP from /usr/bin/env
2020-02-28 14:51:55 -05:00
Andrew Kelley 2536e4c70c
WASI has no dynamic linker 2020-02-28 14:51:55 -05:00
Andrew Kelley bafa895561
compiler-rt: inline at call site to workaround a bug
The bug is #2154
2020-02-28 14:51:55 -05:00
Andrew Kelley 36aa3c8e7f
fix __stack_chk_guard emitted even when not linking libc 2020-02-28 14:51:55 -05:00
Andrew Kelley 6226726571
fix builder.findProgram test 2020-02-28 14:51:55 -05:00
Andrew Kelley 7927764cc2
mips: implement Target.getStandardDynamicLinkerPath 2020-02-28 14:51:54 -05:00
Andrew Kelley 34d2700af4
clean up CrossTarget.getExternalExecutor 2020-02-28 14:51:54 -05:00
Andrew Kelley 0912484c4f
improve the "external executor" detection logic 2020-02-28 14:51:54 -05:00
Andrew Kelley cebcacd872
fix standardTargetOptions and improve init-exe to use it 2020-02-28 14:51:54 -05:00
Andrew Kelley cf233bad58
fix target parsing 2020-02-28 14:51:54 -05:00
Andrew Kelley dbe4d72bcf
separate std.Target and std.zig.CrossTarget
Zig now supports a more fine-grained sense of what is native and what is
not. Some examples:

This is now allowed:
-target native

Different OS but native CPU, default Windows C ABI:
-target native-windows
This could be useful for example when running in Wine.

Different CPU but native OS, native C ABI.
-target x86_64-native -mcpu=skylake

Different C ABI but otherwise native target:
-target native-native-musl
-target native-native-gnu

Lots of breaking changes to related std lib APIs.
Calls to getOs() will need to be changed to getOsTag().
Calls to getArch() will need to be changed to getCpuArch().

Usage of Target.Cross and Target.Native need to be updated to use
CrossTarget API.

`std.build.Builder.standardTargetOptions` is changed to accept its
parameters as a struct with default values. It now has the ability to
specify a whitelist of targets allowed, as well as the default target.
Rather than two different ways of collecting the target, it's now always
a string that is validated, and prints helpful diagnostics for invalid
targets. This feature should now be actually useful, and contributions
welcome to further improve the user experience.

`std.build.LibExeObjStep.setTheTarget` is removed.
`std.build.LibExeObjStep.setTarget` is updated to take a CrossTarget
parameter.

`std.build.LibExeObjStep.setTargetGLibC` is removed. glibc versions are
handled in the CrossTarget API and can be specified with the `-target`
triple.

`std.builtin.Version` gains a `format` method.
2020-02-28 14:51:54 -05:00
Andrew Kelley 87b9e744dd
update std lib to new Target API 2020-02-28 14:51:54 -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 fba39ff331
restructuring std.Target for OS version ranges, pass 1 2020-02-28 14:51:50 -05:00
LemonBoy 6a0927d8c1 debug: Fix end-of-stream condition in DWARF parser 2020-02-26 21:02:54 -05:00
Andrew Kelley 0a88352689
fix behavior tests with --test-evented-io 2020-02-26 13:17:38 -05:00
Andrew Kelley 2b33e27e1c
arm baseline CPU is v7a rather than v6m
v6m is thumb-mode and the baseline should probably be an 'a' variant.
2020-02-26 12:37:13 -05:00
Vexu 22432b15e3
add test for `@intToEnum` 2020-02-26 11:19:40 -05:00
Andrew Kelley aa2aad229c
Merge pull request #4497 from LemonBoy/do-do-do
The great stack-trace race (Part 1 of N)
2020-02-26 11:10:38 -05:00
Andrew Kelley 7cfe854359
clean up std.Buffer.print 2020-02-24 22:34:06 -05:00
vegecode 6fa143355f
Add formatted printing directly into std.Buffer 2020-02-24 22:30:23 -05:00
Andrew Kelley 5503f3f7c4
Merge pull request #4544 from BarabasGitHub/zeroes-for-non-extern-types
implement zeroes for non extern structs and native types
2020-02-24 22:01:56 -05:00
Andrew Kelley 61a50a23e8
Merge pull request #4547 from Vexu/deprecate
Remove deprecated builtins
2020-02-24 21:57:29 -05:00
Andrew Kelley 544bc42fd9
expose --verbose-llvm-cpu-features to zig build 2020-02-24 20:11:33 -05:00
Vexu 538d9a5dd8
remove uses of `@ArgType` and `@IntType` 2020-02-24 23:39:03 +02:00
Bas van den Berg f7aa4f5280 Processed review comments. Updated documentation, used the typinfo for field access, generate compile error on allowzero and set C poitners to null 2020-02-24 22:15:04 +01:00
Vexu 45da72c5b6
remove usages of `@typeId`, `@memberCount`, `@memberName` and `@memberType` 2020-02-24 23:09:01 +02:00
Bas van den Berg 195195d238 vectors do not support iterating, do not support them (for now) 2020-02-24 20:50:51 +01:00
Bas van den Berg 0972b2a8fe implement zeroes for non extern structs and native types 2020-02-24 20:38:33 +01: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
J.W 5275b01202 hashing algorithms: fix logic and index out of bounds 2020-02-24 13:43:54 -05:00
Heide Onas Auri 907c5589ae
std.time.Timer.lap: only read system time once (#4533)
Calling Timer.lap queried the system time twice; once to compute the lap
time and once to reset the timer. This can lead to time discrepancies
between actual and computed durations when summing the result of
Timer.lap in a loop. This commit fixes that.

also fix Timer.read to not require a pointer
2020-02-23 18:25:52 -05:00
LemonBoy 08047cd6d7 correct test expectations 2020-02-23 22:47:48 +01:00
xackus 7664c3bc11 remove @bytesToSlice, @sliceToBytes from tests, docs 2020-02-23 18:03:50 +01:00
Andrew Kelley cfe1fbad0f
Merge pull request #4304 from daurnimator/auto-json
Add "automatic" JSON facilities
2020-02-23 11:25:15 -05:00
frmdstryr 597648231b Format decmial 0.0 with no precision as just 0 2020-02-23 11:17:06 -05:00
Andrew Kelley 94c3dbf9e3
remove no-longer-valid defer 2020-02-23 01:07:19 -05:00
Andrew Kelley 767f041068 std.process: fix typo 2020-02-22 17:49:52 -05:00
Andrew Kelley cfffb9c5e9
improve handling of environment variables on Windows
std.os.getenv and std.os.getenvZ have nice compile errors when not linking
libc and using Windows.

std.os.getenvW is provided as a Windows-only API that does not require
an allocator. It uses the Process Environment Block.
std.process.getEnvVarOwned is improved to be a simple wrapper on top of
std.os.getenvW.

std.process.getEnvMap is improved to use the Process Environment Block
rather than calling GetEnvironmentVariableW.

std.zig.system.NativePaths uses process.getEnvVarOwned instead of
std.os.getenvZ, which works on Windows as well as POSIX.
2020-02-22 17:35:36 -05:00
Andrew Kelley 936d0b18b1
update std lib to integrate with libc for environ
closes #3511
2020-02-22 15:59:13 -05:00
Andrew Kelley 0cd89e9176
std.os.execvpeZ_expandArg0: fix not restoring argv[0]
This function expands argv[0] into the absolute path resolved with PATH
environment variable before making the execve syscall. However, in case
the execve fails, e.g. with ENOENT, it did not restore argv to how it
was before it was passed in. This resulted in the caller performing an
invalid free.

This commit also adds verbose debug info when native system C compiler
detection fails. See #4521.
2020-02-22 13:56:02 -05:00
LemonBoy 495e894225 delete extra code, more forgiveness 2020-02-22 12:44:21 +01:00
LemonBoy 41bca1ce76 unification: windows debug info 2020-02-22 12:05:50 +01:00
LemonBoy c060cae3ce unification: osx debug info 2020-02-22 11:51:45 +01:00
Andrew Kelley 6305ce828b
fix regression in standardTargetOptions 2020-02-21 19:22:50 -05:00
Andrew Kelley 6aecc268fd
remove the allocator from std.event.Loop
closes #3539
2020-02-21 15:20:36 -05:00
Andrew Kelley dff7ca6784
annotate TODO comment with bug tracker link 2020-02-21 14:20:07 -05:00
xackus 783e8ad031 remove @bytesToSlice, @sliceToBytes from std lib 2020-02-21 19:46:53 +01:00
xackus fdae5f5a07 implement bytesAsSlice, sliceAsBytes 2020-02-21 19:40:29 +01:00
Andrew Kelley 71573584cd
std.Target.parse gives parsing diagnostics 2020-02-21 13:34:55 -05:00
Andrew Kelley 7da7fbb912
update ARM cpu models to correctly include the sub-arch 2020-02-21 12:29:27 -05:00
Andrew Kelley ab56d3e18c
fix std.Target unit tests 2020-02-21 11:07:56 -05:00
LemonBoy 8df4d7e4f4 unsure 2020-02-21 12:11:04 +01:00
Andrew Kelley a391a82e49
fix zig build adding invalid cli args 2020-02-21 01:58:40 -05:00
Andrew Kelley 2de7d0b10c
fix zig build, ABI ABI, and update tests to new Target layout 2020-02-20 18:50:20 -05:00
Andrew Kelley 903127f36c
Merge remote-tracking branch 'origin/master' into sub-architecture-annihilation 2020-02-20 18:36:04 -05:00
Andrew Kelley 0f016b368d
support -mcpu=baseline, both in stage1 and stage2
See e381a42de9 for more details.
This is set up so that if we wish to make "baseline" depend on the
OS in the future, it is possible to do that.
2020-02-20 18:31:17 -05:00
Andrew Kelley b0d2ebe529 remove std.io.readLine
This was deceptive. It was always meant to be sort of a "GNU readline"
sort of thing where it provides a Command Line Interface to input text.
However that functionality did not exist and it was basically a red
herring for people trying to read line-delimited input from a stream.

In this commit the API is deleted, so that people can find the proper
API more easily.

A CLI text input abstraction would be useful but may not even need to be
in the standard library. As you can see in this commit, the guess_number
CLI game gets by just fine by using `std.fs.File.read`.
2020-02-20 15:30:00 -05:00
Andrew Kelley 33c69d5cb6
arm: clarify which CPU features are sub-architectures
versus which ones are instruction sets.
2020-02-20 15:27:42 -05:00