Coder Social home page Coder Social logo

webassembly / wasi-sdk Goto Github PK

View Code? Open in Web Editor NEW
1.2K 52.0 169.0 302 KB

WASI-enabled WebAssembly C/C++ toolchain

License: Apache License 2.0

Dockerfile 1.57% Shell 15.72% CMake 49.93% C 24.28% C++ 1.23% Python 7.26%
wasi-sdk llvm wasi-libc sysroot

wasi-sdk's Introduction

WASI SDK

Quick Start

Download SDK packages here.

About this repository

This repository contains no compiler or library code itself; it uses git submodules to pull in the upstream Clang and LLVM tree, as well as the wasi-libc tree.

The libc portion of this SDK is maintained in wasi-libc.

Upstream Clang and LLVM (from 9.0 onwards) can compile for WASI out of the box, and WebAssembly support is included in them by default. So, all that's done here is to provide builds configured to set the default target and sysroot for convenience.

One could also use a standard Clang installation, build a sysroot from the sources mentioned above, and compile with --target=wasm32-wasi --sysroot=/path/to/sysroot. In this scenario, one would also need the libclang_rt.builtins-wasm32.a objects available separately in the release downloads which must be extracted into $CLANG_INSTALL_DIR/$CLANG_VERSION/lib/wasi/.

Clone

This repository uses git submodule, to clone it you need use the command below :

git clone --recursive https://github.com/WebAssembly/wasi-sdk.git

Requirements

The Wasm-sdk's build process needs some packages :

  • cmake
  • clang
  • ninja
  • python3

Please refer to your OS documentation to install those packages.

Build

Building wasi-sdk uses CMake and is split into two halves. First you can build the toolchain itself:

cmake -G Ninja -B build/toolchain -S . -DWASI_SDK_BUILD_TOOLCHAIN=ON -DCMAKE_INSTALL_PREFIX=build/install
cmake --build build/toolchain --target install

When you're developing locally you may also wish to pass -DCMAKE_CXX_COMPILER_LAUNCHER=ccache to assist with rebuilds. Other supported CMake flags are:

  • -DLLVM_CMAKE_FLAGS - extra flags to pass to cmake when building LLVM/Clang.
  • -DRUST_TARGET - the specific Rust target triple to build wasm-component-ld for, useful for cross-compiles.

The clang compiler should now be located at build/install/bin/clang but it's just a compiler, the sysroot isn't built yet. Next the second step of the build is to build the sysroot:

cmake -G Ninja -B build/sysroot -S . \
    -DCMAKE_INSTALL_PREFIX=build/install \
    -DCMAKE_TOOLCHAIN_FILE=build/install/share/cmake/wasi-sdk.cmake \
    -DCMAKE_C_COMPILER_WORKS=ON \
    -DCMAKE_CXX_COMPILER_WORKS=ON
cmake --build build/sysroot --target install

A full toolchain should now be present at build/install and is ready for use in compiling WebAssembly code. Supported CMake flags are:

  • -DWASI_SDK_DEBUG_PREFIX_MAKE=OFF - disable -fdebug-prefix-map when building C/C++ code to use full host paths instead.
  • -DWASI_SDK_INCLUDE_TESTS=ON - used for building tests.
  • -DWASI_SDK_TARGETS=.. - a list of targets to build, by default all WASI targets are compiled.

If you'd like to build distribution artifacts you can use the dist target like so:

cmake --build build/toolchain --target dist
cmake --build build/sysroot --target dist

Tarballs will be created under build/toolchain/dist and build/sysroot/dist. Note that these are separate tarballs for the toolchain and sysroot. To create a single tarball for the entire SDK you'll first want to copy all tarballs into a new folder and then run the ./ci/merge-artifacts.sh script:

