Commit graph

182 commits

Author SHA1 Message Date
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
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
Andrew Kelley
37a1d08de2 haiku: minor fixups
* no isHaiku() function since there is not more than one os tag that
   this applies to.
 * clean up some control flow into a switch
 * add some TODO comments to investigate panics that suspiciously look
   like they should be compile errors (see #363)
2021-02-25 16:54:32 -07:00
Al Hoang
c17396691c initial support for haiku sync update
* add cpu count
* use haiku find_directory
* add definitions and exports for building in haiku
2021-02-25 16:41:42 -07:00
Al Hoang
6b0372229d initial support for haiku continue clean up
* remove unused definitions
* setup os specific blocks
2021-02-25 16:41:42 -07:00
Al Hoang
025635c3f8 initial support for haiku past stage0 2021-02-25 16:41:42 -07:00
Andrew Kelley
102d954220
Merge pull request #7827 from Snektron/spirv-setup
Stage 2: SPIR-V setup
2021-02-01 12:49:51 -08:00
LemonBoy
134f5fd3d6 std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
Robin Voetter
02c138fe70 SPIR-V: Add glsl450 and vulkan spir-v operating system definitions 2021-01-19 15:28:17 +01:00
Robin Voetter
ab607d455e SPIR-V: Initial architecture definitions and setup 2021-01-19 15:28:17 +01:00
Michael Dusan
f2be1fb23e
macos: reimplement OS version detection
The macOS version is now obtained by parsing `SystemVersion.plist`.

Test cases added for plist files that date back to '2005 Panther and up
to the recent '2020 Big Sur 11.1 release of macOS.

Thus we are now able to reliably identify 10.3...11.1 and higher.

- drop use of kern.osproductversion sysctl
- drop use of kern.osversion sysctl (fallback)
- drop kern.osversion tests
- add `lib.std.zig.system.detect()`
- add minimalistic parser for `SystemVersion.plist`
- add test cases for { 10.3, 10.3.9, 10.15.6, 11.0, 11.1 }

closes #7569
2021-01-11 19:54:56 -05:00
Rohlem
cb20503990 std.os.windows.GetFinalPathNameByHandle: address non-structural review comments 2021-01-11 17:48:18 -07:00
Rohlem
2922a48309 move windows runtime version detection into std.zig.system.windows 2021-01-11 17:48:16 -07:00
LemonBoy
dd973fb365 std: Use {s} instead of {} when printing strings 2021-01-02 17:12:57 -07:00
Frank Denis
6c2e0c2046 Year++ 2020-12-31 15:45:24 -08:00
LemonBoy
2622575fde std: Remove duplicated code
Make osRequiresLibC call Os.requiresLibC, let's keep a single list of OS
that require the libc to be linked in.
2020-12-30 14:45:39 -08:00
Andrew Kelley
8f1408578c update the CPU target features and models
Rather than directly pasting the output from the
target-details-generator tool, we have to look at the diff line by line
and decide how to incorporate the changes.

The baseline abstraction is something that Zig provides.

The changes to x86 appear to be incorrect. After LLVM commit
3ad09fd03c51823aeb0bcbd7898aada33e9228d6 the CPU features are stored in
a different data layout in their tables, and so we need to update the
target details extraction tool to match.
2020-12-16 17:25:48 -07:00
Jakub Konka
4b62f1bd93 Update changes due to different CPU feature sets
llvm commit b2851aea80e5a8f0cfd6c3c5a56a6b00fb28c6b6
2020-12-16 18:25:25 +01:00
Jakub Konka
1c40a4df09 Update zig_llvm.cpp and other bits
Include updates to corresponding zig sources

llvm commit b2851aea80e5a8f0cfd6c3c5a56a6b00fb28c6b6
2020-12-16 18:13:58 +01:00
LemonBoy
9c5eea9f40 stage2: Use correct ppc generic feature set 2020-11-20 08:38:10 +01:00