11458 Commits

Author SHA1 Message Date
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
Isaac Freund
a05ae01b4f std/os: define and use dev_t for linux x86_64 2020-11-20 18:36:23 -07:00
Isaac Freund
1344706b47 std/os: add time_t definiton for x86_64 linux 2020-11-20 18:36:15 -07:00
LemonBoy
72980388ca stage1: Resolve usingnamespace decls when calling @typeInfo
Closes #7176
2020-11-20 18:02:20 -07:00
LemonBoy
c6c25a1c09 stage1: Fix undefined assignment for bitfields
Prevents silent memory corruption.

Closes #7055
2020-11-18 22:51:34 -07:00
Frank Denis
3f134cfe5e edwards25519 - skip useless operations and duplicate lookup table
Just some trivial changes; no functional changes.

Skip useless nul additions and multiplications and comptime the
basepoint multiples only once.
2020-11-18 21:45:42 -08:00
breakin
e814f71052 Change seed for Murmur2_64 from u32 to u64 2020-11-18 18:06:04 -07:00
Veikka Tuominen
50269f2315 Merge pull request #6649 from Rocknest/verparse
make Version.parse less strict
2020-11-18 17:47:43 -07:00
Vexu
8af0a1987b make help in commands more consistent
Closes #7101

Co-authored-by: pfg <pfg@pfg.pw>
2020-11-18 17:37:14 -07:00
Timon Kruiper
b498d26376 Allow Zig to be built with clang 11 and -Werror
This was brought to the horizon when using zig-bootstrap to cross compile
Zig for windows-gnu.
2020-11-18 17:32:48 -07:00
LemonBoy
d3f1a4edce stage1: Add architecture-specific clobbers to asm()
We're basically following Clang's lead, add the necessary clobbers to
minimize the risk of generating wrong code.
2020-11-18 17:32:41 -07:00
Veikka Tuominen
1add7c616f Merge pull request #7084 from xackus/mem-volatile
std.mem: make sliceAsBytes, etc. respect volatile
2020-11-18 17:31:11 -07:00
Frank Denis
5f9a664de9
STAGE1_SOURCES: In 0.7.x, leb128.zig is in std/debug (#7148)
* STAGE1_SOURCES: In 0.7.x, leb128.zig is in std/debug

* codegen/aarch64.zig doesn't exist in 0.7.x

Co-authored-by: Frank Denis <github@purftpd.org>
2020-11-18 14:53:47 -05:00
LemonBoy
1c8cd268be stage1: Fix asyncCall with non-abi-aligned arguments
Make the code used to calculate the variable slot index into the frame
match what's done during the structure layout calculation.

Prevents a few nasty LLVM errors when such types are passed around.
2020-11-17 16:55:44 -07:00
Andrew Kelley
eea4cd2924 cli: make -h, --help consistent in usage text and parsing
also trivial fixes in the general usage text
2020-11-17 16:54:15 -07:00
Guoxin Yin
4d44a813de Add -h alias for --help 2020-11-17 11:39:42 -07:00
johnLate
51ffb0548d CMake: properly detect when to rebuild zig1.o
This is andrewrk's patch from ziglang#6724 (rebased)

CMake: Fix dependency problem

I don't know whether the error was expected cmake behavior or a bug.
This change seems to fix the issue. See ziglang#6724 for details.

cmake: add the correct set of zig stage2 sources
2020-11-16 18:04:54 -07:00
Alex Cameron
5b42704ea7 Prevent double file close in MachO linking 2020-11-16 15:00:22 -07:00
Frank Denis
c8b6e407ba Enable loop interleaving when unrolling is enabled
This mimics clang's default behavior.
2020-11-16 15:00:16 -07:00
LemonBoy
9e1e91dafc std: Make windows.ReadFile allow short reads
Make it behave like the read() wrapper for unix systems.
Reading the whole buffer breaks some use-cases like buffered readers
over sockets.

Closes #7121
2020-11-16 14:35:28 -07:00
LemonBoy
6624f9cd5c stage1: Fix generation of pass-by-value args in async fns
The mismatch between the argument slot type in the frame structure and
the one used in the store operation made the generated code write
garbage over the nearby fields.

Fixes #7104
2020-11-16 11:37:49 -07:00
Andrew Kelley
7d0c461b77 std.fs.path.dirname: return null when input path is root
This intentionally diverges from the unix dirname command, as well as
Python and Node.js standard libraries, which all have this edge case
return the input path, unmodified. This is a footgun, and nobody should
have ever done it this way.

Even the man page contradicts the behavior. It says:
"strip last component from file name". Now consider, if you
remove the last item from an array of length 1, then you
have now an array of length 0. After you strip the last component, there
should be no components remaining. Clearly, returning the input parameter
unmodified in this case does not match the documented behavior. This is
my justification for taking a stand on this API design.

closes #6746
closes #6727
closes #6584
closes #6592
closes #6602
2020-11-15 10:53:06 -07:00
LemonBoy
2d280825cd stage1: Disambiguate Wasm imports with same name
Closes #7088
2020-11-13 14:33:20 -07:00
LemonBoy
10617593f8 stage1: Resolve ErrorUnion children types
Since the code is accessing the abi_size field compute the full type
size for both err_set_type and payload_type, not only for the latter.
2020-11-13 14:29:38 -07:00
LemonBoy
10b1001a12 stage1: Ask LLVM to produce compact code in ReleaseSize mode
Let's follow what Clang does for -Oz and apply the `minsize` and
`optsize` attributes by default.

Closes #7048
Supersedes #7077
2020-11-13 10:27:26 -07:00
Hubert Jasudowicz
eaa1db2002 std: Fix code model argument 2020-11-11 19:33:10 -07:00
Vexu
1aec406311 std: fix HashMap.clearRetainingCapacity 2020-11-11 19:33:03 -07:00
Vexu
b6350a2b3f std: fix HashMap.putAssumeCapacity 2020-11-11 19:32:58 -07:00
Vexu
8c62733927 ensure TypeInfo payload is not undefined 2020-11-11 19:32:30 -07:00
LemonBoy
aa6fc29744 stage1: Fix crash in comptime struct generation
Using the gen_index rather than the src_index is needed to handle
structures containing zero-sized or comptime only types.

Closes #7027
2020-11-11 19:14:03 -07:00
Jonas Carpay
01a927a0cb Fix backticked code in langref 2020-11-11 19:13:52 -07:00
LemonBoy
7d3c5f207a stage1: Avoid resolving type entry in [0]T
The logic was already there but this rule was only applied in some
places, apply it in the remaining code paths.

Closes #7058
2020-11-11 19:13:04 -07:00
Andrew Kelley
0405698696 add missing -m<os>-version-min CLI args to clang
This fixes some code generation issues when targeting macOS and
compiling C/C++ code.
2020-11-10 15:24:57 -07:00