11490 Commits

Author SHA1 Message Date
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
LemonBoy
0858d7b0df stage2: Create cache manifest before calling final
If we enter the `if` because `comp.disable_c_depfile` is false the `man`
object has no manifest and calling .final on it will trip an assertion.

Closes #7096
2020-12-01 16:52:52 -07:00
Andrew Kelley
a4c8bd8fd4 stage2: add -femit-foo=bar args to the cache hash
Closes #6979
Closes #7036
2020-12-01 16:36:37 -07:00
Alexandros Naskos
7099dff7ea Add package names and paths to the zig root module cache hash.
Add package names to the stage1 cache hash and package files to the
stage1 manifest file.
2020-12-01 14:57:27 -07:00
Timon Kruiper
6bf19e32e7 Make sure to include the root_name in the cache.
This fixes a bug where the caching system did not notice when the
--name flag changed.
2020-12-01 11:39:15 -07:00
Andrew Kelley
c8b8f0ea13 COFF linking: fix incorrectly passing .dll instead of .lib
commit 9d1816111d1d30e18b8cb43a4aa31c194fb204c4 used the "output path"
as the path for passing shared library artifact paths to the Zig CLI.
For Windows, this was incorrect because it would pass the .dll instead
of the .lib file. This commit passes the "output lib path" instead,
which makes it pass the .lib path in case of a .dll on Windows.

This way the linker does not complain and say, "bad file type. Did you
specify a DLL instead of an import library?"
2020-12-01 11:31:48 -07:00
Andrew Kelley
d2445764a9 restore -target wasm32-freestanding-musl for C headers
See #5854

Some tiny tweaks too:
 * Use `wasm-freestanding-musl` instead of `wasm32-freestanding-musl`,
   making it pointer-size-agnostic.
 * Fix trying to build non-existent wasm musl start files.
2020-11-30 20:58:31 -07:00
Andrew Kelley
a9b7d8fa07 stage2: fix not detecting all dynamic libraries
Positional shared library arguments were not being detected as causing
dynamic linking, resulting in invalid linker lines. LLD did not have an
error message for this when targeting x86_64-linux but it did emit an
error message when targeting aarch64-linux, which is how I noticed the
problem.

This surfaced an error having to do with fifo.pipe() in the cat example
which I did not diagnose but solved the issue by doing the revamp that
was already overdue for that example.

It appears that the zig-window project was exploiting the previous
behavior for it to function properly, so this prompts the question, is
there some kind of static/dynamic executable hybrid that the compiler
should recognize? Unclear - but we can discuss that in #7240.
2020-11-30 20:58:15 -07:00
Andrew Kelley
57ac835a03 Merge branch 'alexnask-fix_6868' into master
Closes #7139
Closes #6868
2020-11-30 18:13:06 -07:00
Andrew Kelley
3c907e51d1 fix regression on wasm targets
The previous commit broke wasm targets because the linking step would
look for the compiler-rt lib in the wrong place. Fixed in this commit.
2020-11-30 17:47:24 -07:00
Andrew Kelley
791e38da8c Merge branch 'alexnask-bundle_compiler_rt' into master
Closes #7013
Closes #6817
2020-11-30 16:50:56 -07:00
Michael Freundorfer
1a61a9d4bf Fix WindowsDynLib.openW trying to strip the \??\ prefix when it does not exist 2020-11-30 12:13:17 -07:00
Jonathan Marler
8f346d9a4b fix memory leak in BufMap 2020-11-30 11:40:44 -07:00
LemonBoy
a7c2cfe16d stage1: Fix typeInfo generation for arrays w/o sentinel
ZigTypeIdOptional types have a different way of specifying their payload
value depending on whether the child type is a pointer or not (plus some
other special cases).

Fixes #7251
2020-11-29 11:39:35 -07:00
LemonBoy
0a4a99ec87 stage1: Add missing bitcast when rendering var ptr
Some types require this extra bitcast, eg. structs or unions with extra
padding fields inserted by the compiler.

Fixes #7250
2020-11-29 11:37:44 -07:00
LemonBoy
be2adff087 std: Avoid deadlock in the signal handler
stderr_mutex may still be held when we reach the signal handler, grab
our own stderr handle to print the error messages and avoid deadlocking.

Closes #7247
2020-11-29 11:31:38 -07:00
christian-stephen
a6222d1d4b Add readAllArrayListAligned to Reader which can accept an arbitrary alignment 2020-11-27 18:01:49 -07:00
Andrew Kelley
f09f960ce4 Merge branch 'kubkon-elf-soname-opt-in' into master
closes #7162
2020-11-27 17:57:11 -07:00
LemonBoy
288b8b535f stage1: Fix crash in *[N]T to []T conversion with zst
Prevent the crash by not making the codegen try to access the
non-existing ptr field in the slice.

Closes #6951
2020-11-27 15:34:13 -07:00
LemonBoy
36b8f5d194 stage1: Force union member types to be resolved
No test case because I couldn't reduce the huuuge test case.
Fixes the problem discovered by @ifreund.
2020-11-26 11:50:38 -07:00
Isaac Freund
41d57b051f std/os: fix prctl constants 2020-11-25 16:47:44 -07:00
LemonBoy
24d4bfb666 stage1: Fix ICE when generating struct fields with padding
Make gen_const_ptr_struct_recursive aware of the possible presence of
some trailing padding by always bitcasting the pointer to its expected
type.

Not an elegant solution but makes LLVM happy and is consistent with how
the other callsites are handling this case.

Fixes #5398
2020-11-25 16:36:57 -07:00
Jonathan Marler
06a75c16ff fix for GCC 9.2: -Wno-maybe-uninitialized 2020-11-24 18:32:57 -07:00
Frank Denis
8af016c5be Update the minimum cmake version we require
Recent versions of cmake complain about it:

<<
  CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.
>>

We don't require anything from version 2.8.5, and version 2.8.12 was
released in 2011, so it is very unlikely that anyone still uses 2.8.5.
2020-11-24 18:32:51 -07:00