Andrew Kelley 4060ae93fb call ld with correct -dynamic-linker argument
It looks like Debian/Ubuntu are doing it correctly.
See https://sourceware.org/glibc/wiki/ABIList

NixOS has a clang patch which disables adding the -dynamic-linker
argument to ld in order to ensure "purity" - that is - that all paths
are in /nix/store/*.
See 6b1651928e/pkgs/development/compilers/llvm/3.7/clang/purity.patch

So, I changed the environment variable to ZIG_NATIVE_DYNAMIC_LINKER and allow
it to be set to blank. And it only matters when building for the native target,
since you might want to build for other targets without modifying your
environment.

closes #1
2015-11-26 23:43:29 -07:00
2015-11-25 11:37:43 -07:00
2015-11-24 23:44:08 -07:00
2015-08-05 15:23:15 -07:00
2015-11-26 01:29:52 -07:00
2015-08-05 16:22:18 -07:00
2015-11-26 01:29:52 -07:00

zig lang

An experiment in writing a low-level programming language with the intent to replace C. Zig intends to be a small language, yet powerful enough to write readable, safe, optimal, and concise code to solve any computing problem.

Goals

  • Ability to run arbitrary code at compile time and generate code.
  • Completely compatible with C libraries with no wrapper necessary.
  • Creating a C library should be a primary use case. Should be easy to export an auto-generated .h file.
  • Generics such as containers.
  • Do not depend on libc unless explicitly imported.
  • First class error code support.
  • Include documentation generator.
  • Eliminate the need for make, cmake, etc.
  • Friendly toward package maintainers.
  • Eliminate the need for C headers (when using zig internally).
  • Ability to declare dependencies as Git URLS with commit locking (can provide a tag or sha1).
  • Tagged union enum type.
  • Opinionated when it makes life easier.
    • Tab character in source code is a compile error.
    • Whitespace at the end of line is a compile error.
  • Resilient to parsing errors to make IDE integration work well.
  • Source code is UTF-8.
  • Shebang line OK so language can be used for "scripting" as well.
  • Ability to mark functions as test and automatically run them in test mode.
  • Memory zeroed by default, unless you initialize with "uninitialized".

Roadmap

  • C style comments.
  • Simple .so library
  • Multiple files
  • figure out integers
  • inline assembly and syscalls
  • running code at compile time
  • implement a simple game using SDL2
  • How should the Widget use case be solved? In Genesis I'm using C++ and inheritance.

Primitive Numeric Types:

zig C equivalent Description
i8 int8_t signed 8-bit integer
u8 uint8_t unsigned 8-bit integer
i16 int16_t signed 16-bit integer
u16 uint16_t unsigned 16-bit integer
i32 int32_t signed 32-bit integer
u32 uint32_t unsigned 32-bit integer
i64 int64_t signed 64-bit integer
u64 uint64_t unsigned 64-bit integer
f32 float 32-bit IEE754 floating point
f64 double 64-bit IEE754 floating point
f128 long double 128-bit IEE754 floating point
isize ssize_t signed pointer sized integer
usize size_t unsigned pointer sized integer

Grammar

Root : many(TopLevelDecl) token(EOF)

TopLevelDecl : FnDef | ExternBlock

ExternBlock : many(Directive) token(Extern) token(LBrace) many(FnDecl) token(RBrace)

FnProto : token(Fn) token(Symbol) ParamDeclList option(token(Arrow) Type)

FnDecl : FnProto token(Semicolon)

FnDef : many(Directive) FnProto Block

ParamDeclList : token(LParen) list(ParamDecl, token(Comma)) token(RParen)

ParamDecl : token(Symbol) token(Colon) Type

Type : token(Symbol) | PointerType | token(Unreachable)

PointerType : token(Star) token(Const) Type | token(Star) token(Mut) Type

Block : token(LBrace) many(Statement) token(RBrace)

Statement : ExpressionStatement | ReturnStatement

ExpressionStatement : Expression token(Semicolon)

ReturnStatement : token(Return) Expression token(Semicolon)

Expression : token(Number) | token(String) | token(Unreachable) | FnCall

FnCall : token(Symbol) token(LParen) list(Expression, token(Comma)) token(RParen)

Directive : token(NumberSign) token(Symbol) token(LParen) token(String) token(RParen)

Building

mkdir build
cd build
cmake ..
make
./run_tests
Description
General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
Readme MIT 711 MiB
Languages
Zig 98.3%
C 1.1%
C++ 0.2%
Python 0.1%