Skip to content

Commit

Permalink
Add option to build system for preferencing DWARF symbols.
Browse files Browse the repository at this point in the history
This commit allows the build system to output DWARF symbols when
PREFER_DWARF_SYMBOLS=1 is set, for example, in user-config.make.

Works best with GCC MinGW rather than LLVM, so it is recommended to
also set MINGW_PATH (for example: MINGW_PATH=/usr/bin).

It also adds a LLVM_MINGW_PATH, which should be modified if a custom
LLVM path is to be used. MINGW_PATH now defaults to this value.

wpfgfx-netcore and some tests only compile with LLVM and always use
LLVM_MINGW_PATH. The rest will use MINGW_PATH which can be LLVM or GCC.
  • Loading branch information
Brendan McGrath authored and Esme Povirk committed Sep 20, 2024
1 parent c647c50 commit b7e5d51
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
12 changes: 10 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ENABLE_DOTNET_CORE_WPFGFX=1
ENABLE_MONODX=1

ENABLE_DEBUG_SYMBOLS=1
PREFER_DWARF_SYMBOLS=0

ENABLE_ARM=0

Expand All @@ -41,6 +42,7 @@ MONO_CFG_DIR=$(BUILDDIR_ABS)/mono-unix-install/etc
MONO_ENV=PATH="$(MONO_BIN_PATH):$$PATH" LD_LIBRARY_PATH="$(MONO_LD_PATH):$$LD_LIBRARY_PATH" MONO_GAC_PREFIX="$(MONO_GAC_PREFIX)" MONO_CFG_DIR="$(MONO_CFG_DIR)"

MINGW_ENV=$(and $(MINGW_PATH),PATH=$(MINGW_PATH):$$PATH)
LLVM_MINGW_ENV=$(and $(LLVM_MINGW_PATH),PATH=$(LLVM_MINGW_PATH):$$PATH)

CP_R=$(SRCDIR_ABS)/tools/copy_recursive.py
RM_F=rm -f
Expand Down Expand Up @@ -98,9 +100,15 @@ clean: clean-build
define MINGW_TEMPLATE =

ifeq (1,$(ENABLE_DEBUG_SYMBOLS))
ifeq (1,$(PREFER_DWARF_SYMBOLS))
INSTALL_PE_$(1)=do_install () { $$(MINGW_ENV) $$(MINGW_$(1))-objcopy --only-keep-debug "$$$$1" "$$$$(printf %s "$$$$2"|sed -e 's/\....$$$$/.dbg/')"; $$(MINGW_ENV) $$(MINGW_$(1))-objcopy --strip-all "$$$$1" "$$$$2"; $$(MINGW_ENV) $$(MINGW_$(1))-objcopy --add-gnu-debuglink="$$$$(printf %s "$$$$2"|sed -e 's/\....$$$$/.dbg/')" "$$$$2"; }; do_install
PDB_CFLAGS_$(1)=-gdwarf-4 -g
PDB_LDFLAGS_$(1)=
else
INSTALL_PE_$(1)=do_install () { cp "$$$$(printf %s "$$$$1"|sed -e 's/\....$$$$/.pdb/')" "$$$$(printf %s "$$$$2"|sed -e 's/\....$$$$/.pdb/')"; cp "$$$$1" "$$$$2"; $$(MINGW_ENV) $$(MINGW_$(1))-strip "$$$$2"; }; do_install
PDB_CFLAGS_$(1)=-gcodeview -g
PDB_LDFLAGS_$(1)=-Wl,-pdb=
endif
else
INSTALL_PE_$(1)=do_install () { cp "$$$$1" "$$$$2"; $$(MINGW_ENV) $$(MINGW_$(1))-strip "$$$$2"; }; do_install
endif
Expand Down Expand Up @@ -289,7 +297,7 @@ clean-msi:
clean: clean-msi

