200 Commits

Author SHA1 Message Date
Meghan
b73cf97c93
replace other uses of std.meta.Vector with @Vector (#11346) 2022-03-30 14:12:14 -04:00
Andrew Kelley
71b8760d3b stage2: rework @mulAdd
* mul_add AIR instruction: use `pl_op` instead of `ty_pl`. The type is
   always the same as the operand; no need to waste bytes redundantly
   storing the type.
 * AstGen: use coerced_ty for all the operands except for one which we
   use to communicate the type.
 * Sema: use the correct source location for requireRuntimeBlock in
   handling of `@mulAdd`.
 * native backends: handle liveness even for the functions that are
   TODO.
 * C backend: implement `@mulAdd`. It lowers to libc calls.
 * LLVM backend: make `@mulAdd` handle all float types.
   - improved fptrunc and fpext to handle f80 with compiler-rt calls.
 * Value.mulAdd: handle all float types and use the `@mulAdd` builtin.
 * behavior tests: revert the changes to testing `@mulAdd`. These
   changes broke the test coverage, making it only tested at
   compile-time.

Improved f80 support:
 * std.math.fma handles f80
 * move fma functions from freestanding libc to compiler-rt
   - add __fmax and fmal
   - make __fmax and fmaq only exported when they don't alias fmal.
   - make their linkage weak just like the rest of compiler-rt symbols.
 * removed `longDoubleIsF128` and replaced it with `longDoubleIs` which
   takes a type as a parameter. The implementation is now more accurate
   and handles more targets. Similarly, in stage2 the function
   CTypes.sizeInBits is more accurate for long double for more targets.
2022-03-06 16:11:39 -07:00
gwenzek
0e1afb4d98
stage2: add support for Nvptx target
sample command:

/home/guw/github/zig/stage2/bin/zig build-obj cuda_kernel.zig -target nvptx64-cuda -O ReleaseSafe
this will create a kernel.ptx

expose PtxKernel call convention from LLVM
kernels are `export fn f() callconv(.PtxKernel)`
2022-02-05 16:33:00 +02:00
Andrew Kelley
75bbc74d56 a small crusade against std.meta.declarations 2022-01-31 22:25:49 -07:00
ominitay
8ca9452a82 Remove deprecation warnings and enable test
Also fixes previously broken code uncovered by this
2022-01-29 15:49:00 +02:00
Andrew Kelley
1530203c80 glibc: update default cross-compile version to 2.19
This number tracks the glibc version in the oldest still-active LTS
version of Debian, which is Jessie, extended LTS expiring in June 2022,
at which point this number can be bumped again.
2021-12-16 03:01:13 -07:00
Andrew Kelley
f3edff439e improve detection of how to execute binaries on the host
`getExternalExecutor` is moved from `std.zig.CrossTarget` to
`std.zig.system.NativeTargetInfo.getExternalExecutor`.

The function also now communicates a bit more information about *why*
the host is unable to execute a binary. The CLI is updated to report
this information in a useful manner.

`getExternalExecutor` is also improved to detect such patterns as:
 * x86_64 is able to execute x86 binaries
 * aarch64 is able to execute arm binaries
 * etc.

Added qemu-hexagon support to `getExternalExecutor`.

`std.Target.canExecBinaries` of is removed; callers should use the more
powerful `getExternalExecutor` instead.

Now that `zig test` tries to run the resulting binary no matter what,
this commit has a follow-up change to the build system and docgen to
utilize the `getExternalExecutor` function and pass `--test-no-exec`
in some cases to avoid getting the error.

Additionally:

 * refactor: extract NativePaths and NativeTargetInfo into their own
   files named after the structs.
 * small improvement to langref to reduce the complexity of the `callconv`
   expression in a couple examples.
2021-12-02 21:51:14 -07:00
Lee Cannon
85de022c56
allocgate: std Allocator interface refactor 2021-11-30 23:32:47 +00:00
Jakub Konka
d6f43a1eac bpf: do not invoke lld when linking eBPF relocatables
Due to a deficiency in LLD, we need to special-case BPF to a simple
file copy when generating relocatables. Normally, we would expect
`lld -r` to work. However, because LLD wants to resolve BPF relocations
which it shouldn't, it fails before even generating the relocatable.

Co-authored-by: Matthew Knight <mattnite@protonmail.com>
2021-11-26 10:53:30 +01:00
Jakub Konka
c42439dff9 Pass inferred cpu_arch to defaultVersionRange
This is mainly because arm64 macOS doesn't support all
versions supported by x86_64 macOS. This is just a temporary
thing until both architectures support the same set of OSes.
2021-11-25 12:19:16 +01:00
Jakub Konka
42a351e099 infer and match macos sdk version for libc headers 2021-11-25 12:19:16 +01:00
Andrew Kelley
01ad6c0b02 freestanding libc: don't rely on compiler_rt symbols we don't have yet
Previous commit made fmal depend on __extendxftf2 and __trunctfxf2 but
we don't have implementations of those yet.
2021-10-05 18:19:31 -07:00
Andrew Kelley
6115cf2240 migrate from std.Target.current to @import("builtin").target
closes #9388
closes #9321
2021-10-04 23:48:55 -07:00
Andrew Kelley
3eb729b442 Merge remote-tracking branch 'origin/master' into llvm13 2021-09-30 21:38:04 -07:00
Stephen Gregoratto
87fd502fb6 Initial bringup of the Solaris/Illumos port 2021-09-24 14:06:16 -04:00
Andrew Kelley
6aeab0f323 Merge remote-tracking branch 'origin/master' into llvm13
Conflicts:
   lib/libcxx/include/__config

d57c0cc3bfeff9af297279759ec2b631e6d95140 added support for DragonFlyBSD
to libc++ by updating some ifdefs. This needed to be synced with llvm13.
2021-08-28 12:41:24 -07:00
Andrew Kelley
d29871977f remove redundant license headers from zig standard library
We already have a LICENSE file that covers the Zig Standard Library. We
no longer need to remind everyone that the license is MIT in every single
file.

Previously this was introduced to clarify the situation for a fork of
Zig that made Zig's LICENSE file harder to find, and replaced it with
their own license that required annual payments to their company.
However that fork now appears to be dead. So there is no need to
reinforce the copyright notice in every single file.
2021-08-24 12:25:09 -07:00
Andrew Kelley
2f599b655b update src/ to LLVM 13 rc1 API 2021-08-16 01:11:10 -07:00
Andrew Kelley
7adf15682c update target CPU features with LLVM 13 rc1 data 2021-08-15 23:09:55 -07:00
Andrew Kelley
a5fb28070f add -femit-llvm-bc CLI option and implement it
* Added doc comments for `std.Target.ObjectFormat` enum
 * `std.Target.oFileExt` is removed because it is incorrect for Plan-9
   targets. Instead, use `std.Target.ObjectFormat.fileExt` and pass a
   CPU architecture.
 * Added `Compilation.Directory.joinZ` for when a null byte is desired.
 * Improvements to `Compilation.create` logic for computing `use_llvm`
   and reporting errors in contradictory flags. `-femit-llvm-ir` and
   `-femit-llvm-bc` will now imply `-fLLVM`.
 * Fix compilation when passing `.bc` files on the command line.
 * Improvements to the stage2 LLVM backend:
   - cleaned up error messages and error reporting. Properly bubble up
     some errors rather than dumping to stderr; others turn into panics.
   - properly call ZigLLVMCreateTargetMachine and
     ZigLLVMTargetMachineEmitToFile and implement calculation of the
     respective parameters (cpu features, code model, abi name, lto,
     tsan, etc).
   - LLVM module verification only runs in debug builds of the compiler
   - use LLVMDumpModule rather than printToString because in the case
     that we incorrectly pass a null pointer to LLVM it may crash during
     dumping the module and having it partially printed is helpful in
     this case.
   - support -femit-asm, -fno-emit-bin, -femit-llvm-ir, -femit-llvm-bc
   - Support LLVM backend when used with Mach-O and WASM linkers.
2021-07-22 19:51:32 -07:00
Andrew Kelley
36295d712f remove 'pe' object format
Portable Executable is an executable format, not an object format.
Everywhere in the entire zig codebase, we treated coff and pe as if they
were the same. Remove confusion by not including pe in the
std.Target.ObjectFormat enum.
2021-07-21 12:45:32 -07:00
jacob gw
34c21affa2 initial plan9 boilerplate
The code now compiles and fails with Plan9ObjectFormatUnimplemented
2021-07-08 14:10:49 -07:00
kprotty
0a1def7833 changes to accomodate std.Thread update 2021-06-30 21:48:59 -05:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Andrew Kelley
da4081fe21 cleanups to previous commit
* fix a merge conflict discovered upon rebasing latest master
 * rename Target.Cpu.Feature.Set.subSet to isSuperSetOf
 * convert a comment into an assert
2021-06-11 14:01:13 -07:00
Edward Dean
7ba175cd8b Add CPU feature check to standardTargetOptions
If there is a mismatch of CPU features provided
compared to the whitelist, then will fail the build and
print what the expected CPU model is and the feature
set for the model. Also prints what features need to be
removed.
2021-06-11 13:32:28 -07:00
Sebastien Marie
fbd99319d1
openbsd: adjust dynamic linker path (#9010)
the dynamic linker on OpenBSD is at /usr/libexec/ld.so (and not /libexec/ld.so)
2021-06-06 16:35:15 +02:00
Kenta Iwasaki
4909aa1da4 os/bits: remove duplicate sockaddr_storage for dragonfly 2021-06-01 18:35:13 +09:00
protty
eb6975f088
std.sync.atomic: extended atomic helper functions (#8866)
- deprecates `std.Thread.spinLoopHint` and moves it to `std.atomic.spinLoopHint`
- added an Atomic(T) generic wrapper type which replaces atomic.Bool and atomic.Int
- in Atomic(T), selectively expose member functions depending on T and include bitwise atomic methods when T is an Integer
- added fence() and compilerFence() to std.atomic
2021-05-31 11:11:30 -05:00
Andrew Kelley
609207801a make "gnu" (mingw-w64) the default C ABI on Windows
Closes #6565
2021-05-24 00:13:54 -04:00
Jakub Konka
bd325d1bd9 wasm: fix object extension to standard .o from .o.wasm
This should offer more compatibility with external tooling when
cross-compiling to wasm with zig.
2021-05-21 22:29:36 +02:00
Jakub Konka
6d5002028a cc,wasi: link compiled WASI libc with wasm-ld 2021-05-20 16:54:00 +02:00
Andrew Kelley
597082adf4 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * src/Compilation.zig
 * src/codegen/spirv/spec.zig
 * src/link/SpirV.zig
 * test/stage2/darwin.zig
   - this one might be problematic; start.zig looks for `main` in the
     root source file, not `_main`. Not sure why there is an underscore
     there in master branch.
2021-05-15 21:44:38 -07:00
Robin Voetter
98dc8eb7d9 SPIR-V: Add generated SPIR-V features 2021-05-14 19:49:32 +02:00
Robin Voetter
fa3afede58 SPIR-V: Set default ofmt to spirv 2021-05-14 19:49:32 +02:00
Andrew Kelley
c9cc09a3bf Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * lib/std/os/linux.zig
 * lib/std/os/windows/bits.zig
 * src/Module.zig
 * src/Sema.zig
 * test/stage2/test.zig

Mainly I wanted Jakub's new macOS code for respecting stack size, since
we now depend on it for debug builds able to pass one of the test cases
for recursive comptime function calls with `@setEvalBranchQuota`.

The conflicts were all trivial.
2021-05-12 16:41:20 -07:00
Michael Dusan
30ace64fc4 bsd: detect os version
- netbsd, dragonly: use sysctlbyname
- openbsd: use sysctl
- updated default semver ranges
2021-05-11 22:05:08 -04:00
Andrew Kelley
df24ce52b1 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted to take advantage of the new hex float parsing
code.
2021-04-28 14:57:38 -07:00
Andrew Kelley
86e129eff6 std.Target: bump freebsd known maximum version 2021-04-28 10:26:47 -07:00
Andrew Kelley
e86cee258c Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted the change that makes `suspend;` illegal in the
parser.
2021-04-24 10:44:41 -07:00
LemonBoy
d82eb8dd40 std: Split syscall parameters for PowerPC targets 2021-04-21 16:31:29 +02:00
Michael Dusan
0c6dfa6f0c target: drop ppc32 and prefer ppc
- original PR #7949 (incorrectly) patched a generated-file and changes
  have subsequently been lost/overwritten
- fix #7947 in a different way: drop `ppc32` because `ppc` already exists
2021-04-20 16:19:59 -04:00
Andrew Kelley
429cd2b5dd std: change @import("builtin") to std.builtin 2021-04-15 19:06:39 -07:00
Michael Dusan
93cf9560b1
Merge remote-tracking branch 'origin/master' into llvm12 2021-04-11 17:40:19 -04:00
LemonBoy
89df41e5d8 stage2: Default AVR generic cpu to avr2
The avr1 target is a very minimal subset of the AVR ISA, quoting the GCC
manual:

> This ISA is implemented by the minimal AVR core and supported for
> assembler only.

Default to avr2 as GCC and Clang do.
2021-04-06 10:18:11 -07:00
Michael Dusan
6fe2fb6cdb std.Target.Abi: add gnuilp32 2021-02-27 11:53:08 -08:00
Andrew Kelley
280195038a std.Target: add powerpcle 2021-02-27 02:51:35 -07:00
Andrew Kelley
50a5fc98dc update most target CPU features to llvm12
The tools/update_cpu_features script is coming along, and generates
correct information for all these targets. The remaining targets are:

 * arm
 * aarch64
 * amdgpu
 * riscv

I will commit them once the issues with the updater tool are resolved.
2021-02-27 01:05:53 -07:00
Andrew Kelley
03de5ec6dd tools/update_cpu_features: handle ISAs with no features
These are represented by not having a file for them.
2021-02-26 23:52:04 -07:00
Andrew Kelley
0b58b61799 Merge remote-tracking branch 'origin/master' into llvm12
Conflicts:
 * src/clang.zig
 * src/llvm.zig
   - this file got moved to src/llvm/bindings.zig in master branch so I
     had to put the new LLVM arch/os enum tags into it.
 * lib/std/target.zig, src/stage1/target.cpp
   - haiku had an inconsistency with its default target ABI, gnu vs
     eabi. In this commit we make it gnu in both places to match the
     latest changes by @hoanga.
 * src/translate_c.zig
2021-02-25 21:04:23 -07:00