120 Commits

Author SHA1 Message Date
Andrew Kelley
a239c7439f
more helpful error message when failing to parse glibc abi.txt 2019-09-22 17:41:15 -04:00
Andrew Kelley
b564e7ca59
os: raise maximum file descriptor limit
Do a binary search for the maximum RLIMIT_NOFILE.

Patch lifted from node.js commit
6820054d2d42ff9274ea0755bea59cfc4f26f353
2019-09-05 15:09:13 -04:00
Andrew Kelley
8b1900e5df
Revert "Merge pull request #2991 from emekoi/mingw-ci"
This reverts commit ec7d7a5b14540ea3b2bab9f11318630338467965, reversing
changes made to 81c441f8855d4c58f0b2ff86d3d007cf0bf395d3.

It looks like this broke colors in Windows Command Prompt (#3147)
and this method of detecting native C ABI isn't working well (#3121).
2019-09-01 00:33:02 -04:00
emekoi
102d3f30c4 accept unix style paths on windows-gnu 2019-08-02 19:39:33 -05:00
emekoi
f15ec9a59b implemented runtime abi detetction for windows 2019-08-02 19:32:46 -05:00
emekoi
3ac9e3c888 make string literal const on windows 2019-06-22 19:54:11 -05:00
Jonathan Marler
21dff1c4e2 Remove duplicate exe name with zig run 2019-06-17 14:10:10 -04:00
LemonBoy
7987202243 Fix signedness mismatch in comparison 2019-05-20 23:14:49 +02:00
Andrew Kelley
6b36b756eb
fix static builds of zig from requiring c compiler
to be installed when linking libc.

When zig links against libc, it requires a dynamic linker path.
Usually this can be determined based on the architecture and operating
system components of the target. However on some systems this is not
correct; because of this zig checks its own dynamic linker.

When zig is statically linked, this information is not available, and so
it resorts to using cc -print-filename=foo to find the dynamic linker
path.

Before this commit, Zig incorrectly exited with an error if there was
no c compiler installed. Now, Zig falls back to the dynamic linker
determined based on the arch and os when no C compiler can be found.
2019-05-15 21:50:56 -04:00
Andrew Kelley
1d95fdaf6e
Fix path canonicalization when $HOME has a trailing slash 2019-04-26 14:37:26 -04:00
Shawn Landden
8ef7f6febb remove Shebang (#!) support
Closes:  #2165
2019-04-24 23:34:19 -04:00
Ben Noordhuis
ea5518f69e make os_file_close poison file handle after close
This helps track down use-after-close bugs.
2019-04-13 12:31:49 +02:00
Andrew Kelley
0cccba71d4
better error message when os_file_overwrite fails 2019-04-02 15:21:08 -04:00
Shawn Landden
65e234adfd fix build on arm64 2019-03-27 01:14:29 +00:00
Andrew Kelley
895fab156a fix build on windows 2019-03-11 10:35:04 -04:00
Andrew Kelley
3a6f19de48
stage1 caching system: detect problematic mtimes
closes #2045
2019-03-11 10:26:08 -04:00
Andrew Kelley
91955dee58
breaking changes to zig build API and improved caching
* in Zig build scripts, getOutputPath() is no longer a valid function
   to call, unless setOutputDir() was used, or within a custom make()
   function. Instead there is more convenient API to use which takes
   advantage of the caching system. Search this commit diff for
   `exe.run()` for an example.
 * Zig build by default enables caching. All build artifacts will go
   into zig-cache. If you want to access build artifacts in a convenient
   location, it is recommended to add an `install` step. Otherwise
   you can use the `run()` API mentioned above to execute programs
   directly from their location in the cache. Closes #330.
   `addSystemCommand` is available for programs not built with Zig
   build.
 * Please note that Zig does no cache evicting yet. You may have to
   manually delete zig-cache directories periodically to keep disk
   usage down. It's planned for this to be a simple Least Recently
   Used eviction system eventually.
 * `--output`, `--output-lib`, and `--output-h` are removed. Instead,
   use `--output-dir` which defaults to the current working directory.
   Or take advantage of `--cache on`, which will print the main output
   path to stdout, and the other artifacts will be in the same directory
   with predictable file names. `--disable-gen-h` is available when
   one wants to prevent .h file generation.
 * `@cImport` is always independently cached now. Closes #2015.
   It always writes the generated Zig code to disk which makes debug
   info and compile errors better. No more "TODO: remember C source
   location to display here"
 * Fix .d file parsing. (Fixes the MacOS CI failure)
 * Zig no longer creates "temporary files" other than inside a
   zig-cache directory.

This breaks the CLI API that Godbolt uses. The suggested new invocation
can be found in this commit diff, in the changes to `test/cli.zig`.
2019-03-08 23:23:11 -05:00
Andrew Kelley
431b3b2459 fix windows build 2019-03-07 13:32:43 -05:00
Andrew Kelley
4d8467fafc better behavior when cache dir unavailable
and choose different manifest dir for local cache to avoid
conflict with zig build
2019-03-07 13:16:52 -05:00
Andrew Kelley
e2ce00f272 fix regressions on macos 2019-03-07 13:04:10 -05:00
Andrew Kelley
aeb16010f3
initial glibc support 2019-03-04 22:15:53 -05:00
Andrew Kelley
02f3a834b0
struct types get fully qualified names
and function symbol names become fully qualified
2019-02-28 15:40:57 -05:00
Andrew Kelley
c59ce046a0 windows returns EINVAL for fopen when there is an asterisk in the name
closes #508
2019-02-26 23:02:57 -05:00
Andrew Kelley
0d4db8828a
@cImport works with --cache on
We pass -MD -MF args to clang when doing `@cImport`, which
gives us a complete list of files that the C code read from.
Then we add these to the cache. So even when using `@cImport`
Zig's caching system remains perfect. This is a proof of concept
for the mechanism that the self-hosted compiler will use to
watch and rebuild files.
2019-02-25 14:03:36 -05:00
Andrew Kelley
6fd8d455bc
better libc detection (#1996)
* better libc detection

This introduces a new command `zig libc` which prints
the various paths of libc files. It outputs them to stdout
in a simple text file format that it is capable of parsing.
You can use `zig libc libc.txt` to validate a file.

These arguments are gone:
--libc-lib-dir [path]        directory where libc crt1.o resides
--libc-static-lib-dir [path] directory where libc crtbegin.o resides
--msvc-lib-dir [path]        (windows) directory where vcruntime.lib resides
--kernel32-lib-dir [path]    (windows) directory where kernel32.lib resides

Instead we have this argument:
--libc [file]                Provide a file which specifies libc paths

This is used to pass a libc text file (which can be generated with
`zig libc`). So it is easier to manage multiple cross compilation
environments.

`--cache on` now works when linking against libc.

`ZigTarget` now has a bool field `is_native`

Better error messaging when you try to link against libc or use
`@cImport` but the various paths cannot be found. It should also be
faster.

* save native_libc.txt in zig-cache

This avoids having to detect libc at runtime on every invocation.
2019-02-23 09:35:56 -05:00
Maya Rashish
bc10382ec1 Add NetBSD support
Mostly picking the same paths as FreeBSD.
We need a little special handling for crt files, as netbsd uses its
own (and not GCC's) for those, with slightly different names.
2019-02-17 09:17:34 +02:00
Andrew Kelley
28873e7622 os.cpp: fix regression on Windows from 59c050e7 2019-01-31 16:52:59 -05:00
Andrew Kelley
59c050e7ff
collapse os_file_mtime into os_file_open_r and check for directory
This is a manual merge of kristate's pull request #1754, due to
conflicts + a couple fixups.

closes #1754
2019-01-30 16:06:18 -05:00
Andrew Kelley
d770333827
freebsd: fix os_self_exe_path function and update std lib 2018-12-12 22:28:15 -05:00
Andrew Kelley
e3bf40742d
Merge branch 'master' into freebsd2 2018-11-27 20:36:44 -05:00
Andrew Kelley
67a39a4c99
stage1: better file path handling
* better message printed when cache hash fails
 * better handling of '/' as root source file
 * os_path_split parses '/' and '/a' correctly

closes #1693
closes #1746
2018-11-26 20:04:35 -05:00
Andrew Kelley
9493738e54
Merge branch 'freebsd-up' of https://github.com/myfreeweb/zig into freebsd2 2018-11-19 17:24:41 -05:00
kristopher tate
947cdafd91
src/os.cpp: os_file_read: return ErrorIsDir on case EISDIR; 2018-11-18 15:30:24 +09:00
Vallentin
398914eb71 Fixed typos 2018-11-16 14:03:39 -05:00
emekoi
8e69a18d8c made colored output more consistent (#1706)
* made colored output more consistent
* added os.supportsAnsiEscapeCodes
2018-11-08 00:36:36 -05:00
Andrew Kelley
63f636e7b7
limit integer types to maximum bit width of 65535
closes #1541
2018-11-06 11:09:14 -05:00
Andrew Kelley
1554dd9697
support building static self hosted compiler on macos
* add a --system-linker-hack command line parameter to work around
   poor LLD macho code. See #1535
 * build.zig correctly handles static as well as dynamic dependencies
   when building the self hosted compiler.
   - no more unnecessary libxml2 dependency
   - a static build on macos produces a completely static self-hosted
     compiler for macos (except for libSystem as intended).
2018-11-02 00:54:34 -04:00
Greg V
9a541c1214 Add FreeBSD support to os.cpp 2018-10-20 15:15:01 +03:00
Andrew Kelley
05e608a0c7
stage1 os: workaround for macos not having environ variable 2018-10-09 13:16:51 -04:00
Andrew Kelley
6b93495792
more efficient builtin library code generation
* introduce --disable-pic option which can generally be allowed to be
   the default. compiler_rt.a and builtin.a get this option when you
   build a static executable.
 * compiler_rt and builtin libraries are not built for build-lib
   --static
 * posix_spawn instead of fork/execv
 * disable the error limit on LLD. Fixes the blank lines printed
2018-10-09 13:16:50 -04:00
Andrew Kelley
d40c4e7c89
Merge pull request #1429 from shawnl/arm64
initial arm64 support
2018-10-06 00:11:39 -04:00
Shawn Landden
2d27341724 arm64: respond to code review 2018-10-06 03:31:52 +00:00
Jeff Fowler
f955844435 rm extraneous macro 2018-09-22 10:50:35 -04:00
Andrew Kelley
93ff5024a4
minor cleanups from 68c1d05917 2018-09-18 10:17:48 -04:00
emekoi
68c1d05917 compiling on mingw is now supported (#1542)
* compiles on mingw-w64
* fixed error in os_file_overwrite on windows
* fixed windows hello_world example
2018-09-18 00:13:17 -04:00
Andrew Kelley
4c6f1e614a
remove zig build --init. add zig init-lib and zig init-exe
init-lib creates a working static library with tests, and
init-exe creates a working hello world with a `run` target.

both now have test coverage with the new "cli tests" file.

closes #1035
2018-09-17 17:11:18 -04:00
Andrew Kelley
1caa48c2df windows os.cpp implementations 2018-09-12 11:33:26 -04:00
Andrew Kelley
1a4dcf10fe darwin fixups 2018-09-11 17:42:03 -04:00
Andrew Kelley
4af844732a
Merge remote-tracking branch 'origin/master' into stage1-caching 2018-09-11 15:56:04 -04:00
Andrew Kelley
5ee5933ade
stage1 caching: zig no longer uses zig-cache 2018-09-10 17:30:45 -04:00