$(OUTDIR)/wine-mono-$(MSI_VERSION)-x86.tar.$(COMPRESSED_SUFFIX): $(BUILDDIR)/.imagedir-built
cd $(IMAGEDIR)/..; tar cf $(OUTDIR_ABS)/wine-mono-$(MSI_VERSION)-x86.tar.$(COMPRESSED_SUFFIX) --transform 's:^$(notdir $(IMAGEDIR_ABS)):wine-mono-$(MSI_VERSION):g' '--exclude=*.pdb' '--use-compress-program=$(COMPRESSOR)' $(notdir $(IMAGEDIR_ABS))
cd $(IMAGEDIR)/..; tar cf $(OUTDIR_ABS)/wine-mono-$(MSI_VERSION)-x86.tar.$(COMPRESSED_SUFFIX) --transform 's:^$(notdir $(IMAGEDIR_ABS)):wine-mono-$(MSI_VERSION):g' '--exclude=*.pdb' '--exclude=*.dbg' '--use-compress-program=$(COMPRESSOR)' $(notdir $(IMAGEDIR_ABS))

bin: $(OUTDIR)/wine-mono-$(MSI_VERSION)-x86.tar.$(COMPRESSED_SUFFIX)
.PHONY: bin
Expand All @@ -303,7 +311,7 @@ clean-targz:
clean: clean-targz

$(OUTDIR)/wine-mono-$(MSI_VERSION)-dbgsym.tar.$(COMPRESSED_SUFFIX): $(BUILDDIR)/.imagedir-built
cd $(IMAGEDIR)/..; find $(notdir $(IMAGEDIR_ABS)) -name '*.pdb'|tar cf $(OUTDIR_ABS)/wine-mono-$(MSI_VERSION)-dbgsym.tar.$(COMPRESSED_SUFFIX) --transform 's:^$(notdir $(IMAGEDIR_ABS)):wine-mono-$(MSI_VERSION):g' -T - '--use-compress-program=$(COMPRESSOR)'
cd $(IMAGEDIR)/..; find $(notdir $(IMAGEDIR_ABS)) -name '*.pdb' -o -name '*.dbg'|tar cf $(OUTDIR_ABS)/wine-mono-$(MSI_VERSION)-dbgsym.tar.$(COMPRESSED_SUFFIX) --transform 's:^$(notdir $(IMAGEDIR_ABS)):wine-mono-$(MSI_VERSION):g' -T - '--use-compress-program=$(COMPRESSOR)'

dbgsym: $(OUTDIR)/wine-mono-$(MSI_VERSION)-dbgsym.tar.$(COMPRESSED_SUFFIX)
.PHONY: dbgsym
Expand Down
5 changes: 3 additions & 2 deletions llvm.make
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FETCH_LLVM_MINGW=$(SRCDIR_ABS)/$(FETCH_LLVM_MINGW_DIRECTORY)

AUTO_LLVM_MINGW?=1

ifeq ($(origin MINGW_x86) $(origin MINGW_x86_64) $(origin MINGW_PATH) $(AUTO_LLVM_MINGW),undefined undefined undefined 1)
ifeq ($(origin MINGW_x86) $(origin MINGW_x86_64) $(origin LLVM_MINGW_PATH) $(AUTO_LLVM_MINGW),undefined undefined undefined 1)

#default: obtain llvm-mingw automatically

Expand All @@ -19,10 +19,11 @@ ifeq (x$(wildcard $(FETCH_LLVM_MINGW)/.dir),x)
DO_FETCH_LLVM_MINGW=1
endif

MINGW_PATH = $(FETCH_LLVM_MINGW)/bin
LLVM_MINGW_PATH = $(FETCH_LLVM_MINGW)/bin

endif

MINGW_PATH ?= $(LLVM_MINGW_PATH)
MINGW_x86 ?= i686-w64-mingw32
MINGW_x86_64 ?= x86_64-w64-mingw32
MINGW_arm ?= armv7-w64-mingw32
Expand Down
2 changes: 1 addition & 1 deletion mono.make
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ IMAGEDIR_BUILD_TARGETS += $$(BUILDDIR)/mono-$(1)/support/.built
libmono-2.0-$(1).dll: $$(BUILDDIR)/mono-$(1)/mono/mini/.built
mkdir -p "$$(IMAGEDIR)/bin"
$$(INSTALL_PE_$(1)) "$$(BUILDDIR)/mono-$(1)/mono/mini/.libs/libmonosgen-2.0.dll" "$$(IMAGEDIR)/bin/libmono-2.0-$(1).dll"
if test x1 = x$(ENABLE_DEBUG_SYMBOLS); then cp "$$(BUILDDIR)/mono-$(1)/mono/mini/libmono-2.0-$(1).pdb" "$$(IMAGEDIR)/bin/libmono-2.0-$(1).pdb"; fi
if test x1 = x$(ENABLE_DEBUG_SYMBOLS) -a x1 != x$(PREFER_DWARF_SYMBOLS); then cp "$$(BUILDDIR)/mono-$(1)/mono/mini/libmono-2.0-$(1).pdb" "$$(IMAGEDIR)/bin/libmono-2.0-$(1).pdb"; fi

