* CLI: `-target [name]` instead of `--target-*` args.
This matches clang's API.
* `builtin.Environ` renamed to `builtin.Abi`
- likewise `builtin.environ` renamed to `builtin.abi`
* stop hiding the concept of sub-arch. closes#1526
* `zig targets` only shows available targets. closes#438
* include all targets in readme, even those that don't
print with `zig targets` but note they are Tier 4
* refactor target.cpp and make the naming conventions
more consistent
* introduce the concept of a "default C ABI" for a given
OS/Arch combo. As a rule of thumb, if the system compiler
is clang or gcc then the default C ABI is the gnu ABI.
Prevents LLVM from generating debug info for
struct member functions with a pointer as the
first parameter as though the first parameter
were the implicit "this" pointer from C++.
it has a patch that adds an OS type, breaking the public API
this commit avoids depending on the last os type enum item,
but retains the safety assertion checks.
closes#1788
On Arch Linux the current default compiler is gcc 8.2.1 and this change
is needed to ignore the following errors:
In file included from /home/wink/local/include/llvm/ADT/STLExtras.h:21,
from /home/wink/local/include/llvm/ADT/StringRef.h:13,
from /home/wink/local/include/llvm/ADT/StringMap.h:17,
from /home/wink/local/include/llvm/Support/Host.h:17,
from /home/wink/local/include/llvm/ADT/Hashing.h:49,
from /home/wink/local/include/llvm/ADT/ArrayRef.h:13,
from /home/wink/local/include/llvm/ADT/APFloat.h:21,
from /home/wink/local/include/clang/AST/APValue.h:18,
from /home/wink/local/include/clang/AST/Decl.h:17,
from /home/wink/local/include/clang/AST/ASTTypeTraits.h:20,
from /home/wink/local/include/clang/AST/ASTContext.h:18,
from /home/wink/local/include/clang/Frontend/ASTUnit.h:18,
from /home/wink/prgs/ziglang/zig/src/translate_c.cpp:18:
/home/wink/local/include/llvm/ADT/SmallVector.h: In instantiation of ‘void llvm::SmallVectorTemplateBase<T, true>::push_back(const T&) [with T = std::pair<void*, long unsigned int>]’:
/home/wink/local/include/llvm/Support/Allocator.h:249:33: required from ‘void* llvm::BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>::Allocate(size_t, size_t) [with AllocatorT = llvm::MallocAllocator; long unsigned int SlabSize = 4096; long unsigned int SizeThreshold = 4096; size_t = long unsigned int]’
/home/wink/local/include/clang/AST/ASTContext.h:659:42: required from here
/home/wink/local/include/llvm/ADT/SmallVector.h:313:11: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct std::pair<void*, long unsigned int>’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
memcpy(this->end(), &Elt, sizeof(T));
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/8.2.1/utility:70,
from /home/wink/local/include/llvm/Support/type_traits.h:19,
from /home/wink/local/include/llvm/Support/Casting.h:19,
from /home/wink/local/include/clang/Basic/LLVM.h:22,
from /home/wink/local/include/clang/AST/APValue.h:17,
from /home/wink/local/include/clang/AST/Decl.h:17,
from /home/wink/local/include/clang/AST/ASTTypeTraits.h:20,
from /home/wink/local/include/clang/AST/ASTContext.h:18,
from /home/wink/local/include/clang/Frontend/ASTUnit.h:18,
from /home/wink/prgs/ziglang/zig/src/translate_c.cpp:18:
/usr/include/c++/8.2.1/bits/stl_pair.h:198:12: note: ‘struct std::pair<void*, long unsigned int>’ declared here
struct pair
^~~~
Add wasm32 support to the build-obj, build-exe and build-lib commands
of the stage 1 compiler. Wasm64 should work transparently once it's
supported in upstream LLVM.
To export a function:
// lib.zig - for exposition, not necessary for this example
pub use @import("add.zig");
// add.zig
export fn add(a: i32, b: i32) i32 {
return a + b;
}
To import a function:
// cube.zig
extern fn square(x: i32) i32;
export fn cube(x: i32) i32 {
return x * square(x);
}
* remove @cmpxchg, add @cmpxchgWeak and @cmpxchgStrong
- See explanations in the langref.
* add operand type as first parameter
* return type is ?T where T is the operand type
closes#461
* add @noInlineCall - see #640
This fixes a crash in --release-safe and --release-fast modes
where the optimizer inlines everything into _start and
clobbers the command line argument data.
If we were able to verify that the user's code never reads
command line args, we could leave off this "no inline"
attribute.
* add i29 and u29 primitive types. u29 is the type of alignment,
so it makes sense to be a primitive.
probably in the future we'll make any `i` or `u` followed by
digits into a primitive.
* add `aligned` functions to Allocator interface
* add `os.argsAlloc` and `os.argsFree` so that you can get
a `[]const []u8`, do whatever arg parsing you want, and then free
it. For now this uses the other API under the hood, but it could
be reimplemented to do a single allocation.
* add tests to make sure command line argument parsing works.