diff --git a/.travis.yml b/.travis.yml index 271b6069b5..c5299e914e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,11 @@ +sudo: required +services: + - docker os: - linux - osx dist: trusty osx_image: xcode8.3 -sudo: required language: cpp before_install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ci/travis_linux_before_install; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index 979d771cda..cea302cb06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,11 +30,7 @@ if(GIT_EXE) endif() message("Configuring zig version ${ZIG_VERSION}") -set(ZIG_LIBC_LIB_DIR "" CACHE STRING "Default native target libc directory where crt1.o can be found") -set(ZIG_LIBC_STATIC_LIB_DIR "" CACHE STRING "Default native target libc directory where crtbeginT.o can be found") -set(ZIG_LIBC_INCLUDE_DIR "/usr/include" CACHE STRING "Default native target libc include directory") -set(ZIG_DYNAMIC_LINKER "" CACHE STRING "Override dynamic linker for native target") -set(ZIG_EACH_LIB_RPATH off CACHE BOOL "Add each dynamic library to rpath for native target") +set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_LIB_DIR_ESCAPED "${ZIG_LIBC_LIB_DIR}") string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_LIBC_STATIC_LIB_DIR_ESCAPED "${ZIG_LIBC_STATIC_LIB_DIR}") @@ -429,6 +425,7 @@ set(ZIG_STD_FILES "crypto/sha2.zig" "crypto/sha3.zig" "crypto/blake2.zig" + "crypto/hmac.zig" "cstr.zig" "debug/failing_allocator.zig" "debug/index.zig" @@ -509,7 +506,7 @@ set(ZIG_STD_FILES "os/windows/index.zig" "os/windows/util.zig" "os/zen.zig" - "rand.zig" + "rand/index.zig" "sort.zig" "special/bootstrap.zig" "special/bootstrap_lib.zig" @@ -698,6 +695,8 @@ if(MINGW) set(EXE_LDFLAGS "-static -static-libgcc -static-libstdc++") elseif(MSVC) set(EXE_LDFLAGS "/STACK:16777216") +elseif(ZIG_STATIC) + set(EXE_LDFLAGS "-static") else() set(EXE_LDFLAGS " ") endif() diff --git a/README.md b/README.md index 0893017bb7..90f0d48f2c 100644 --- a/README.md +++ b/README.md @@ -138,14 +138,10 @@ libc. Create demo games using Zig. ##### POSIX -If you have gcc or clang installed, you can find out what `ZIG_LIBC_LIB_DIR`, -`ZIG_LIBC_STATIC_LIB_DIR`, and `ZIG_LIBC_INCLUDE_DIR` should be set to -(example below). - ``` mkdir build cd build -cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd) -DZIG_LIBC_LIB_DIR=$(dirname $(cc -print-file-name=crt1.o)) -DZIG_LIBC_INCLUDE_DIR=$(echo -n | cc -E -x c - -v 2>&1 | grep -B1 "End of search list." | head -n1 | cut -c 2- | sed "s/ .*//") -DZIG_LIBC_STATIC_LIB_DIR=$(dirname $(cc -print-file-name=crtbegin.o)) +cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd) make make install ./zig build --build-file ../build.zig test @@ -153,8 +149,6 @@ make install ##### MacOS -`ZIG_LIBC_LIB_DIR` and `ZIG_LIBC_STATIC_LIB_DIR` are unused. - ``` brew install cmake llvm@7 brew outdated llvm@7 || brew upgrade llvm@7 diff --git a/build.zig b/build.zig index 88775498ca..b72641a2ef 100644 --- a/build.zig +++ b/build.zig @@ -45,6 +45,11 @@ pub fn build(b: &Builder) !void { var exe = b.addExecutable("zig", "src-self-hosted/main.zig"); exe.setBuildMode(mode); + + // This is for finding /lib/libz.a on alpine linux. + // TODO turn this into -Dextra-lib-path=/lib option + exe.addLibPath("/lib"); + exe.addIncludeDir("src"); exe.addIncludeDir(cmake_binary_dir); addCppLib(b, exe, cmake_binary_dir, "zig_cpp"); diff --git a/ci/appveyor/build_script.bat b/ci/appveyor/build_script.bat index 2d4b325a6b..179bd88d7e 100644 --- a/ci/appveyor/build_script.bat +++ b/ci/appveyor/build_script.bat @@ -20,9 +20,7 @@ call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_ mkdir %ZIGBUILDDIR% cd %ZIGBUILDDIR% -cmake.exe .. -Thost=x64 -G"Visual Studio 14 2015 Win64" "-DCMAKE_INSTALL_PREFIX=%ZIGBUILDDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release "-DZIG_LIBC_INCLUDE_DIR=C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt" "-DZIG_LIBC_LIB_DIR=C:\Program Files (x86)\Windows Kits\10\bin\x64\ucrt" "-DZIG_LIBC_STATIC_LIB_DIR=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64" || exit /b +cmake.exe .. -Thost=x64 -G"Visual Studio 14 2015 Win64" "-DCMAKE_INSTALL_PREFIX=%ZIGBUILDDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release || exit /b msbuild /p:Configuration=Release INSTALL.vcxproj || exit /b bin\zig.exe build --build-file ..\build.zig test || exit /b - -@echo "MSVC build succeeded" diff --git a/ci/travis_linux_install b/ci/travis_linux_install index 98f8d5aabc..46da6d18d2 100755 --- a/ci/travis_linux_install +++ b/ci/travis_linux_install @@ -4,4 +4,4 @@ set -x sudo apt-get remove -y llvm-* sudo rm -rf /usr/local/* -sudo apt-get install -y clang-7.0 libclang-7.0 libclang-7.0-dev llvm-7.0 llvm-7.0-dev liblld-7.0 liblld-7.0-dev cmake wine1.6-amd64 +sudo apt-get install -y clang-7.0 libclang-7.0 libclang-7.0-dev llvm-7.0 llvm-7.0-dev liblld-7.0 liblld-7.0-dev cmake s3cmd diff --git a/ci/travis_linux_script b/ci/travis_linux_script index 698cd996f0..93b27f74c1 100755 --- a/ci/travis_linux_script +++ b/ci/travis_linux_script @@ -8,25 +8,16 @@ export CXX=clang++-7.0 echo $PATH mkdir build cd build -cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd) -DZIG_LIBC_LIB_DIR=$(dirname $($CC -print-file-name=crt1.o)) -DZIG_LIBC_INCLUDE_DIR=$(echo -n | $CC -E -x c - -v 2>&1 | grep -B1 "End of search list." | head -n1 | cut -c 2- | sed "s/ .*//") -DZIG_LIBC_STATIC_LIB_DIR=$(dirname $($CC -print-file-name=crtbegin.o)) -make VERBOSE=1 -make install +cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd) +make -j2 install ./zig build --build-file ../build.zig test -./zig test ../test/behavior.zig --target-os windows --target-arch i386 --target-environ msvc -wine zig-cache/test.exe - -./zig test ../test/behavior.zig --target-os windows --target-arch i386 --target-environ msvc --release-fast -wine zig-cache/test.exe - -./zig test ../test/behavior.zig --target-os windows --target-arch i386 --target-environ msvc --release-safe -wine zig-cache/test.exe - -./zig test ../test/behavior.zig --target-os windows --target-arch x86_64 --target-environ msvc -wine64 zig-cache/test.exe - -#./zig test ../test/behavior.zig --target-os windows --target-arch x86_64 --target-environ msvc --release-fast -#wine64 test.exe -# -#./zig test ../test/behavior.zig --target-os windows --target-arch x86_64 --target-environ msvc --release-safe -#wine64 test.exe +if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then + mkdir $TRAVIS_BUILD_DIR/artifacts + docker run -it --mount type=bind,source="$TRAVIS_BUILD_DIR/artifacts",target=/z ziglang/static-base:llvm6-1 -j2 $TRAVIS_COMMIT + echo "access_key = $AWS_ACCESS_KEY_ID" >> ~/.s3cfg + echo "secret_key = $AWS_SECRET_ACCESS_KEY" >> ~/.s3cfg + s3cmd put -P $TRAVIS_BUILD_DIR/artifacts/* s3://ziglang.org/builds/ + touch empty + s3cmd put -P empty s3://ziglang.org/builds/zig-linux-x86_64-$TRAVIS_BRANCH.tar.xz --add-header=x-amz-website-redirect-location:/builds/$(ls $TRAVIS_BUILD_DIR/artifacts) +fi diff --git a/cmake/Findllvm.cmake b/cmake/Findllvm.cmake index 1e09ad673a..788e57a644 100644 --- a/cmake/Findllvm.cmake +++ b/cmake/Findllvm.cmake @@ -15,7 +15,7 @@ find_program(LLVM_CONFIG_EXE "c:/msys64/mingw64/bin" "C:/Libraries/llvm-7.0.0/bin") -if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug")) +if(NOT(CMAKE_BUILD_TYPE STREQUAL "Debug") OR ZIG_STATIC) execute_process( COMMAND ${LLVM_CONFIG_EXE} --libfiles --link-static OUTPUT_VARIABLE LLVM_LIBRARIES_SPACES diff --git a/doc/docgen.zig b/doc/docgen.zig index 5332a62ac7..56d9a04412 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -55,7 +55,7 @@ pub fn main() !void { // TODO issue #709 // disabled to pass CI tests, but obviously we want to implement this // and then remove this workaround - if (builtin.os == builtin.Os.linux) { + if (builtin.os != builtin.Os.windows) { os.deleteTree(allocator, tmp_dir_name) catch {}; } } diff --git a/doc/langref.html.in b/doc/langref.html.in index d227936f82..7f837186b5 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -2864,18 +2864,18 @@ const err = (error {FileNotFound}).FileNotFound; assert to make sure the error value is in fact in the destination error set.
- The global error set should generally be avoided when possible, because it prevents - the compiler from knowing what errors are possible at compile-time. Knowing - the error set at compile-time is better for generated documentationt and for - helpful error messages such as forgetting a possible error value in a {#link|switch#}. + The global error set should generally be avoided because it prevents the + compiler from knowing what errors are possible at compile-time. Knowing + the error set at compile-time is better for generated documentation and + helpful error messages, such as forgetting a possible error value in a {#link|switch#}.
{#header_close#} {#header_close#} {#header_open|Error Union Type#}
- Most of the time you will not find yourself using an error set type. Instead,
- likely you will be using the error union type. This is when you take an error set
- and a normal type, and create an error union with the ! binary operator.
+ An error set type and normal type can be combined with the !
+ binary operator to form an error union type. You are likely to use an
+ error union type more often than an error set type by itself.
Here is a function to parse a string into a 64-bit integer: @@ -5739,7 +5739,7 @@ UseDecl = "use" Expression ";" ExternDecl = "extern" option(String) (FnProto | VariableDeclaration) ";" -FnProto = option("nakedcc" | "stdcallcc" | "extern" | ("async" option("(" Expression ")"))) "fn" option(Symbol) ParamDeclList option("align" "(" Expression ")") option("section" "(" Expression ")") option("!") (TypeExpr | "var") +FnProto = option("nakedcc" | "stdcallcc" | "extern" | ("async" option("<" Expression ">"))) "fn" option(Symbol) ParamDeclList option("align" "(" Expression ")") option("section" "(" Expression ")") option("!") (TypeExpr | "var") FnDef = option("inline" | "export") FnProto Block @@ -5863,7 +5863,9 @@ StructLiteralField = "." Symbol "=" Expression PrefixOp = "!" | "-" | "~" | "*" | ("&" option("align" "(" Expression option(":" Integer ":" Integer) ")" ) option("const") option("volatile")) | "?" | "??" | "-%" | "try" | "await" -PrimaryExpression = Integer | Float | String | CharLiteral | KeywordLiteral | GroupedExpression | BlockExpression(BlockOrExpression) | Symbol | ("@" Symbol FnCallExpression) | ArrayType | FnProto | AsmExpression | ContainerDecl | ("continue" option(":" Symbol)) | ErrorSetDecl +PrimaryExpression = Integer | Float | String | CharLiteral | KeywordLiteral | GroupedExpression | BlockExpression(BlockOrExpression) | Symbol | ("@" Symbol FnCallExpression) | ArrayType | FnProto | AsmExpression | ContainerDecl | ("continue" option(":" Symbol)) | ErrorSetDecl | PromiseType + +PromiseType = "promise" option("->" TypeExpr) ArrayType : "[" option(Expression) "]" option("align" "(" Expression option(":" Integer ":" Integer) ")")) option("const") option("volatile") TypeExpr @@ -6031,4 +6033,3 @@ hljs.registerLanguage("zig", function(t) {