Skip to content

Commit 307694b

Browse files
authored
Add DWARF debugging information to all artifacts by default (#422)
* Add DWARF debugging information to all artifacts by default This commit adds DWARF debugging information with the `-g` compiler flag to all WASI artifacts for wasi-sdk. The LLVM build itself does not have debugging information, only the sysroot artifacts. This is intended to assist with debugging. The main downside to this is binary size of generated artifacts will, by default, be larger. Stripping debug information from an artifact though involves removing custom sections which is generally pretty easy to do through wasm tooling. * Pass extra cflags to wasi-libc * Fix tests from previous commit * Update some expected error messages and remove some files with duplicate error messages that are no longer needed. * Remove undefined behavior in `stat.c` where padding bytes were being compared.
1 parent af429ed commit 307694b

12 files changed

+30
-42
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ CLANG_VERSION=$(shell $(VERSION_SCRIPT) llvm-major --llvm-dir=$(LLVM_PROJ_DIR))
5050
VERSION:=$(shell $(VERSION_SCRIPT))
5151
DEBUG_PREFIX_MAP=-fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)
5252

53+
# Generate debuginfo by default for wasi-sdk since it's easily strippable and
54+
# otherwise quite useful for debugging.
55+
WASI_SDK_CFLAGS := $(DEBUG_PREFIX_MAP) -g
56+
WASI_SDK_CXXFLAGS := $(WASI_SDK_CFLAGS)
57+
5358
default: build
5459
@echo "Use -fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)"
5560

@@ -138,6 +143,7 @@ WASI_LIBC_MAKEFLAGS = \
138143
AR=$(BUILD_PREFIX)/bin/llvm-ar \
139144
NM=$(BUILD_PREFIX)/bin/llvm-nm \
140145
SYSROOT=$(BUILD_PREFIX)/share/wasi-sysroot \
146+
EXTRA_CFLAGS="$(WASI_SDK_CFLAGS)" \
141147
TARGET_TRIPLE=$(1)
142148

143149
build/wasi-libc.BUILT: build/compiler-rt.BUILT build/wasm-component-ld.BUILT
@@ -166,7 +172,7 @@ build/compiler-rt.BUILT: build/llvm.BUILT
166172
-DCOMPILER_RT_ENABLE_IOS=OFF \
167173
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=On \
168174
-DWASI_SDK_PREFIX=$(BUILD_PREFIX) \
169-
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP)" \
175+
-DCMAKE_C_FLAGS="$(WASI_SDK_CFLAGS)" \
170176
-DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \
171177
-DCOMPILER_RT_OS_DIR=wasi \
172178
-DCMAKE_INSTALL_PREFIX=$(PREFIX)/lib/clang/$(CLANG_VERSION)/ \
@@ -225,8 +231,8 @@ LIBCXX_CMAKE_FLAGS = \
225231
-DUNIX:BOOL=ON \
226232
--debug-trycompile \
227233
-DCMAKE_SYSROOT=$(BUILD_PREFIX)/share/wasi-sysroot \
228-
-DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP) $(EXTRA_CFLAGS) $(4) --target=$(3)" \
229-
-DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP) $(EXTRA_CXXFLAGS) $(4) --target=$(3)" \
234+
-DCMAKE_C_FLAGS="$(WASI_SDK_CFLAGS) $(EXTRA_CFLAGS) $(4) --target=$(3)" \
235+
-DCMAKE_CXX_FLAGS="$(WASI_SDK_CXXFLAGS) $(EXTRA_CXXFLAGS) $(4) --target=$(3)" \
230236
-DLIBCXX_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/$(3) \
231237
-DLIBCXXABI_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/$(3) \
232238
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Error: failed to run main module `abort.c.---.wasm`
22

33
Caused by:
4-
0: failed to invoke command default
4+
0: failed to invoke ---
55
1: error while executing at wasm backtrace:
6+
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
67
2: wasm trap: wasm `unreachable` instruction executed

tests/general/abort.c.stderr.expected.filter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ set -euo pipefail
33

44
cat \
55
| sed -e 's/main module `abort\.c\.[^`]*\.wasm`/main module `abort.c.---.wasm`/' \
6+
| sed -e 's/failed to invoke.*/failed to invoke ---/' \
67
| sed -E '/0x[[:xdigit:]]+/d'

tests/general/abort.c.wasm32-wasi-preview2.stderr.expected

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/general/abort.c.wasm32-wasi.stderr.expected

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/general/abort.c.wasm32-wasip2.stderr.expected

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/general/assert-fail.c.stderr.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Assertion failed: false (assert-fail.c: main: 5)
22
Error: failed to run main module `assert-fail.c.---.wasm`
33

44
Caused by:
5-
0: failed to invoke command default
5+
0: failed to invoke ---
66
1: error while executing at wasm backtrace:
7+
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable may show more debugging information
78
2: wasm trap: wasm `unreachable` instruction executed

tests/general/assert-fail.c.stderr.expected.filter

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ set -euo pipefail
33

44
cat \
55
| sed -e 's/main module `assert-fail\.c\.[^`]*\.wasm`/main module `assert-fail.c.---.wasm`/' \
6+
| sed -e 's/failed to invoke.*/failed to invoke ---/' \
67
| sed -E '/0x[[:xdigit:]]+/d'

tests/general/assert-fail.c.wasm32-wasi-preview2.stderr.expected

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)