3915 Commits

Author SHA1 Message Date
Timon Kruiper
d33766e6c7 Make sure that ZigTypeVector and ZigTypeArray have the same memory layout
Throughout the stage1 code it is assumed that these have the same layout,
but that was not the case. This caused an issue on 32-bit hardware.
2020-04-01 20:50:13 +02:00
Timon Kruiper
ae6965a4e7 Fix undefined behavior when shift amount is 64 2020-04-01 20:50:09 +02:00
Timon Kruiper
d9cf779b47 Fix some nullptr dereferences on arm-linux-musleabhif 2020-04-01 20:38:32 +02:00
Timon Kruiper
9e019ed26b Fix possible unaligned ptr from getauxval
This caused SIGILL on armv7a-linux
2020-03-31 15:26:06 -04:00
Andrew Kelley
47a0e3ec5e
Merge pull request #4871 from boothby/issue4769
Address bugs when //, /// or //! are immediately followed by EOF
2020-03-31 10:56:21 -04:00
Andrew Kelley
839d85e440 fixes to 32-bit handling, to support 32-bit arm 2020-03-31 10:10:31 -04:00
Kelly Boothby
1111d3ad13 fixed bugs hitting EOF immediately after //, /// or //! 2020-03-30 18:30:03 -07:00
Andrew Kelley
cfedd3aca2
revert detection of rtti and exceptions
This caused link errors in c++ code because it was not correct to pass
these flags to child codegens. And that was the only reason to detect
these flags. Otherwise we can safely rely on non-explicitly-detected
flag forwarding.
2020-03-30 17:42:30 -04:00
Andrew Kelley
6408766d6b
linking: remove check for target_supports_libunwind
I'm not sure why this was ever there. Maybe it was working around a
problem with LLVM 9. Anyway this fixes linking C++ code for 32 bit
arm and riscv.
2020-03-30 15:50:53 -04:00
Andrew Kelley
b980568c81
add peer type resolution for mixed-const []T and *[N]T
closes #4766

This commit also fixes the implementation of some utility functions for
adjusting properties of pointer types. Previously these functions would
incorrectly drop vector, sentinel, and inference metadata.
2020-03-30 13:02:50 -04:00
LemonBoy
c1cc1ebc35 ir: Avoid constant-folding ptr to sentinels
Constant-folding the pointers to the expected sentinel value have some
big problems: it hides the real content of the array, makes the pointer
to the sentinel point to a completely different memory region and treats
it like a const value even when the underlying array is mutable.

Fixes #4840
2020-03-30 11:03:56 -04:00
Andrew Kelley
f9f7deaeda
linking against c++ does not trigger system library directories 2020-03-29 20:58:59 -04:00
Andrew Kelley
5aa2812507
linking is now aware -lm is provided by mingw-w64 2020-03-29 13:17:21 -04:00
Andrew Kelley
38a1af5d4f
zig cc: -O0 also counts as debug mode 2020-03-29 10:34:12 -04:00
Ryan Liptak
874b4618ca zig cc: Add support for -z
This is only the first step; it makes zig cc recognize -z and append it to the linker args, but the linker arg parsing doesn't support -z yet so it will just give the warning 'unsupported linker arg: -z'
2020-03-28 00:35:54 -07:00
Ryan Liptak
b0b29b8a2f zig cc: Add support for -Xlinker, --for-linker, --for-linker= 2020-03-27 23:32:01 -07:00
Andrew Kelley
12e1c6e21c
Merge pull request #4835 from squeek502/export-dynamic
-rdynamic/--export-dynamic fixes
2020-03-28 02:16:09 -04:00
Andrew Kelley
69aa09948b
cmake: support cross compiling 2020-03-27 23:43:21 -04:00
Andrew Kelley
a258741084
initial support of response files
See #4833

It doesn't support comments or quotes yet.
2020-03-27 22:24:40 -04:00
Ryan Liptak
e7847f8d42 zig cc: Add --export-dynamic linker flag support 2020-03-27 17:42:02 -07:00
Ryan Liptak
1a95f1c2e0 Fix -rdynamic not sending --export-dynamic to the ELF linker 2020-03-27 17:36:43 -07:00
Andrew Kelley
f407109070
zig c++: get it working with musl and mingw-w64 2020-03-27 12:38:52 -04:00
Andrew Kelley
db17c0d88c
ability to compile c++ hello world with zig c++
closes #4786
2020-03-26 22:48:37 -04:00
Andrew Kelley
0d4354324c
fix behavior tests compile error on i386-linux 2020-03-26 12:54:59 -04:00
Andrew Kelley
ddd98a7f10
prevent ptr cast from forcing alignment resolution unnecessarily 2020-03-26 12:34:16 -04:00
Andrew Kelley
5ec6a0ea02
fix an invalid free having to do with bound functions
this should fix the drone CI failure
2020-03-25 21:00:02 -04:00
Andrew Kelley
fae6cf0961
improved handling of native system directories
* `-isystem` instead of `-I` for system include directories
   fixes a problem with native system directories interfering with zig's
   bundled libc.
 * separate Stage2Target.is_native into Stage2Target.is_native_os and
   Stage2Target.is_native_cpu.
