Commit Graph

12877 Commits

Author SHA1 Message Date
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
LemonBoy a4d0d7f1de soldier on 2020-02-20 20:48:54 +01:00
LemonBoy 342a274948 tidy interface, const correctness 2020-02-20 20:18:51 +01:00
LemonBoy ce2efbdca6 Correctly count all the loaded modules on Windows 2020-02-20 19:41:29 +01:00
LemonBoy d5b583008a sudoku 2020-02-20 19:41:29 +01:00
LemonBoy fabab58528 less hideous 2020-02-20 19:41:29 +01:00
LemonBoy b9c02e4076 elvis entered the building 2020-02-20 19:41:29 +01:00
LemonBoy 2a350cf174 osx 2020-02-20 19:41:29 +01:00
LemonBoy b3f728585a windows widestring 2020-02-20 19:41:29 +01:00
LemonBoy 463f704431 wide 2020-02-20 19:41:29 +01:00
LemonBoy 99649794e9 win 2020-02-20 19:41:29 +01:00
LemonBoy b0b60cd468 tmp 2020-02-20 19:41:29 +01:00
LemonBoy 3620b67c26 debug: Split the DWARF stuff in its own file 2020-02-20 19:41:28 +01:00
Andrew Kelley ec889d5888 NO_MEDIA_IN_DEVICE => return error.NoDevice 2020-02-20 12:39:46 -05:00
Andrew Kelley 9c3eff9193 Revert "arm: clean up the messy sub-architecture & CPU features"
This reverts commit 96f45c27b6.
2020-02-20 12:18:32 -05:00
LemonBoy ae16a6773f std: Handle NO_MEDIA_IN_DEVICE error in openFileWindows
Closes #4507
2020-02-20 13:25:45 +01:00
Andrew Kelley 3c76e5e33d update tls in std lib for lack of sub-arch 2020-02-19 22:09:35 -05:00
Andrew Kelley c33cd370fc fix unit test for Target.parse
I think this is working correctly. Without also removing sse2 from the
feature set, sse gets added back into the set because sse2 is part of
the x86_64 baseline (which is the cpu provided) and sse2 depends on sse.
2020-02-19 21:55:25 -05:00
Andrew Kelley ef2d237f2f this is not the proper way to support this feature 2020-02-19 21:51:24 -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 96f45c27b6 arm: clean up the messy sub-architecture & CPU features 2020-02-19 19:11:20 -05:00
Andrew Kelley 4c6f207aff clean up arm CPU features
* remove "cpu features" that are actually just processors
 * rename `v8` to `v8a`. this matches the corresponding
   change to target/aarch64.zig
 * rename types in preparation for removing sub-architecture
   from `std.Target`.

I have other files changed in my dirty working tree, but about to make
some changes to arm.zig that I don't want batched with this commit.
2020-02-19 18:12:06 -05:00
Bas 1483ae37f2 Add an appendValues method to ArrayList to append a value n times. (#4460) 2020-02-19 11:33:35 -05:00
daurnimator e270db956c std: tagged unions are broken on arm64 2020-02-19 23:17:04 +11:00
daurnimator d989396a34 std: add json.parse to automatically decode json into a struct 2020-02-19 23:16:35 +11:00
daurnimator 5a20604820 std: add json.stringify to encode arbitrary values to JSON 2020-02-19 23:01:12 +11:00
Andrew Kelley c664692bdd make the CLI support depending on system headers and libraries
(include and lib search paths)

The detection of native system paths is self-hosted.

closes #2041
2020-02-19 01:24:34 -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 dba12cd693 Rename produce_* bools to emit_* to match CLI 2020-02-18 18:59:45 -05:00
Noam Preil 2502cb242a Improve support for generating LLVM IR/asm files 2020-02-18 18:59:45 -05:00