Commit Graph

102 Commits (0a9672fb86b84658f8780f57e769be45e41f3034)

Author SHA1 Message Date
Vexu caaa26c9f0 reference emit_raw in std lib tests 2020-06-18 20:17:53 -04:00
Alexandros Naskos 65d827183b Added custom build step id, made tests.zig steps use it 2020-05-25 11:36:12 +03:00
Alexandros Naskos d268e0cf2e Added and id and a cast function to build steps 2020-05-25 11:20:31 +03:00
Jakub Konka 3d267bab71 Re-enable refAllDecls gen and check in std.zig 2020-05-18 21:05:29 +02:00
Jakub Konka d43c08a3e5 Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.

Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.

The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
  to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
  in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
  fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-18 16:09:49 +02:00
Andrew Kelley f2ceb023f4
Merge pull request #5217 from wozeparrot/master
build.zig recursive dep support
2020-05-16 14:24:51 -04:00
DrDeano 72b72faa0b
Add Enum Option 2020-05-16 15:36:18 +01:00
DrDeano b2cb8beed9
Add enum to addBuildOptions 2020-05-16 15:35:42 +01:00
Vexu d4d509090b
make std.build.getInstallPath public
Closes  #5299
2020-05-09 00:31:11 +03:00
Josh Junon b6dc7fc9ff
publicize member functions affected by #4909 2020-05-08 14:26:28 +03:00
Andrew Kelley 6f3d76f61e simplify test-evented-io build setting 2020-05-05 15:18:04 -04:00
Haze Booth a39cb034ea Add setUseTestEventedIO for test steps in build.zig 2020-05-05 15:16:54 -04:00
wozeparrot 9d79f39844 switch anyerror to OutOfMemory 2020-04-30 12:14:17 -04:00
wozeparrot bfb40972a9 build.zig recursive dep support 2020-04-29 12:54:06 -04:00
wozeparrot 01605a7742 add missing const to pkg dependencies 2020-04-27 18:29:55 -04:00
LemonBoy a4b1242f0a build: Create the output directory if it doesn't exist
Fixes #5054
2020-04-17 05:12:42 -04:00
xackus 7a28c644aa new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
Andrew Kelley 553f0e0546
fixups and revert a few things 2020-04-01 11:56:39 -04:00
daurnimator ecbc235403
std: use std.ArrayList(u8) instead of std.Buffer in std/build.zig 2020-04-01 10:36:38 -04:00
Andrew Kelley 9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
dbandstra a8fa1ecd89 fix build.zig addBuildOption function for stream refactor 2020-03-21 23:18:09 -04:00
Andrew Kelley 3a2c490889 "generate .h files" feature is no longer supported in stage1 2020-03-20 18:33:36 -04:00
Andrew Kelley 555a2c0328
(breaking) std.fs.copyFile now integrates with Dir
Removed:
 * `std.fs.updateFile`
 * `std.fs.updateFileMode`
 * `std.fs.copyFile`
 * `std.fs.copyFileMode`

Added:
 * `std.fs.Dir.copyFile`
 * `std.fs.copyFileAbsolute`
 * `std.fs.updateFileAbsolute`

Moved:
 * `std.fs.Dir.UpdateFileOptions` => `std.fs.CopyFileOptions`

Deprecated:
 * `std.fs.deleteDir`
 * `std.fs.deleteDirC`
 * `std.fs.deleteDirW`
 * `std.fs.readLink`
 * `std.fs.readLinkC`
2020-03-19 14:43:41 -04:00
Andrew Kelley 46ffc798b6
fix swapped logic for Windows
Remove `std.fs.deleteTree`. Callers instead should use
`std.fs.cwd().deleteTree`.

Add `std.fs.deleteTreeAbsolute` for when the caller has an absolute
path.
2020-03-18 16:42:47 -04:00
Andrew Kelley 27affde592
(breaking) clarify openDir API
* remove deprecated `std.fs.Dir` APIs
 * `std.fs.Dir.openDir` now takes a options struct with bool fields for
   `access_sub_paths` and `iterate`. It's now much more clear how
   opening directories works.
 * fixed the std lib and various zig code calling the wrong openDir
   function.
 * the runtime safety check for dir flags is removed in favor of the
   cheaper option of putting a comment on the same line as handling
   EBADF / ACCESS_DENIED, since that will show up in stack traces.
2020-03-18 16:10:57 -04:00
LemonBoy c45fe2759f
build: Fix silly bug in directory traversal 2020-03-18 13:45:52 -04:00
LemonBoy 582991a5a8 build: Expose function-sections switch 2020-03-16 13:06:50 -04:00
Andrew Kelley 66e76a0209
zig build system: correctly handle multiple output artifacts
Previously the zig build system incorrectly assumed that the only build
artifact was a binary. Now, when you enable the cache, only the output
dir is printed to stdout, and the zig build system iterates over the
files in that directory, copying them to the output directory.

To support this change:

 * Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`.
 * Fix `std.os.linux.renameat` not compiling due to typos.
 * Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`.
 * Add `std.fs.Dir.updateFile`, which supports using open directory
   handles for both the source and destination paths, as well as an
   options parameter which allows overriding the mode.
 * Update `std.fs.AtomicFile` to support operating based on an open
   directory handle. Instead of `std.fs.AtomicFile.init`, use
   `std.fs.Dir.atomicFile`.
 * `std.fs.AtomicFile` deinit() better handles the situation when the
    rename fails but the temporary file still exists, by still
    attempting to remove the temporary file.
 * `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`.
 * `std.os.RenameError` gains the error codes `NoDevice`,
   `SharingViolation`, and `PipeBusy` which have been observed from
   Windows.

Closes #4733
2020-03-13 21:22:08 -04:00
Andrew Kelley 2bff0dda79
fix regressions found by test suite 2020-03-10 20:22:30 -04:00
daurnimator 8f627593eb
Use in_stream.readAllAlloc where sensible 2020-03-06 18:49:12 -05:00
daurnimator 1ca5f06762
Update callers of fs.makePath 2020-03-03 13:25:43 -05:00
xackus 00be934569 short std.builtin enum literals in std lib 2020-03-01 13:57:41 -05:00
Andrew Kelley 500dde32d5
dynamic_linker becomes a field of std.zig.CrossTarget 2020-02-28 14:51:56 -05:00
Andrew Kelley 6226726571
fix builder.findProgram test 2020-02-28 14:51:55 -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 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 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 45da72c5b6
remove usages of `@typeId`, `@memberCount`, `@memberName` and `@memberType` 2020-02-24 23:09:01 +02:00
Andrew Kelley 6305ce828b
fix regression in standardTargetOptions 2020-02-21 19:22:50 -05: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 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
pwzk eff50abce6 Fixing library search path 2020-02-07 12:08:41 -05:00