From 8fbfe1875dec7980a9c6a952924f9b3912a57ebc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 20 May 2024 12:36:57 -0700 Subject: [PATCH] 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. --- Makefile | 11 ++++++++--- src/wasi-libc | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index eeac2db..15f2c78 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,11 @@ CLANG_VERSION=$(shell $(VERSION_SCRIPT) llvm-major --llvm-dir=$(LLVM_PROJ_DIR)) VERSION:=$(shell $(VERSION_SCRIPT)) DEBUG_PREFIX_MAP=-fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION) +# Generate debuginfo by default for wasi-sdk since it's easily strippable and +# otherwise quite useful for debugging. +WASI_SDK_CFLAGS := $(DEBUG_PREFIX_MAP) -g +WASI_SDK_CXXFLAGS := $(WASI_SDK_CFLAGS) + default: build @echo "Use -fdebug-prefix-map=$(ROOT_DIR)=wasisdk://v$(VERSION)" @@ -166,7 +171,7 @@ build/compiler-rt.BUILT: build/llvm.BUILT -DCOMPILER_RT_ENABLE_IOS=OFF \ -DCOMPILER_RT_DEFAULT_TARGET_ONLY=On \ -DWASI_SDK_PREFIX=$(BUILD_PREFIX) \ - -DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP)" \ + -DCMAKE_C_FLAGS="$(WASI_SDK_CFLAGS)" \ -DLLVM_CONFIG_PATH=$(ROOT_DIR)/build/llvm/bin/llvm-config \ -DCOMPILER_RT_OS_DIR=wasi \ -DCMAKE_INSTALL_PREFIX=$(PREFIX)/lib/clang/$(CLANG_VERSION)/ \ @@ -225,8 +230,8 @@ LIBCXX_CMAKE_FLAGS = \ -DUNIX:BOOL=ON \ --debug-trycompile \ -DCMAKE_SYSROOT=$(BUILD_PREFIX)/share/wasi-sysroot \ - -DCMAKE_C_FLAGS="$(DEBUG_PREFIX_MAP) $(EXTRA_CFLAGS) $(4) --target=$(3)" \ - -DCMAKE_CXX_FLAGS="$(DEBUG_PREFIX_MAP) $(EXTRA_CXXFLAGS) $(4) --target=$(3)" \ + -DCMAKE_C_FLAGS="$(WASI_SDK_CFLAGS) $(EXTRA_CFLAGS) $(4) --target=$(3)" \ + -DCMAKE_CXX_FLAGS="$(WASI_SDK_CXXFLAGS) $(EXTRA_CXXFLAGS) $(4) --target=$(3)" \ -DLIBCXX_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/$(3) \ -DLIBCXXABI_LIBDIR_SUFFIX=$(ESCAPE_SLASH)/$(3) \ -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ diff --git a/src/wasi-libc b/src/wasi-libc index 9e8c542..44c4b1e 160000 --- a/src/wasi-libc +++ b/src/wasi-libc @@ -1 +1 @@ -Subproject commit 9e8c542319242a5e536e14e6046de5968d298038 +Subproject commit 44c4b1e3a58f5c3042fa26dff9c1b29b6fc695b2