Commit Graph

11513 Commits

Author SHA1 Message Date
Andrew Kelley
783cb980ab Release 0.7.1 2020-12-13 12:14:58 -07:00
Andrew Kelley
cf0e453cc9 Merge pull request #7406 from ifreund/dyn-musl2
stage2: support dynamically linking musl libc
2020-12-12 16:52:55 -07:00
Andrew Kelley
9d2e5bbcb4 glibc: do not provide -lcrypt
glibc is dropping this functionality moving forward.

This is a partial revert of commit
97c0e1cc41
2020-12-12 12:44:41 -07:00
Andrew Kelley
a42c712934 std.fs.path.extension: different behavior for ending dot
extension("a.") now returns "." instead of "".

This matches both Python and Node.js standard library behavior as well
as my personal opinion on how this function should be defined.

Apologies for missing this in the code review.
2020-12-11 18:23:57 -07:00
Andrew Kelley
1bbf731e7e stage2: proper file extension stripping
Previously it used mem.split on "." and took the first iterated item.
Now it uses fs.path.extension and strips off that number of bytes.

Closes #7404
2020-12-11 17:44:33 -07:00
Andrew Kelley
a6de0b4136 std.fs.path.extension: add additional API guarantee
Added:

The returned slice is guaranteed to have its pointer
within the start and end pointer address range of `path`,
even if it is length zero.
2020-12-11 17:44:27 -07:00
Andrew Kelley
5df9f15843 Merge pull request #7098 from MasterQ32/std.fs.path.extension
Implements std.fs.path.extension
2020-12-11 17:44:19 -07:00
Andrew Kelley
4797fdb3db fix deadlock with build-exe on an object for windows
The steps to repro this issue are:

zig build-obj hello.zig -target x86_64-windows-msvc
zig build-exe hello.obj -target x86_64-windows-msvc --subsystem console
-lkernel32 -lntdll

What was happening is that the main Compilation added a work item to
produce kernel32.lib. Then it added a sub-Compilation to build zig's
libc, which ended up calling a function with extern "kernel32", which
caused the sub-Compilation to also try to produce kernel32.lib. The main
Compilation and sub-Compilation do not coordinate about the set of
import libraries that they will be trying to build, so this caused a
deadlock.

This commit solves the problem by disabling the extern "foo" feature
from working when building compiler_rt or libc. Zig's linker code is now
responsible for putting the appropriate import libs on the linker line,
if any for compiler_rt and libc.

Related: #5825
2020-12-11 17:23:55 -07:00
Andrew Kelley
74c17aa8c5 mingw-w64: add .def files for xinput1_4
closes #7398
2020-12-11 17:23:50 -07:00
Andrew Kelley
465b90c1fa mingw-w64: add support for -lwldap32
closes #7395
2020-12-11 00:51:28 -07:00
LemonBoy
00664dbdce zig fmt: Fix alignment of initializer elements
Resetting `column_counter` is not needed as the effective column number
is calculated by taking that value modulo `row_size`.

Closes #7289
2020-12-11 00:40:05 -07:00
Vexu
c9bc8b9d0c zig fmt: improve var decl initializer formatting 2020-12-11 00:39:52 -07:00
Andrew Kelley
fd4c98cbb7 stage2: detect redundant C/C++ source files
Cache exposes BinDigest.

Compilation gains a set of a BinDigest for every C/C++ source file. We
detect when the same source/flags have already been added and emit a
compile error. This prevents a deadlock in the caching system.

Closes #7308
2020-12-11 00:33:59 -07:00
Andrew Kelley
21236c0151 CLI: improved local cache directory logic
Previously, when choosing the local cache directory, if there was no
root source file, an explicitly chosen path, or other clues, zig would
choose cwd + zig-cache/ as the local cache directory.

This can be problematic if Zig is invoked with the CWD set to a
read-only directory, or a directory unrelated to the actual source files
being compiled. In the real world, we see this when using `zig cc` with
CGo, which for some reason changes the current working directory to the
read-only go standard library path before running the C compiler.