2020-03-25 20:34:15 -04:00
Andrew Kelley
e3fec6cce9
zig cc: add detection for -###
it turns on --verbose-cc and --verbose-link
2020-03-25 19:32:12 -04:00
Andrew Kelley
f313ab18ae
zig cc: freestanding target implies -nostdlib 2020-03-25 12:28:41 -04:00
Andrew Kelley
6cbe589b51
zig cc: support -T linker script option 2020-03-25 12:05:48 -04:00
Andrew Kelley
3869e80331
Merge pull request #4793 from LemonBoy/netbsd-forever
Netbsd forever
2020-03-25 10:19:49 -04:00
Andrew Kelley
93c7fa105f
Merge remote-tracking branch 'origin/llvm10'
LLVM 10 was released today
2020-03-24 09:57:09 -04:00
LemonBoy
2f21c8f5ba stage1: Link pthread on NetBSD 2020-03-23 18:47:39 +01:00
LemonBoy
bab66235b9 stage1: Remove fflush on file open for reading
On NetBSD this caused the libuserland compilation to fail.

Closes #3719
2020-03-23 17:17:28 +00:00
Andrew Kelley
dc44fe053c
zig cc: detect dynamic linker argument 2020-03-23 12:39:18 -04:00
Andrew Kelley
e643b414e4
zig cc: recognize .S and .C as source file extensions 2020-03-23 11:34:16 -04:00
LemonBoy
0cd953d40e ir: Prevent crash when slicing hardcoded pointer
Closes #4780
2020-03-23 09:13:52 -04:00
Andrew Kelley
13d04f9963
Merge pull request #4741 from momumi/master
allow `_` separators in number literals (stage 1)
2020-03-23 00:54:54 -04:00
Andrew Kelley
94f7c56001
riscv: add -mrelax arg for C to work around upstream issue
See #4485
2020-03-22 21:47:19 -04:00
Andrew Kelley
e5e5196d8e
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-22 20:48:21 -04:00
Andrew Kelley
7ffdf59c44
Merge pull request #4774 from ziglang/zig-cc
ability to use `zig cc` as a drop-in C compiler
2020-03-22 19:20:02 -04:00
LemonBoy
6a89751025 ir: Implement cast from anon struct to union 2020-03-22 19:06:22 -04:00
Andrew Kelley
23c263776c
Merge remote-tracking branch 'origin/master' into llvm10 2020-03-22 15:09:29 -04:00
Andrew Kelley
2b65dc1032
zig cc: detect optimization and debug flags 2020-03-21 22:30:46 -04:00
LemonBoy
dc79f181a5
ir: Disallow comparison between enum literal and untagged enum
Closes #4770
2020-03-21 20:54:05 -04:00
Andrew Kelley
4b0ddb817b
zig cc: better support for the preprocessor option (-E) 2020-03-21 20:32:48 -04:00
Michael Dusan
28ad78cb7f
rename "passthrough" → "driver_punt"
- punt when `-E` is supplied
- punt when `-S` is supplied
2020-03-21 16:53:59 -04:00
Andrew Kelley
4d9b458f8f
zig cc: support .cc and .cxx extensions 2020-03-21 16:51:43 -04:00
Andrew Kelley
0eee98edc1
zig cc improvements
* The generated options data file is sorted now in a way that
   makes sure longer prefixes are first. This prevents collisions
   with some parameters.
 * Add support for `-fPIC`, `-fno-PIC`, `-nostdlib`, `-shared`,
   `-rdynamic`, `-Wl,-soname`, `-Wl,-rpath`
 * Better support for `-o`.
 * Disable generating h files
 * Shared library support.
 * Better positional argument support.
2020-03-21 15:40:49 -04:00
Andrew Kelley
a4eaeee720
ability to use zig cc as a drop-in C compiler
The basics are working
2020-03-21 15:39:39 -04:00