From 1e965e30ff3b1dc431bb9dddf8dcc005d70a9926 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 29 Jan 2024 17:19:32 -0800 Subject: [PATCH] windows host: add embedded manifest file Without a manifest, Windows applications force a fixed PATH_MAX limit to any pathname; this is unnecessary. Signed-off-by: H. Peter Anvin --- Makefile.in | 18 +++++++++++++----- Mkfiles/msvc.mak | 18 ++++++++++++------ Mkfiles/openwcom.mak | 7 +++++-- configure.ac | 10 +++++++--- win/.gitignore | 1 + win/manifest.rc | 2 ++ win/manifest.xml | 24 ++++++++++++++++++++++++ 7 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 win/.gitignore create mode 100644 win/manifest.rc create mode 100644 win/manifest.xml diff --git a/Makefile.in b/Makefile.in index 5be6fc17..3743d787 100644 --- a/Makefile.in +++ b/Makefile.in @@ -55,6 +55,7 @@ ASCIIDOC = @ASCIIDOC@ XMLTO = @XMLTO@ MAKENSIS = @MAKENSIS@ XZ = @XZ@ +WINDRES = @WINDRES@ # Optional targets MANPAGES = @MANPAGES@ @@ -98,6 +99,8 @@ endif .xml.1: $(XMLTO) man --skip-validation $< 2>/dev/null +MANIFEST = @MANIFEST@ + #-- Begin File Lists --# NASM = asm/nasm.$(O) NDISASM = disasm/ndisasm.$(O) @@ -159,7 +162,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ) ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW) ALLOBJ = $(PROGOBJ) $(LIBOBJ) -SUBDIRS = stdlib nasmlib output asm disasm x86 common macros +SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win XSUBDIRS = test doc nsis DEPDIRS = . include config x86 $(SUBDIRS) #-- End File Lists --# @@ -177,11 +180,11 @@ $(NASMLIB): $(LIBOBJ) $(AR) cq $(NASMLIB) $(LIBOBJ) $(RANLIB) $(NASMLIB) -nasm$(X): $(NASM) $(NASMLIB) - $(CC) $(ALL_LDFLAGS) -o nasm$(X) $(NASM) $(NASMLIB) $(LIBS) +nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB) + $(CC) $(ALL_LDFLAGS) -o nasm$(X) $^ $(LIBS) -ndisasm$(X): $(NDISASM) $(NASMLIB) - $(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $(NDISASM) $(NASMLIB) $(LIBS) +ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB) + $(CC) $(ALL_LDFLAGS) -o ndisasm$(X) $^ $(LIBS) #-- Begin Generated File Rules --# @@ -362,6 +365,11 @@ nsis: nsis/nasm.nsi nsis/arch.nsh nsis/version.nsh #-- End NSIS Rules --# +# Windows embedded manifest +MANIFEST_RC = win/manifest.rc +win/manifest.$(O): win/manifest.xml $(MANIFEST_RC) + $(WINDRES) -I. -Iwin -DMANIFEST_FILE='\"$<\"' -i $(MANIFEST_RC) -o $@ + # Generated manpages, also pregenerated for distribution manpages: nasm.1 ndisasm.1 diff --git a/Mkfiles/msvc.mak b/Mkfiles/msvc.mak index da71c5c6..f030b85e 100644 --- a/Mkfiles/msvc.mak +++ b/Mkfiles/msvc.mak @@ -18,12 +18,15 @@ exec_prefix = $(prefix) bindir = $(prefix)/bin mandir = $(prefix)/man +MANIFEST_FLAGS = /MANIFEST:EMBED /MANIFESTFILE:$(MANIFEST) + !IF "$(DEBUG)" == "1" CFLAGS = /Od /Zi -LDFLAGS = /DEBUG +LDFLAGS = /DEBUG $(MANIFEST_FLAGS) !ELSE CFLAGS = /O2 /Zi -LDFLAGS = /DEBUG /OPT:REF /OPT:ICF # (latter two undoes /DEBUG harm) + # /OPT:REF and /OPT:ICF two undo /DEBUG harm +LDFLAGS = /DEBUG /OPT:REF /OPT:ICF $(MANIFEST_FLAGS) !ENDIF CC = cl @@ -59,6 +62,8 @@ X = .exe .c.obj: $(CC) /c $(ALL_CFLAGS) /Fo$@ $< +MANIFEST = win/manifest.xml + #-- Begin File Lists --# # Edit in Makefile.in, not here! NASM = asm\nasm.$(O) @@ -77,7 +82,8 @@ LIBOBJ_NW = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) \ nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) \ nasmlib\realpath.$(O) nasmlib\path.$(O) \ nasmlib\filename.$(O) nasmlib\rlimit.$(O) \ - nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) \ + nasmlib\readnum.$(O) nasmlib\numstr.$(O) \ + nasmlib\zerobuf.$(O) nasmlib\bsi.$(O) \ nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) \ nasmlib\raa.$(O) nasmlib\saa.$(O) \ nasmlib\strlist.$(O) \ @@ -120,7 +126,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ) ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW) ALLOBJ = $(PROGOBJ) $(LIBOBJ) -SUBDIRS = stdlib nasmlib output asm disasm x86 common macros +SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win XSUBDIRS = test doc nsis DEPDIRS = . include config x86 $(SUBDIRS) #-- End File Lists --# @@ -129,10 +135,10 @@ NASMLIB = libnasm.$(A) all: nasm$(X) ndisasm$(X) -nasm$(X): $(NASM) $(NASMLIB) +nasm$(X): $(NASM) $(MANIFEST) $(NASMLIB) $(CC) /Fe$@ $(NASM) $(LDFLAGS) $(NASMLIB) $(LIBS) -ndisasm$(X): $(NDISASM) $(NASMLIB) +ndisasm$(X): $(NDISASM) $(MANIFEST) $(NASMLIB) $(CC) /Fe$@ $(NDISASM) $(LDFLAGS) $(NASMLIB) $(LIBS) $(NASMLIB): $(LIBOBJ) diff --git a/Mkfiles/openwcom.mak b/Mkfiles/openwcom.mak index 605f9afe..84dd2088 100644 --- a/Mkfiles/openwcom.mak +++ b/Mkfiles/openwcom.mak @@ -48,6 +48,8 @@ X = .exe @set INCLUDE= $(CC) -c $(ALL_CFLAGS) -fo=$^@ $[@ +MANIFEST = + #-- Begin File Lists --# # Edit in Makefile.in, not here! NASM = asm\nasm.$(O) @@ -66,7 +68,8 @@ LIBOBJ_NW = stdlib\snprintf.$(O) stdlib\vsnprintf.$(O) stdlib\strlcpy.$(O) & nasmlib\file.$(O) nasmlib\mmap.$(O) nasmlib\ilog2.$(O) & nasmlib\realpath.$(O) nasmlib\path.$(O) & nasmlib\filename.$(O) nasmlib\rlimit.$(O) & - nasmlib\zerobuf.$(O) nasmlib\readnum.$(O) nasmlib\bsi.$(O) & + nasmlib\readnum.$(O) nasmlib\numstr.$(O) & + nasmlib\zerobuf.$(O) nasmlib\bsi.$(O) & nasmlib\rbtree.$(O) nasmlib\hashtbl.$(O) & nasmlib\raa.$(O) nasmlib\saa.$(O) & nasmlib\strlist.$(O) & @@ -109,7 +112,7 @@ LIBOBJ = $(LIBOBJ_NW) $(WARNOBJ) ALLOBJ_NW = $(PROGOBJ) $(LIBOBJ_NW) ALLOBJ = $(PROGOBJ) $(LIBOBJ) -SUBDIRS = stdlib nasmlib output asm disasm x86 common macros +SUBDIRS = stdlib nasmlib output asm disasm x86 common macros win XSUBDIRS = test doc nsis DEPDIRS = . include config x86 $(SUBDIRS) #-- End File Lists --# diff --git a/configure.ac b/configure.ac index c55dfb3c..e30125b2 100644 --- a/configure.ac +++ b/configure.ac @@ -17,9 +17,6 @@ dnl cross-compiling when in fact we are; running Wine here is at dnl the best very slow and doesn't buy us a single thing at all. PA_CROSS_COMPILE -dnl Get the canonical target system name -AC_CANONICAL_HOST - dnl Enable any available C extensions AC_PROG_CC AC_USE_SYSTEM_EXTENSIONS @@ -151,6 +148,13 @@ AC_CHECK_INCLUDES_DEFAULT dnl Check for variadic macro support PA_VARIADIC_MACROS +dnl Handle Windows embedded manifests +AS_CASE([$host], + [*-win* | *-mingw*], + [AC_CHECK_TOOL(WINDRES, windres, false) + AS_IF([test x"$WINDRES" != xfalse], + [AC_SUBST(MANIFEST, ['win/manifest.$(O)'])])]) + PA_ADD_HEADERS(string.h) PA_ADD_HEADERS(stdarg.h) PA_ADD_HEADERS(inttypes.h) diff --git a/win/.gitignore b/win/.gitignore new file mode 100644 index 00000000..d7ec32ea --- /dev/null +++ b/win/.gitignore @@ -0,0 +1 @@ +!*.xml diff --git a/win/manifest.rc b/win/manifest.rc new file mode 100644 index 00000000..411b7cb3 --- /dev/null +++ b/win/manifest.rc @@ -0,0 +1,2 @@ +LANGUAGE 0,0 +1 24 MANIFEST_FILE diff --git a/win/manifest.xml b/win/manifest.xml new file mode 100644 index 00000000..046fcb50 --- /dev/null +++ b/win/manifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + true + + + + + + + + + + + +