This commit conservatively chooses to use the global cache directory
as the local cache directory when there is no other reasonable choice,
and no longer will rely on the cwd path to choose a local cache directory.

As a reminder, the --cache-dir CLI flag and ZIG_LOCAL_CACHE_DIR
environment variable are available for overriding the decision. For the
zig build system, it will always choose the directory that build.zig is
+ zig-cache/.

Closes #7342
2020-12-10 17:00:46 -07:00
antlilja
ea70a983ba Added global-cache argument to build system + removed extra args.
* Field global_cache_root was added to Builder struct along with
mandatory argument for build_runner.zig. Logic for using the custom
global cache was also added.

* The arguments --cache-dir and --global-cache-dir are no longer passed
directly through to build_runner.zig and are instead only passed through the
mandatory cache_root and global_cache_root arguments.
2020-12-10 17:00:38 -07:00
Vexu
235d56cb82 make std.json.unescapeString pub 2020-12-10 14:10:48 -07:00
Andrew Kelley
b4c0396d3c CLI: infer --name based on first C source file or object
Previously, --name would only be inferred if there was exactly 1 C
source file or exactly 1 object. Now it will be inferred if there is at
least one of either.
2020-12-09 21:21:27 -07:00
Timon Kruiper
97692cb4fe Do not keep the build.zig cache manifest file locked.
This allows to have multiple instances of `zig build` at the same
time. For example when you have a long running `zig build run` and
then want to run `zig build somethingelse`.
2020-12-09 20:16:26 -07:00
Andrew Kelley
d9c808e3ff mingw-w64: patch to silence implicit-function-declaration warnings
Closes #7356