mkdir dist-my-platform
cp build/toolchain/dist/* build/sysroot/dist/* dist-my-platform
./ci/merge-artifacts.sh

This will produce dist/wasi-sdk-*.tar.gz which is the same as the release artifacts for this repository.

Finally you can additionally bundle many of the above steps, minus merge-artifact.sh by using the CI script to perform both the toolchain and sysroot build:

./ci/build.sh

The built package can be found into build/dist directory. For releasing a new version of the package on GitHub, see RELEASING.md.

Install

A typical installation from the release binaries might look like the following:

export WASI_VERSION=20
export WASI_VERSION_FULL=${WASI_VERSION}.0
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
tar xvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz

Use

Use the clang installed in the wasi-sdk directory:

export WASI_SDK_PATH=`pwd`/wasi-sdk-${WASI_VERSION_FULL}
CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
$CC foo.c -o foo.wasm

Note: ${WASI_SDK_PATH}/share/wasi-sysroot contains the WASI-specific includes/libraries/etc. The --sysroot=... option is not necessary if WASI_SDK_PATH is /opt/wasi-sdk. For troubleshooting, one can replace the --sysroot path with a manual build of wasi-libc.

Integrating with a CMake build system

Use a toolchain file to setup the wasi-sdk platform.

$ cmake -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk.cmake ...

or the wasi-sdk-thread platform

$ cmake -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PATH}/share/cmake/wasi-sdk-pthread.cmake ...

Notes for Autoconf

Autoconf 2.70 now recognizes WASI.

For convenience when building packages that aren't yet updated, updated config.sub and config.guess files are installed at share/misc/config.* in the install directory.

Docker Image

We provide a docker image including WASI SDK that can be used for building projects without a separate installation of the SDK. Autotools, CMake, and Ninja are included in this image, and standard environment variables are set to use WASI SDK for building.

For example, this command can build a make-based project with the Docker image.

docker run -v `pwd`:/src -w /src ghcr.io/webassembly/wasi-sdk make

Take note of the notable limitations below when building projects, for example many projects will need threads support disabled in a configure step before building with WASI SDK.

Notable Limitations

This repository does not yet support C++ exceptions. C++ code is supported only with -fno-exceptions for now. Similarly, there is not yet support for setjmp/longjmp. Work on support for exception handling is underway at the language level which will support both of these features.

This repository experimentally supports threads with --target=wasm32-wasi-threads. It uses WebAssembly's threads primitives (atomics, wait/notify, shared memory) and wasi-threads for spawning threads. Note: this is experimental โ€” do not expect long-term stability!

This repository does not yet support dynamic libraries. While there are some efforts to design a system for dynamic libraries in wasm, it is still in development and not yet generally usable.

There is no support for networking. It is a goal of WASI to support networking in the future though.

wasi-sdk's People

Contributors

abrown avatar acfoltzer avatar alexcrichton avatar anuraaga avatar brettcannon avatar chicoxyzzy avatar dicej avatar ericson2314 avatar gautric avatar glandium avatar imrying avatar jlb6740 avatar johalun avatar kiancross avatar lopopolo avatar lum1n0us avatar lygstate avatar michaellilltokiwa avatar nilslice avatar orestisfl avatar pchickey avatar sbc100 avatar sunfishcode avatar terrorjack avatar tschneidereit avatar vnepogodin avatar vvuk avatar whitequark avatar yamt avatar yurydelendik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wasi-sdk's Issues

Question: The correct way to compile without main function

Hi guys, I would like to create a WASM file from the following C file:

int total_count = 0;

// Modules can have state
int count() {
  return ++total_count;
}

// They can do work
int add(int a, int b) {
  return a + b;
}

// But they only work with numbers
char * string() {
  return "Hello, world!";
}

Besides other things, I tried to run $WASI_SDK_DIR/bin/clang --target=wasm32-unknown-wasi -Wl,--no-entry -nostartfiles --sysroot $WASI_SDK_DIR/share/wasi-sysroot -o module.wasm module.c. This command creates a module.wasm file without compiler error but the file is almost empty unfortunately.

My goal is to create an equal file with wasi-sdk to what the following command does: clang --target=wasm32 --no-standard-libraries -Wl,--export-all -Wl,--no-entry -o module.wasm module.c

I don't need a main function because I want to import these functions as ES Modules later with the help from deno.

What am I doing wrong?
Thank you!

Can't build a C++ "Hello world" program

I can't compile a simple C++ hello world program with sdk 3.0 on Linux.

I tried compiling this:

#include <iostream>

int main() {
	std::cout << "Hello world!" << std::endl;
}

But it fails to link due to missing pthreads functions used by libc++:

https://gist.github.com/zhuowei/fc4c13962057a674692f3e6048d547ac

A C hello world program does build and run (using the in-browser polyfill), so my SDK install seems fine.

Is there a compiler/linker parameter I need to add so these functions would link?

Edit: I'm assuming #12 would help? Do I need to build the wasi-sdk from source to get that patch, or should I wait for the next wasi-sdk release?

Publish sysroot as a separate downloadable

We currently publish 3 version of the SDK for mac, linux and windows. Each one contains platform specific compiler and (hopefully) identical sysroot.

This leads me to think, should we verify the sysroot are identical? Is there any point in building the sysroot on all three platforms?

But also, many developers already have a recent version of clang on their system. Could we, in addition, publish a sysroot-only archive, so such used can just download the sysroot and use clang from their $PATH?

The current setup would make way more sense if we maintained patches to upstream llvm, but we explicitly don't so we are shipping and compiler many people already have N copies of.

Undefined symbol compile error with library

I tried to compile this function:

#include <string.h>

int mylen(char *a) {
    return strlen(a);
}

I'm using the wasi-sdk setup described here:

https://00f.net/2019/04/07/compiling-to-webassembly-with-llvm-and-clang/

I get the compile error "undefined symbol: strlen".

However, I can compile and run this function:

#include <string.h>

int mylen(char *a) {
    return strlen("test");
}

I'm very new to this and so am probably doing something silly. Any ideas what it could be?

<algorithm> is not supported

If we have an example.cpp like:

#import <algorithm>

int main() {
	printf("hello world");
	return 0;
}

Using regular compilation works:

clang -Os -s -o a.out example.cpp

Where as targeting wasm and pointing to the right sysroot doesn't:

clang --target=wasm32-unknown-wasi --sysroot /tmp/wasi-libc -Os -s -o a.wasm example.cpp

Output:

hey.cpp:1:9: fatal error: 'algorithm' file not found
#import <algorithm>
        ^~~~~~~~~~~
1 error generated.

Is there something I'm missing? I'm relatively new to cross-compilation so it might be an oversight on my part. Thank you!

Strip "opt/wasi-sdk" from filenames in releases

When we untar a release we end up with e.g.

wasi-sdk-6.0/opt/wasi-sdk/bin/clang

When wasi-sdk-6.0/bin/clang would seem more sensible and concise.

I understand the opt/wasi-sdk prefix is useful to using during configuration since it means the SDK will work better when installed at this location. But when unpacked from tarball I don't think its useful since we can't know that final path.

Looks like a simple change to tar_from_installation.sh

Are there plans for implementing IPC system calls?

I think IPC can be considered as one of the most important parts of modern binaries. A lot of them won't be able to communicate (except for maybe using sockets?) and such things as Wayland won't be easy to get up and running without IPC support.

LLVM trunk renamed install-clang-headers to install-clang-resource-headers

LLVM r355340 (on March 4th) renamed install-clang-headers to install-clang-resource-headers, so we'll need to update the Makefile accordingly when using trunk and newer versions.

The LLVM revision:

r355340 | smeenai | 2019-03-04 13:19:53 -0800 (Mon, 04 Mar 2019) | 23 lines

[build] Rename clang-headers to clang-resource-headers
Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].

I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html

Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille

Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, lldb-commits, cfe-commits, llvm-commits

Tags: #clang, #sanitizers, #lldb, #openmp, #llvm

Differential Revision: https://reviews.llvm.org/D58791

Add release binary for MacOS 10.13

When running [WASI_SDK]/bin/clang I get:

dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin
  Referenced from: /Users/foo/Web/wasi-sdk-10.0/bin/clang (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ____chkstk_darwin
  Referenced from: /Users/foo/Web/wasi-sdk-10.0/bin/clang (which was built for Mac OS X 10.15)
  Expected in: /usr/lib/libSystem.B.dylib

Abort trap: 6

Which appears to be because the binaries are built on MacOS 10.15. I found a similar issue here: nodegui/nodegui#391

C++ building eror: missing the LIBC++ ABI symbols

Hi, we met some errors while buiding a C++ library source code. It looks the libc++ abi library is not compiled by the SDK. Can anyone kindly give some information here?

shaka@shaka-VirtualBox:~/work/test/c/eigen_test$ /opt/wasi-sdk/bin/clang++ -DEIGEN_HAS_CXX11_ATOMIC=0 -I ~/work/eigen -o test.wasm main.cpp
wasm-ld: error: /tmp/main-b1f1cc.o: undefined symbol: __cxa_begin_catch
wasm-ld: error: /tmp/main-b1f1cc.o: undefined symbol: __cxa_allocate_exception
wasm-ld: error: /tmp/main-b1f1cc.o: undefined symbol: __cxa_throw
clang-8: error: lld command failed with exit code 1 (use -v to see invocation)

Instructions for compiling `libclang_rt.builtins-wasm32.a`?

I'm trying to use clang-9 to compile and use wasi-sysroot, but additionally the libclang_rt.builtins-wasm32.a file is required to link into the final wasm module. It is not obvious how to build this file without building the llvm/clang submodules first, so it would be much appreciated if you can add relevant instructions. Thanks a lot!

Is it possible to log function name in the Custom section?

I try to use clang to compile helloworld.c as follows.

#include <stdio.h>
int main() {
    printf("helloworld");
}

In official spec, it says wasm format is allowed to log out function name in Custom Section and emcc offers this feature with add -g flag. I wonder can I do it with clang? Which flag should I add?

undeclared identifier 'max_align_t' when compiling libgit2

I'm not sure if the issue is with wasi-sdk or libgit2. I'm not super experienced in C programming but the error message is from wasi-sysroot/include/__struct_sockaddress_in.h, so I'm posting it here. Any hints?

(There is a port to emscripten at https://github.com/petersalomonsen/wasm-git/, but I'd like to compile it without emscripten.)

I use the following bash script to download and compile libgit2:

#!/usr/bin/bash
set -e
cd "$(dirname "$0")" || exit 1
rm -rf libgit2 build
git clone https://github.com/libgit2/libgit2 --depth 1

cd libgit2
# with NODEFS we can't open a file for writing if mode is set to 0444
sed -i 's/GIT_PACK_FILE_MODE 0444/GIT_PACK_FILE_MODE 0644/g' src/pack.h
sed -i 's/GIT_OBJECT_FILE_MODE 0444/GIT_OBJECT_FILE_MODE 0644/g' src/odb.h
cd ..

mkdir build
cd build

export CC=../../wasi-sdk-8.0/bin/clang
export CXX=../../wasi-sdk-8.0/bin/clang++
cmake \
    -DCMAKE_C_COMPILER_TARGET=wasm32-unkown-wasi -DCMAKE_C_FLAGS="-v --sysroot=$(pwd)/../../wasi-sdk-8.0/share/wasi-sysroot -Wno-incompatible-pointer-types" \
    -DCMAKE_VERBOSE_MAKEFILE=true \
    -DREGEX_BACKEND=regcomp -DSONAME=OFF -DUSE_HTTPS=OFF -DBUILD_SHARED_LIBS=OFF -DTHREADSAFE=OFF -DUSE_SSH=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=ON \
    -DUSE_BUNDLED_ZLIB=ON \
    ../libgit2
cmake -build ../libgit2
make
wasm2wat examples/lg2.wasm -o examples/lg2.wat

the output:

Cloning into 'libgit2'...
remote: Enumerating objects: 5989, done.
remote: Counting objects: 100% (5989/5989), done.
remote: Compressing objects: 100% (4599/4599), done.
remote: Total 5989 (delta 225), reused 4935 (delta 182), pack-reused 0
Receiving objects: 100% (5989/5989), 4.21 MiB | 1.34 MiB/s, done.
Resolving deltas: 100% (225/225), done.
-- The C compiler identification is Clang 9.0.0
-- Check for working C compiler: /home/MYUSER/SOMEPATH/wasi-sdk-8.0/bin/clang
-- Check for working C compiler: /home/MYUSER/SOMEPATH/wasi-sdk-8.0/bin/clang - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.6.3") 
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Could NOT find Threads (missing: Threads_FOUND) 
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM - Success
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC - Failed
-- Performing Test HAVE_STRUCT_STAT_MTIME_NSEC
-- Performing Test HAVE_STRUCT_STAT_MTIME_NSEC - Failed
-- Performing Test HAVE_STRUCT_STAT_NSEC
-- Performing Test HAVE_STRUCT_STAT_NSEC - Success
-- Performing Test IS_WALL_SUPPORTED
-- Performing Test IS_WALL_SUPPORTED - Success
-- Performing Test IS_WEXTRA_SUPPORTED
-- Performing Test IS_WEXTRA_SUPPORTED - Success
-- Performing Test IS_WDOCUMENTATION_SUPPORTED
-- Performing Test IS_WDOCUMENTATION_SUPPORTED - Success
-- Performing Test IS_WNO_MISSING_FIELD_INITIALIZERS_SUPPORTED
-- Performing Test IS_WNO_MISSING_FIELD_INITIALIZERS_SUPPORTED - Success
-- Performing Test IS_WSTRICT_ALIASING_SUPPORTED
-- Performing Test IS_WSTRICT_ALIASING_SUPPORTED - Success
-- Performing Test IS_WSTRICT_PROTOTYPES_SUPPORTED
-- Performing Test IS_WSTRICT_PROTOTYPES_SUPPORTED - Success
-- Performing Test IS_WDECLARATION_AFTER_STATEMENT_SUPPORTED
-- Performing Test IS_WDECLARATION_AFTER_STATEMENT_SUPPORTED - Success
-- Performing Test IS_WSHIFT_COUNT_OVERFLOW_SUPPORTED
-- Performing Test IS_WSHIFT_COUNT_OVERFLOW_SUPPORTED - Success
-- Performing Test IS_WUNUSED_CONST_VARIABLE_SUPPORTED
-- Performing Test IS_WUNUSED_CONST_VARIABLE_SUPPORTED - Success
-- Performing Test IS_WUNUSED_FUNCTION_SUPPORTED
-- Performing Test IS_WUNUSED_FUNCTION_SUPPORTED - Success
-- Performing Test IS_WINT_CONVERSION_SUPPORTED
-- Performing Test IS_WINT_CONVERSION_SUPPORTED - Success
-- Performing Test IS_WFORMAT_SUPPORTED
-- Performing Test IS_WFORMAT_SUPPORTED - Success
-- Performing Test IS_WFORMAT_SECURITY_SUPPORTED
-- Performing Test IS_WFORMAT_SECURITY_SUPPORTED - Success
-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED
-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED - Success
-- Looking for futimens
-- Looking for futimens - found
-- Checking prototype qsort_r for HAVE_QSORT_R_BSD - False
-- Checking prototype qsort_r for HAVE_QSORT_R_GNU - False
-- Looking for qsort_s
-- Looking for qsort_s - not found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Found OpenSSL: /usr/lib32/libcrypto.so (found version "1.1.1e")  
-- Found mbedTLS:
--   version 2.16.5
--   TLS: /usr/lib/libmbedtls.so
--   X509: /usr/lib/libmbedx509.so
--   Crypto: /usr/lib/libmbedcrypto.so
-- Found PCRE: /usr/lib32/libpcre.so  
-- http-parser version 2 was not found or disabled; using bundled 3rd-party sources.
-- Performing Test IS_WIMPLICIT_FALLTHROUGH_1_SUPPORTED
-- Performing Test IS_WIMPLICIT_FALLTHROUGH_1_SUPPORTED - Failed
-- Performing Test IS_WNO_IMPLICIT_FALLTHROUGH_SUPPORTED
-- Performing Test IS_WNO_IMPLICIT_FALLTHROUGH_SUPPORTED - Success
-- LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.
-- Found GSSAPI: /usr/lib32/libgssapi_krb5.so;/usr/lib32/libkrb5.so;/usr/lib32/libk5crypto.so;/usr/lib32/libcom_err.so  
-- Enabled features:
 * nanoseconds, whether to use sub-second file mtimes and ctimes
 * tracing, tracing support
 * SHA, using CollisionDetection
 * regex, using system regcomp
 * http-parser, http-parser support (bundled)
 * zlib, using bundled zlib

-- Disabled features:
 * debugpool, debug pool allocator
 * threadsafe, threadsafe support
 * HTTPS
 * SSH, SSH transport support
 * ntlmclient, NTLM authentication support for Unix
 * SPNEGO, SPNEGO authentication support
 * iconv, iconv encoding conversion support

-- Configuring done
-- Generating done
-- Build files have been written to: /home/MYUSER/SOMEPATH/libgit2/build
-- Could NOT find Threads (missing: Threads_FOUND) 
-- Checking prototype qsort_r for HAVE_QSORT_R_BSD - False
-- Checking prototype qsort_r for HAVE_QSORT_R_GNU - False
-- Found mbedTLS:
--   version 2.16.5
--   TLS: /usr/lib/libmbedtls.so
--   X509: /usr/lib/libmbedx509.so
--   Crypto: /usr/lib/libmbedcrypto.so
-- http-parser version 2 was not found or disabled; using bundled 3rd-party sources.
-- LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.
-- Enabled features:
 * nanoseconds, whether to use sub-second file mtimes and ctimes
 * tracing, tracing support
 * SHA, using CollisionDetection
 * regex, using system regcomp
 * http-parser, http-parser support (bundled)
 * zlib, using bundled zlib

-- Disabled features:
 * debugpool, debug pool allocator
 * threadsafe, threadsafe support
 * HTTPS
 * SSH, SSH transport support
 * ntlmclient, NTLM authentication support for Unix
 * SPNEGO, SPNEGO authentication support
 * iconv, iconv encoding conversion support

-- Configuring done
-- Generating done
-- Build files have been written to: /home/MYUSER/SOMEPATH/libgit2/build
/usr/bin/cmake -S/home/MYUSER/SOMEPATH/libgit2/libgit2 -B/home/MYUSER/SOMEPATH/libgit2/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/MYUSER/SOMEPATH/libgit2/build/CMakeFiles /home/MYUSER/SOMEPATH/libgit2/build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/MYUSER/SOMEPATH/libgit2/build'
make -f src/CMakeFiles/git2internal.dir/build.make src/CMakeFiles/git2internal.dir/depend
make[2]: Entering directory '/home/MYUSER/SOMEPATH/libgit2/build'
cd /home/MYUSER/SOMEPATH/libgit2/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/MYUSER/SOMEPATH/libgit2/libgit2 /home/MYUSER/SOMEPATH/libgit2/libgit2/src /home/MYUSER/SOMEPATH/libgit2/build /home/MYUSER/SOMEPATH/libgit2/build/src /home/MYUSER/SOMEPATH/libgit2/build/src/CMakeFiles/git2internal.dir/DependInfo.cmake --color=
Scanning dependencies of target git2internal
make[2]: Leaving directory '/home/MYUSER/SOMEPATH/libgit2/build'
make -f src/CMakeFiles/git2internal.dir/build.make src/CMakeFiles/git2internal.dir/build
make[2]: Entering directory '/home/MYUSER/SOMEPATH/libgit2/build'
[  1%] Building C object src/CMakeFiles/git2internal.dir/alloc.c.o
cd /home/MYUSER/SOMEPATH/libgit2/build/src && /home/MYUSER/SOMEPATH/wasi-sdk-8.0/bin/clang --target=wasm32-unkown-wasi -DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\" -DSHA1DC_NO_STANDARD_INCLUDES=1 -D_FILE_OFFSET_BITS=64 -I/home/MYUSER/SOMEPATH/libgit2/build/src -I/home/MYUSER/SOMEPATH/libgit2/libgit2/src -I/home/MYUSER/SOMEPATH/libgit2/libgit2/include -I/home/MYUSER/SOMEPATH/libgit2/libgit2/deps/http-parser -I/home/MYUSER/SOMEPATH/libgit2/libgit2/deps/zlib  -D_GNU_SOURCE -v --sysroot=/home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot -Wno-incompatible-pointer-types -Wall -Wextra -Wdocumentation -Wno-missing-field-initializers -Wstrict-aliasing -Wstrict-prototypes -Wdeclaration-after-statement -Wshift-count-overflow -Wunused-const-variable -Wunused-function -Wint-conversion -Wformat -Wformat-security -Wno-documentation-deprecated-sync -g -D_DEBUG -O0   -std=gnu90 -o CMakeFiles/git2internal.dir/alloc.c.o   -c /home/MYUSER/SOMEPATH/libgit2/libgit2/src/alloc.c
clang version 9.0.0 (https://github.com/llvm/llvm-project 0399d5a9682b3cef71c653373e38890c63c4c365)
Target: wasm32-unkown-wasi
Thread model: posix
InstalledDir: /home/MYUSER/SOMEPATH/wasi-sdk-8.0/bin
 "/home/MYUSER/SOMEPATH/wasi-sdk-8.0/bin/clang-9" -cc1 -triple wasm32-unkown-wasi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name alloc.c -mrelocation-model static -mthread-model posix -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -fvisibility hidden -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -momit-leaf-frame-pointer -v -coverage-notes-file /home/MYUSER/SOMEPATH/libgit2/build/src/CMakeFiles/git2internal.dir/alloc.c.gcno -resource-dir /home/MYUSER/SOMEPATH/wasi-sdk-8.0/lib/clang/9.0.0 -D "SHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\"" -D "SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\"" -D SHA1DC_NO_STANDARD_INCLUDES=1 -D _FILE_OFFSET_BITS=64 -I /home/MYUSER/SOMEPATH/libgit2/build/src -I /home/MYUSER/SOMEPATH/libgit2/libgit2/src -I /home/MYUSER/SOMEPATH/libgit2/libgit2/include -I /home/MYUSER/SOMEPATH/libgit2/libgit2/deps/http-parser -I /home/MYUSER/SOMEPATH/libgit2/libgit2/deps/zlib -D _GNU_SOURCE -D _DEBUG -isysroot /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot -internal-isystem /home/MYUSER/SOMEPATH/wasi-sdk-8.0/lib/clang/9.0.0/include -internal-isystem /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/wasm32-wasi -internal-isystem /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include -O0 -Wno-incompatible-pointer-types -Wall -Wextra -Wdocumentation -Wno-missing-field-initializers -Wstrict-aliasing -Wstrict-prototypes -Wdeclaration-after-statement -Wshift-count-overflow -Wunused-const-variable -Wunused-function -Wint-conversion -Wformat -Wformat-security -Wno-documentation-deprecated-sync -std=gnu90 -fdebug-compilation-dir /home/MYUSER/SOMEPATH/libgit2/build/src -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gnustep -fno-common -fdiagnostics-show-option -o CMakeFiles/git2internal.dir/alloc.c.o -x c /home/MYUSER/SOMEPATH/libgit2/libgit2/src/alloc.c
clang -cc1 version 9.0.0 based upon LLVM 9.0.0 default target wasm32-wasi
ignoring nonexistent directory "/home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/wasm32-wasi"
#include "..." search starts here:
#include <...> search starts here:
 /home/MYUSER/SOMEPATH/libgit2/build/src
 /home/MYUSER/SOMEPATH/libgit2/libgit2/src
 /home/MYUSER/SOMEPATH/libgit2/libgit2/include
 /home/MYUSER/SOMEPATH/libgit2/libgit2/deps/http-parser
 /home/MYUSER/SOMEPATH/libgit2/libgit2/deps/zlib
 /home/MYUSER/SOMEPATH/wasi-sdk-8.0/lib/clang/9.0.0/include
 /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include
End of search list.
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/alloc.c:10:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/allocators/stdalloc.h:11:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/common.h:74:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/arpa/inet.h:9:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/netinet/in.h:10:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/sys/socket.h:5:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__header_sys_socket.h:5:
/home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__struct_sockaddr.h:10:14: error: use of undeclared identifier 'max_align_t'
    _Alignas(max_align_t) sa_family_t sa_family;
             ^
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/alloc.c:10:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/allocators/stdalloc.h:11:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/common.h:74:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/arpa/inet.h:9:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/netinet/in.h:10:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/sys/socket.h:5:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__header_sys_socket.h:6:
/home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__struct_sockaddr_storage.h:10:14: error: use of undeclared identifier 'max_align_t'
    _Alignas(max_align_t) sa_family_t ss_family;
             ^
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/alloc.c:10:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/allocators/stdalloc.h:11:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/common.h:74:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/arpa/inet.h:9:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/netinet/in.h:13:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__header_netinet_in.h:6:
/home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__struct_sockaddr_in.h:12:14: error: use of undeclared identifier 'max_align_t'
    _Alignas(max_align_t) sa_family_t sin_family;
             ^
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/alloc.c:10:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/allocators/stdalloc.h:11:
In file included from /home/MYUSER/SOMEPATH/libgit2/libgit2/src/common.h:74:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/arpa/inet.h:9:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/netinet/in.h:13:
In file included from /home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__header_netinet_in.h:7:
/home/MYUSER/SOMEPATH/libgit2/build/../../wasi-sdk-8.0/share/wasi-sysroot/include/__struct_sockaddr_in6.h:12:14: error: use of undeclared identifier 'max_align_t'
    _Alignas(max_align_t) sa_family_t sin6_family;
             ^
4 errors generated.
make[2]: *** [src/CMakeFiles/git2internal.dir/build.make:83: src/CMakeFiles/git2internal.dir/alloc.c.o] Error 1
make[2]: Leaving directory '/home/MYUSER/SOMEPATH/libgit2/build'
make[1]: *** [CMakeFiles/Makefile2:178: src/CMakeFiles/git2internal.dir/all] Error 2
make[1]: Leaving directory '/home/MYUSER/SOMEPATH/libgit2/build'
make: *** [Makefile:150: all] Error 2

signal header C++/WASI libc inconsistency (WASI SDK 8)

There is an inconsistency in the signal headers for C++ vs C lib that causes build failure. Tested for WASI SDK 8.

Error from compiler:
/usr/local/wasi-sdk/share/wasi-sysroot/include/c++/v1/csignal:53:9: error: no member named 'signal' in the global namespace; did you mean 'sigval'?
using ::signal;

The WASI clib header (share/wasi-sysroot/include/signal.h) uses __wasilibc_unmodified_upstream to disable signal function:
#ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
void (*signal(int, void (*)(int)))(int);
#endif

But the C++ csignal header (share/wasi-sysroot/include/c++/v1/csignal) refers to signal function always:
_LIBCPP_BEGIN_NAMESPACE_STD
using ::sig_atomic_t;
#ifdef __wasilibc_unmodified_upstream // ADDED BY ME
using ::signal;
#endif // ADDED BY ME
using ::raise;
_LIBCPP_END_NAMESPACE_STD

I just add __wasilibc_unmodified_upstream in csignal as a workaround for my build pipeline but likely better to add fake signal in WASI c lib to avoid modifying C++ llvm header? Not sure what is preferred.

LLVM 9.0.0 support.

It is not possible to build wasi-sdk with LLVM 9.0.0.

In file included from /home/qis/wasi/src/wasi-libc/libc-bottom-half/crt/crt1.c:1:
In file included from /LLVM/share/wasi-sysroot/include/stdlib.h:6:
In file included from /LLVM/share/wasi-sysroot/include/__functions_malloc.h:7:
/LLVM/share/wasi-sysroot/include/stddef.h:30:15: fatal error: 'stddef.h' file not found
#include_next <stddef.h>
              ^~~~~~~~~~
1 error generated.
Makefile:416: recipe for target 'startup_files' failed

It may be a good idea to start a trunk branch that targets the latest LLVM as both, a preparation for the next release and for making it easier for users to experiment with new compiler features in the browser.

Optimization for size

I want to implement a simple algorithm in WebAssembly, but adding just std::vector<float> into my code adds 250 KB of bloat. Is the prebuilt SDK compiled with -Os --function-sections --data-sections?

It seems to me it's not, so I wanted to rebuild it with such CFLAGS, but there are no instructions for the full SDK build. And docker_build.sh is currently wrong and broken for several reasons :-(

Can we enable LIBCXX_ENABLE_FILESYSTEM in libcxx?

Hi there!

I have just recompiled wasi-sdk v10 for a project I am working on and I thought I'd try to enable LIBCXX_ENABLE_FILESYSTEM for libcxx in order to have access to std::filesystem from my WASM code - the custom environment I am using is WASI-capable and works fine with C file I/O and C++ streams, but I hit a problem when trying to use std::filesystem::create_directory (or std::__fs::filesystem::create_directory as it seems to be named here).

My problem is that enabling the flag leads to an include error with a missing <sys/statvfs.h> included in "filesystem_common.h": does anyone know if it is at all possible to get std::filesystem to compile in libcxx for use in WASM?

For a bit of context, I am compiling under Ubuntu 18.04 (through WSL in Windows 10), cloned the wasi-sdk repo and used make. Everything works as expected without the flag.

Thanks a lot for your hard work!!!

Decoupling wasi-sysroot and LLVM?

Right now, wasi-sdk ships a single big package that includes both wasi-sysroot, and a copy of LLVM.

However, systems can already have a recent version of LLVM installed.

On MacOS, for example, the LLVM code included in wasi-sdk is useless as it will only run on Linux. But homebrew can seamlessly install the latest LLVM version. Most recent Linux and BSD distributions also include LLVM 8 or LLVM 9 packages that can compile to WebAssembly.

As CraneStation/wasi-libc doesn't ship any precompiled releases any more, would it make sense to split wasi-sdk in two, one package with LLVM for Linux, another package with only wasi-sysroot?

Can we have clang find the sysroot using a relative path?

Today we configure llvm with -DDEFAULT_SYSROOT=/opt/wasi-sdk/share/wasi-sysroot which means the resulting toolchain will work as expected only when installed in /opt/wasi-sdk.

Installing it anywhere else (e.g. just untaring it somewhere) will mean that one needs to pass the --sysroot=.. flag to each compiler invocation.

Perhaps there is some way we can find the default sysroot relative the compiler binary?

Followup from #57

Pointer conversion between int and long.

The wasi sdk currently implements https://github.com/WebAssembly/tool-conventions/blob/master/BasicCABI.md, so int and long are both 32 bits wide.

When mixing int and long, like in int l2 = 1L;, there is no warning.

But when using pointers, a warning is issued:

int *i = NULL;
long *l = i;

warning: incompatible pointer types initializing 'long *' with an expression of type 'int *' [-Wincompatible-pointer-types].

I find this especially confusing, because neither int32_t nor int64_t can be used if a long pointer is required in a library function.

Why is there this discrepencay between normal integers and pointers?

wasi-sdk-9 requires libtinfo.so.5

On Linux, version 9 of wasi-sdk seems to have a new dependency:

$ clang
clang: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

The current Ubuntu only ships with libtinfo.so.6.

Upgrade to llvm 9

llvm 9 is stable, and wasi-libc is now updated to build and test against it: WebAssembly/wasi-libc#169

Should probably make a release of the sdk baed on llvm 9 to keep on top of things. I think it would be nice to do it in isolation from any major wasi API or wasi-libc update.

Threads

Hey there, does wasi have support for threads at the moment? Looking at current experimental wasi target for rust, look like no but this might just be a limitation of an experimental target.

Thanks!

Should WASI provide stub support for atomics/threads even in single thread mode?

Currently, WASI disables support for atomics and pthreads since WASI is single-threaded. There's no pthreads.h, and including the C++ header gives an error.

This makes it difficult to port programs that use atomics and/or thread apis: even if the program can run in single threaded mode, I still have to manually remove all uses of atomics and pthread mutexes/semaphores/etc.

Would it make sense to provide stub implementations of atomics and pthreads apis, to minimize the changes required for programs originally written for multithreaded environments to compile on WASI?

Emscripten does provide atomics for programs, even though it's also single threaded; adding this may make it easier to port programs from emscripten.

Ship wasm32-wasi-clang sym links under `bin`?

Using these binaries then wouldn't require a --target. This is a relatively common pattern for cross compilers and it means you can put wasi-sdk/bin on the end of your PATH without shadowing /usr/bin/clang (which happens if you put it at the start of your PATH)

Using std::cout increases .wasm size by 900kb

A simple C++ program I wrote was ~40kb, but adding a simple std::cout << "Hello World" increased the bundle size to ~950kb (using -O2, -Os doesn't affect the size much). Using stdio.h printf() doesn't meaningfully change .wasm file size

Not sure if there is a bug in the sdk or there is just a lot of logic inside std::cout that I am not aware of. In any case it can be extremely hard to track down the final .wasm size to the features used, it might be something this project could help track with an external tool somehow (linker flag to add some special tokens to the .wasm file?)

Moving forward with wasi-sdk vs WebAssembly/waterfall

As mentioned in WebAssembly/wasi-libc#70 it might make sense to integrate or unify the two current efforts we have to build wasm sdk.

The https://github.com/WebAssembly/waterfall does have slightly different goals in that it primarily designed to all of our tooling together and tip of tree to warn is of breakages as soon as possible.
wasi-sdk on the other hand pins its various dependencies and rolls forward periodically.

If we do decide to continue with two separate efforts, would it make sense to move this repo under WebAssembly org? Like we are planning to do wit the sysroot repo?

Document linux requirements for prebuilt binaries

See #117

Currently we build against debian:stretch inside a docker contains and hope for the best. We should probably document the minimal requires for libc, libc++ and any other dynamic libraryies our binaries use.

We should perhaps also do some minimal testing against some reasonable subset of modern distros as part of the build/release process.

import function

Hi, guys!

I am trying to declare and use import function in C code like this one (as WASI syscalls being imported):

#define __IMPORT(name) \
    __attribute__((__import_module__("logger"), __import_name__(#name)))

void __wasm_log(
        const char *ptr,
        int length
) __IMPORT(wasm_log);

More precisely I wanted __wasm_log to presence in compiled wasm code in import section without body (then it would be linked with external linker). But I am getting the following result:

user:$ clang -fdeclspec --sysroot=/tmp/wasi-sdk/ --target=wasm32-unknown-wasi -o hello_world.wasm -nostartfiles -fvisibility=hidden -Wl,--no-entry,--demangle,--export=allocate,--export=deallocate,--export=invoke -- main.c
wasm-ld: error: /var/folders/main-36d4c2.o: undefined symbol: __wasm_log
clang-8: error: lld command failed with exit code 1 (use -v to see invocation)

What am i doing wrong?

wasm features enabled by default with wasi-sdk clang

I'm currently looking at adding a few features to the default CPU in llvm: https://reviews.llvm.org/D77908

I'm guessing that wasi-sdk users are mostly targeting wasmtime and wasmer which should not have a problem with any stage 5 features I guess? So its probably fine, but wanted to raise this issue in case anyone has any concerns.

If we want to be conservative we could have wasi-sdk clang default to the mvp CPU maybe?

C++ support in WASI?

I saw C++ ABIs and stuff mentioned in the Makefile. Does that mean it's safe to assume that WASI fully supports C++ now? Or are there still problems? Thanks in advance for any answers.

Build is broken

Facing build issue with the latest version
$ sudo make
mkdir -p build/libcxxabi
cd build/libcxxabi; cmake -G "Unix Makefiles"
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
-DCMAKE_CXX_COMPILER_WORKS=ON
-DCMAKE_C_COMPILER_WORKS=ON
-DLIBCXXABI_ENABLE_EXCEPTIONS:BOOL=OFF
-DLIBCXXABI_ENABLE_SHARED:BOOL=OFF
-DLIBCXXABI_HAS_PTHREAD_API:BOOL=ON
-DCXX_SUPPORTS_CXX11=ON
-DLLVM_COMPILER_CHECKED=ON
-DCMAKE_BUILD_TYPE=RelWithDebugInfo
-DLIBCXXABI_LIBCXX_PATH=/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxx
-DLIBCXXABI_LIBCXX_INCLUDES=/opt/wasi-sdk/share/sysroot/include/c++/v1
-DLLVM_CONFIG_PATH=/media/ExtendedDrive/wasi-sdk/build/llvm/bin/llvm-config
-DCMAKE_TOOLCHAIN_FILE=/media/ExtendedDrive/wasi-sdk/wasi-sdk.cmake
-DWASI_SDK_PREFIX=/opt/wasi-sdk
-DCMAKE_C_FLAGS="-fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m"
-DCMAKE_CXX_FLAGS="-fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m"
-DUNIX:BOOL=ON
--debug-trycompile
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi
debug trycompile on
System is unknown to cmake, create:
Platform/Wasm to use this system, please send your config file to [email protected] so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please send that file to [email protected].
-- Configuring for standalone build.
-- Found LLVM_CONFIG_PATH as /media/ExtendedDrive/wasi-sdk/build/llvm/bin/llvm-config
-- Linker detection: LLD
-- Building with -fPIC
CMake Warning at CMakeLists.txt:476 (message):
The libc++abi tests aren't valid when libc++abi is built standalone (i.e.
outside of llvm/projects/libcxxabi ) and is built without a shared library.
Either build a shared library, build libc++abi at the same time as you
build libc++, or do without testing. No check target will be available!

-- Configuring done
-- Generating done
-- Build files have been written to: /media/ExtendedDrive/wasi-sdk/build/libcxxabi
cd build/libcxxabi; make -j 8 install
make[1]: Entering directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
/usr/local/bin/cmake -S/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi -B/media/ExtendedDrive/wasi-sdk/build/libcxxabi --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /media/ExtendedDrive/wasi-sdk/build/libcxxabi/CMakeFiles /media/ExtendedDrive/wasi-sdk/build/libcxxabi/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[2]: Entering directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
make -f src/CMakeFiles/cxxabi_objects.dir/build.make src/CMakeFiles/cxxabi_objects.dir/depend
make[3]: Entering directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src /media/ExtendedDrive/wasi-sdk/build/libcxxabi /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src/CMakeFiles/cxxabi_objects.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
make -f src/CMakeFiles/cxxabi_objects.dir/build.make src/CMakeFiles/cxxabi_objects.dir/build
make[3]: Entering directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
[ 5%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_aux_runtime.cpp.o
[ 10%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_default_handlers.cpp.o
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_aux_runtime.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_aux_runtime.cpp
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_default_handlers.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_default_handlers.cpp
[ 15%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_exception_storage.cpp.o
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_exception_storage.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_exception_storage.cpp
[ 21%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o
[ 26%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_guard.cpp.o
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_demangle.cpp
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_guard.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_guard.cpp
[ 31%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_handlers.cpp.o
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_handlers.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_handlers.cpp
[ 36%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_vector.cpp.o
[ 42%] Building CXX object src/CMakeFiles/cxxabi_objects.dir/cxa_unexpected.cpp.o
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_vector.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_vector.cpp
cd /media/ExtendedDrive/wasi-sdk/build/libcxxabi/src && /opt/wasi-sdk/bin/clang++ --target=wasm32-unknown-wasi --sysroot=/opt/wasi-sdk/share/sysroot -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LIBCPP_DISABLE_EXTERN_TEMPLATE -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS -D_LIBCPP_HAS_THREAD_API_PTHREAD -D_LIBCXXABI_BUILDING_LIBRARY -D_LIBCXXABI_NO_EXCEPTIONS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/include -fdebug-prefix-map=/media/ExtendedDrive/wasi-sdk=wasisdk://v3.6g8eff94c85cdc+m -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -w -ffunction-sections -fdata-sections -fPIC -nostdinc++ -Werror=return-type -W -Wall -Wchar-subscripts -Wconversion -Wmismatched-tags -Wmissing-braces -Wnewline-eof -Wunused-function -Wshadow -Wshorten-64-to-32 -Wsign-compare -Wsign-conversion -Wstrict-aliasing=2 -Wstrict-overflow=4 -Wunused-parameter -Wunused-variable -Wwrite-strings -Wundef -Wno-error -WX- -pedantic -fstrict-aliasing -fno-exceptions -D_DEBUG -D_LIBCPP_BUILD_STATIC -std=c++11 -o CMakeFiles/cxxabi_objects.dir/cxa_unexpected.cpp.o -c /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_unexpected.cpp
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_default_handlers.cpp:12:10: fatal error: 'stdexcept' file not found
#include
^~~~~~~~~~~
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_handlers.cpp:13:10: fatal error: 'stdexcept' file not found
#include
^~~~~~~~~~~
In file included from /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_demangle.cpp:18:
In file included from /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/demangle/ItaniumDemangle.h:23:
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/demangle/StringView.h:15:10: fatal error: 'algorithm' file not found
#include
^~~~~~~~~~~
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_guard.cpp:13:10: fatal error: '__threading_support' file not found
#include <__threading_support>
^~~~~~~~~~~~~~~~~~~~~
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_aux_runtime.cpp:14:10: fatal error: 'new' file not found
#include
^~~~~
1 error generated.
1 error generated.
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_unexpected.cpp:10:10: fatal error: 'exception' file not found
#include
^~~~~~~~~~~
src/CMakeFiles/cxxabi_objects.dir/build.make:117: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_guard.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_guard.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
src/CMakeFiles/cxxabi_objects.dir/build.make:65: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_aux_runtime.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_aux_runtime.cpp.o] Error 1
In file included from /media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_exception_storage.cpp:14:
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_exception.hpp:17:10: fatal error: 'exception' file not found
#include // for std::unexpected_handler and std::terminate_handler
^~~~~~~~~~~
1 error generated.
1 error generated.
src/CMakeFiles/cxxabi_objects.dir/build.make:130: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_handlers.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_handlers.cpp.o] Error 1
1 error generated.
src/CMakeFiles/cxxabi_objects.dir/build.make:78: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_default_handlers.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_default_handlers.cpp.o] Error 1
src/CMakeFiles/cxxabi_objects.dir/build.make:143: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_unexpected.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_unexpected.cpp.o] Error 1
1 error generated.
src/CMakeFiles/cxxabi_objects.dir/build.make:104: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_exception_storage.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_exception_storage.cpp.o] Error 1
/media/ExtendedDrive/wasi-sdk/src/llvm-project/libcxxabi/src/cxa_vector.cpp:16:10: fatal error: 'exception' file not found
#include // for std::terminate
^~~~~~~~~~~
1 error generated.
src/CMakeFiles/cxxabi_objects.dir/build.make:156: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_vector.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_vector.cpp.o] Error 1
1 error generated.
src/CMakeFiles/cxxabi_objects.dir/build.make:91: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o' failed
make[3]: *** [src/CMakeFiles/cxxabi_objects.dir/cxa_demangle.cpp.o] Error 1
make[3]: Leaving directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
CMakeFiles/Makefile2:195: recipe for target 'src/CMakeFiles/cxxabi_objects.dir/all' failed
make[2]: *** [src/CMakeFiles/cxxabi_objects.dir/all] Error 2
make[2]: Leaving directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
Makefile:120: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/media/ExtendedDrive/wasi-sdk/build/libcxxabi'
Makefile:97: recipe for target 'build/libcxxabi.BUILT' failed
make: *** [build/libcxxabi.BUILT] Error 2

Sanitizer support?

Hi! Is there a path forward towards supporting the Clang sanitizers on wasm32-unknown-wasi?

libfuse: 'sys/statvfs.h' file not found

I'm trying to compile libfuse's hello.c.

$ /opt/wasi-sdk/bin/clang hello.c `pkg-config fuse3 --cflags --libs` -o demo.wasm
In file included from hello.c:24:
/usr/local/include/fuse3/fuse.h:25:10: fatal error: 'sys/statvfs.h' file not found
#include <sys/statvfs.h>
         ^~~~~~~~~~~~~~~
1 error generated.

Can it be resolved?

wasi-sdk 8.0 libstdc++ required version is too high

On an Ubuntu Xenial system, I see:

/opt/wasi-sdk/bin/clang: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22\' not found (required by /opt/wasi-sdk/bin/clang)

This hasn't been an issue with past releases, and seems to be new since basing the Dockerfile on Debian stretch rather than Xenial. Could we consider switching back to Xenial, or an older version of Debian that would pull in a compatible libstdc++?

How much of llvm/clang do we want to ship in the SDK

Right now the SDK consists of two main parts:

  1. the wasi sysroot
  2. a recent build llvm from stable branch

In (2) list of llvm components we install is current long and hardcoded and includes many binaries but also libllvm/libclang/headers that allow for tools to be build with llvm itself.

I'm not sure what logic was used to decide which llvm components to install but I think we would be useful to make a conscious decision: Are we shipping a compiler to end users (e.g. apt-get install clang) or do we also want to allow compiler developers to use the SDK (e.g. apt-get install llvm-dev).

For something like wasi-sdk I think we should really focus on keeping it small that targeted and as such we should just install the minimal set of end user tools that make sense (hopefully llvm has an install target such as "install-user-tools" that encapsulates that for us so we don't need to maintain out large subset of install targets.

If we do want to ship a "fat" SDK when maybe we just want to install everything (.e.g make install)?

My guess is that most people doing compiler development already have their own llvm either in the form an llvm-dev package or a source checkout.. but perhaps I'm wrong.

stdio.h file not found.

I am on mac os Catalina. And clang is not able to find stdio.h for some weird reason.
I looked into the files in the sdk to my surprise I could not find the stdio header file.
I am using the following command:

clang -v sample.c --sysroot=/home/mac/Downloads/wasi-sdk-7.0/opt/wasi-sdk/share/wasi-sysroot/ --target=wasm32-wasi -o sample.wasm 

I get the following error:

Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: wasm32-wasi
Thread model: single
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple wasm32-wasi -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name sample.c -mrelocation-model static -mthread-model single -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic -fvisibility hidden -dwarf-column-info -debugger-tuning=gdb -target-linker-version 450.3 -momit-leaf-frame-pointer -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1 -isysroot /home/mac/Downloads/wasi-sdk-7.0/opt/wasi-sdk/share/wasi-sysroot/ -internal-isystem /home/mac/Downloads/wasi-sdk-7.0/opt/wasi-sdk/share/wasi-sysroot//include -Wno-atomic-implicit-seq-cst -Wno-framework-include-private-from-public -Wno-atimport-in-framework-header -Wno-quoted-include-in-framework-header -fdebug-compilation-dir /Users/mac -ferror-limit 19 -fmessage-length 181 -fobjc-runtime=gnustep -fno-common -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/dw/m7rkkl9x1ds7176r6_mqq5cc0000gn/T/sample-187628.o -x c sample.c
clang -cc1 version 10.0.1 (clang-1001.0.46.4) default target x86_64-apple-darwin19.0.0
ignoring nonexistent directory "/home/mac/Downloads/wasi-sdk-7.0/opt/wasi-sdk/share/wasi-sysroot//include"
ignoring nonexistent directory "/home/mac/Downloads/wasi-sdk-7.0/opt/wasi-sdk/share/wasi-sysroot//usr/local/include"
ignoring nonexistent directory "/home/mac/Downloads/wasi-sdk-7.0/opt/wasi-sdk/share/wasi-sysroot//usr/include"
#include "..." search starts here:
#include <...> search starts here:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.1/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
End of search list.
sample.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.

FYI sample.c

#include <stdio.h>

int main(){
	printf("Hello world \n");
}

Add CI support to get releases built automatically

We could use circle-ci or travis-ci. They both allow for long builds like this now (travis limit is 50 minutes and I think circle-ci is 5 hours!).

We could also add PR testing, although it might be annoying long..

Consider adding main() signature with environment argument

Per C Standard, J.5.1 [ISO/IEC 9899:2011] main with environment is ok and is supported by all the main platforms.

Test could be something like this:

#include <stdio.h>

int main(int argc, /*const*/ char* argv[], /*const*/ char* envp[])
{
  if (argc < 1) {
    return 1;
  }

  for (int i = 0; i < argc; ++i) {
    const char* arg = argv[i];
    if (!arg) {
      return 1; // do not allow nullptr argument
    }
    for (; *arg; ++arg) { // ensure memory is valid
    }
  }

  for (size_t j = 0; envp[j]; ++j) {
    const char* env = envp[j];
    if (!env) {
      return 1; // do not allow nullptr item
    }
    for (; *env; ++env) { // ensure memory is valid
    }
  }

  puts("hello from argc argv envp main!");
  return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.