.PHONY: libmono-2.0-$(1).dll
imagedir-targets: libmono-2.0-$(1).dll
Expand Down
6 changes: 3 additions & 3 deletions tools/tests/tests.make
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ clean: clean-tools-tests
define MINGW_TEMPLATE +=

$$(BUILDDIR)/call-mixedmode-$(1).exe: $$(SRCDIR)/tools/tests/call-mixedmode.c $$(MINGW_DEPS)
$$(MINGW_ENV) $$(MINGW_$(1))-gcc $$(filter %.lib,$$^) $$< -o $$@
$$(LLVM_MINGW_ENV) $$(MINGW_$(1))-gcc $$(filter %.lib,$$^) $$< -o $$@

tools-tests-all: $$(BUILDDIR)/call-mixedmode-$(1).exe $$(BUILDDIR)/call-method-$(1).exe

Expand All @@ -208,7 +208,7 @@ clean-call-method-$(1):
clean-build: clean-call-method-$(1)

$$(BUILDDIR)/winemonotest-$(1).dll: $$(SRCDIR)/tools/tests/winemonotest.c $$(MINGW_DEPS)
$$(MINGW_ENV) $$(MINGW_$(1))-gcc -shared -Wl,--kill-at $$(filter %.lib,$$^) -loleaut32 $$< -o $$@
$$(LLVM_MINGW_ENV) $$(MINGW_$(1))-gcc -shared -Wl,--kill-at $$(filter %.lib,$$^) -loleaut32 $$< -o $$@

tools-tests-all: $$(BUILDDIR)/winemonotest-$(1).dll

Expand All @@ -218,7 +218,7 @@ clean-winemonotest-$(1):
clean-build: clean-winemonotest-$(1)

$$(BUILDDIR)/vtblgap-lib-$(1).dll: $$(SRCDIR)/tools/tests/vtblgap-lib.cpp $$(MINGW_DEPS)
$$(MINGW_ENV) $$(MINGW_$(1))-g++ -shared -luuid -lole32 $$< -static-libgcc -static-libstdc++ -o $$@
$$(LLVM_MINGW_ENV) $$(MINGW_$(1))-g++ -shared -luuid -lole32 $$< -static-libgcc -static-libstdc++ -o $$@

tools-tests-all: $$(BUILDDIR)/vtblgap-lib-$(1).dll

Expand Down
2 changes: 1 addition & 1 deletion wpf.make
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif

$$(BUILDDIR)/wpfgfx-netcore-$(1)/.built: $$(WPF_SRCS) $$(MINGW_DEPS)
mkdir -p $$(@D)
+$$(MINGW_ENV) CFLAGS="$$(PDB_CFLAGS_$(1))" CXXFLAGS="$$(PDB_CFLAGS_$(1))" LDFLAGS="$$(PDB_LDFLAGS_$(1))" $(MAKE) OBJDIR=$$(BUILDDIR_ABS)/wpfgfx-netcore-$(1) -C $$(SRCDIR_ABS)/wpf/src/Microsoft.DotNet.Wpf/src/WpfGfx "MINGW=$$(MINGW_$(1))" ARCH=$(1)
+$$(LLVM_MINGW_ENV) CFLAGS="$$(PDB_CFLAGS_$(1))" CXXFLAGS="$$(PDB_CFLAGS_$(1))" LDFLAGS="$$(PDB_LDFLAGS_$(1))" $(MAKE) OBJDIR=$$(BUILDDIR_ABS)/wpfgfx-netcore-$(1) -C $$(SRCDIR_ABS)/wpf/src/Microsoft.DotNet.Wpf/src/WpfGfx "MINGW=$$(MINGW_$(1))" ARCH=$(1)
touch "$$@"
ifeq (1,$(ENABLE_DOTNET_CORE_WPF))
ifeq (1,$(ENABLE_DOTNET_CORE_WPFGFX))
Expand Down

0 comments on commit b7e5d51

Please sign in to comment.