I did this as a patch to the source rather than passing flags so that
it would intentionally be reverted when we update to the next release of
mingw-w64. At this time if any warnings are still emitted we should find
out why and make sure upstream is aware of the problem.
2020-12-09 17:32:32 -07:00
Andrew Kelley
1f09584d05 MoveFileEx can return ACCESS_DENIED
I observed this on Windows 10, trying to use MoveFileEx with
MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH
to overwrite a running executable.
2020-12-09 17:32:26 -07:00
Martin Wickham
cad2e8da9d Fix operator precedence documentation 2020-12-09 17:31:49 -07:00
Andrew Kelley
b124d04e6a Merge pull request #7366 from LemonBoy/fix-7346
Some compiler-rt fixes
2020-12-09 12:21:28 -07:00
Lee Cannon
a7eea0813f Fixes #7352 - ignore zig fmt ignore zig-cache 2020-12-09 11:44:40 -07:00
Andrew Kelley
85c1db9222 Merge pull request #7355 from ziglang/lld-child-process
invoke LLD as a child process rather than a library
2020-12-09 00:32:30 -07:00
antlilja
40e37d4324 Change tag returned by zigTagType for c_longdouble to Float.
Function was returning Int before.
2020-12-08 17:10:55 -07:00
Nathanaël Courant
1ec0261518 Fix general purpose allocator incorrectly modifying total_requested_bytes in some cases 2020-12-08 13:57:02 -07:00
Andrew Kelley
5c13a4e54a tests: run-translated-c now respects -Dtarget 2020-12-08 13:56:56 -07:00
Andrew Kelley
c2de3bdc12 always use codeview (pdb) when object_format is PE/COFF
Previously, when mixing Zig and C/C++ code for windows-gnu targets, zig
would get codeview format but the C/C++ code would not get any debug
info. Now, C/C++ code properly emits debug info in codeview format and
everything just works.
2020-12-08 13:56:50 -07:00
Andrew Kelley
ad95eecf37 glibc: additionally provide -lcrypt
also remove redundant "util" string matching.
2020-12-08 13:56:21 -07:00
Nathan Michaels
83b2785a43 Implement msp430 mapping for c_longdouble. (#7333) 2020-12-08 11:14:33 -07:00
LemonBoy
e2104ecc2d stage1: Fix type mapping for c_longdouble
A quick and dirty job to let the compiler use the correct size and
alignment.
2020-12-08 11:14:21 -07:00
xackus
05fefc0d3f std.c: freeing null is a no-op 2020-12-08 11:11:49 -07:00
Veikka Tuominen
01ff3684dc Merge pull request #7313 from LemonBoy/booo
Fix a few unsound optimizations on single-element union/enum
2020-12-06 12:37:18 -07:00
Andrew Kelley
48c8948f49 update to latest clang C headers 2020-12-04 17:25:55 -07:00
Jakub Konka
f385419259 macho: specify -install_name as full dylib's name
This then allows for proper resolution of names via runpath search
path list, i.e., `-rpath @loader_path` will correctly resolve
to `@rpath/libxxx.dylib (...)` in the linked binary.
2020-12-04 14:54:17 -07:00
Jakub Konka
96a703ee6d Version-gate appending -syslibroot flag to lld
This commit version-gates appending `-syslibroot` flag to lld. This
is predicated upon the fact that for versions of macOS lower than
11, lld would fail to find and link against frameworks with this
flag specified.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-12-04 12:39:07 -07:00
Jakub Konka
32997a2fb0 Merge pull request #7293 from kubkon/fix-7030
stage1: allow idx 0 err to be put into error_name_table
2020-12-04 12:39:01 -07:00
Andrew Kelley
a1d0c77539 add more mingw-w64 .def files
closes #7268
2020-12-03 18:04:39 -07:00
Andrew Kelley
2ce5f84c2f stage1: compile error for pointer arithmetic on ptr-to-array
See #2018
2020-12-03 17:46:21 -07:00
Andrew Kelley
05265160ae add @cImport files to Compilation cache manifest
closes #7007
2020-12-03 16:08:55 -07:00
Koakuma
52de625df9 Fix floating point parsing on BE systems (#7256)
* Fix floating point parsing on BE systems

* Load the appropriate endian.h files for macOS and BSD

* Add endian definition for Windows and extra check for ldshape selection

* Fix endian macro definition for macOS

Apparently their macros are defined without a leading __.

* Define new macro for endian checking purposes

This is gross and I really do not like the lack of standardization
around this part, but what can I do?
2020-12-03 13:47:31 -07:00
Miles Alan
cdde9d8885 std/event: Fix import path for WaitGroup 2020-12-03 13:44:25 -07:00
Andrew Kelley
ff802cc996 stage2: don't pass -l arguments when building .a or .o files
See #7094
2020-12-02 20:25:03 -07:00
LemonBoy
0ac43154eb std: Add nosuspend around stderr.print calls 2020-12-02 17:54:34 -07:00
Vexu
401d091fb4 std.build: addBuildOption special handling for SemanticVersion 2020-12-02 17:54:29 -07:00
Andrew Kelley
b1f52ca7f2 stage2: linkAsArchive: respect disable_lld_caching
Closes #7274
Closes #6943
2020-12-02 16:40:00 -07:00
LemonBoy
02cb3841a6 ci: Retry apt-get install at most three times
Try harder instead of failing after the first invocation fails.
2020-12-02 16:16:36 -07:00
LemonBoy
7c13bec7cb std: make the use of pthread_join POSIX-compliant
Applications supplying their own custom stack to pthread_create are not
allowed to free the allocated memory after pthread_join returns as,
according to the specification, the thread is not guaranteed to be dead
after the join call returns.

Avoid this class of problems by avoiding the use of a custom stack
altogether, let pthread handle its own resources.

Allocations made on the child stack are now done on the C heap.

Thanks @semarie for noticing the problem on OpenBSD and suggesting a
fix.

Closes #7275
2020-12-02 16:16:31 -07:00
Mathieu Guay-Paquet
7add370371 fix the tinyest typo 2020-12-02 16:16:02 -07:00
daurnimator
d15a0ec7b2 Localhost is special (#6955)
* std: always return loopback address when looking up localhost

* std: also return Ipv6 loopback

* std: remove commented out obsolete code
2020-12-01 17:14:43 -07:00