3929 Commits

Author SHA1 Message Date
Andrew Kelley
e7f555ca55
stage1: fix build for i386-linux 2020-04-02 19:07:52 -04:00
Timon Kruiper
b5526d0b3b Fix multiplication overflow in hash_const_val
In some cases the compiler was actually emitting an 64 bit signed
multiplication, instead of a 32 bit unsigned one.
2020-04-02 17:51:04 -04:00
Andrew Kelley
5314641e11
zig cc: support more linker args 2020-04-02 17:29:22 -04:00
Andrew Kelley
c1778bd41f
zig cc: support --version-script linker arg
See #4784
2020-04-02 16:59:08 -04:00
Andrew Kelley
c4b3c84b3f
zig cc: support -F and -framework 2020-04-02 15:59:48 -04:00
Andrew Kelley
e4edc6d118
zig cc: respect -MF -MV -MD options
Zig disables its caching and forwards these args when any are provided.

see #4784
2020-04-02 15:47:27 -04:00
Andrew Kelley
4848b28ec8
zig cc: detect -mcpu, -march, -mtune
However these are all treated like zig's -mcpu parameter.

See #4784
2020-04-01 18:06:04 -04:00
Rejean Loyer
2b6dfdd3d4 zig cc: add support for -L linker arguments 2020-04-01 17:21:11 -04:00
Andrew Kelley
783f73c7e3
zig cc properly handles -S flag and .ll, .bc extensions 2020-04-01 16:01:06 -04:00
LemonBoy
6695fa4f32 ir: Fix comparison of ?T values
The code assumed that every ?T had a pointer child type T, add some more
checks to make sure the type is effectively a pointer.

Closes #4789
2020-04-01 15:56:38 -04:00
Michael Dusan
212e2354b8 stage1: make C++ switch fallthrough an error
Make fallthrough an error when compiler supports it. This requires a new
macro that is defined with such compilers to be used as a statement, at
all fallthrough sites:

    switch (...) {
        case 0:
            ...
            ZIG_FALLTHROUGH;
        case 1:
            ...
            break;
        default:
            ...
            break;
    }

If we ever move to C++17 as minimal requirement, then the macro can be
replaced with `[[fallthrough]];` at statement sites.
2020-04-01 15:56:00 -04:00
Andrew Kelley
0f1f56bb69
Merge pull request #4896 from FireFox317/fix-arm32-stuff
fix some nullptr dereferences on arm-linux-musleabhif
2020-04-01 15:55:31 -04:00
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
Andrew Kelley
553f0e0546
fixups and revert a few things 2020-04-01 11:56:39 -04:00
daurnimator
7eb938c909
Use length field as passed in stage2 libc_installation instead of relying on zero termination 2020-04-01 10:36:38 -04: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