Saturday, March 11, 2023

Re: Non-standard allocations in games/vkquake

Thomas Frohwein <tfrohwein@fastmail.com> wrote:
> On Fri, Mar 10, 2023 at 08:36:06PM +0000, Ali Farzanrad wrote:
> [...]
> > > > Please leave in the hunk that removes -Werror
> > >
> > > yes, what's the reason for this being in the diff/
> >
> > I thought that you've removed that -Werror mistakenly, because it was
> > used to detect compiler options and without that flag it's functionality
> > (compiler flags detection) is broken.
>
> I see those. I feel like there must be a better way to silence those
> unused flags. Here they are:
>
> cc: warning: optimization flag '-fweb' is not supported [-Wignored-optimization-argument]
> cc: warning: optimization flag '-frename-registers' is not supported [-Wignored-optimization-argument]

OK, but I think it is better to remove the compiler option detection
functionality compeletely, instead of breaking it, right?

$ cat patches/patch-Quake_Makefile
remove hardcoded optimization flag
use standard library for allocation

Index: Quake/Makefile
--- Quake/Makefile.orig
+++ Quake/Makefile
@@ -25,14 +25,6 @@ MP3LIB=mad
# which library to use for ogg decoding: vorbis or tremor
VORBISLIB=vorbis

-# ---------------------------
-# Helper functions
-# ---------------------------
-
-check_gcc = $(shell if echo | $(CC) $(1) -Werror -S -o /dev/null -xc - > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi;)
-
-# ---------------------------
-
HOST_OS := $(shell uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]')

DEBUG ?= 0
@@ -51,19 +43,19 @@ LDFLAGS ?=
DFLAGS ?=
CFLAGS ?=

-CFLAGS += -Wall -Wno-trigraphs -Wno-unused-function -Werror -std=gnu11 -MMD
+CFLAGS += -Wall -Wno-trigraphs -Wno-unused-function -std=gnu11 -MMD
CFLAGS += $(CPUFLAGS)
+CFLAGS += -DUSE_CRT_MALLOC
ifneq ($(DEBUG),0)
DFLAGS += -D_DEBUG
CFLAGS += -g
do_strip=
else
DFLAGS += -DNDEBUG
-CFLAGS += -O3
-CFLAGS += $(call check_gcc,-fweb,)
-CFLAGS += $(call check_gcc,-frename-registers,)
-CFLAGS += $(call check_gcc,-fno-asynchronous-unwind-tables,)
-CFLAGS += $(call check_gcc,-fno-ident,)
+CFLAGS += -fweb
+CFLAGS += -frename-registers
+CFLAGS += -fno-asynchronous-unwind-tables
+CFLAGS += -fno-ident
cmd_strip=$(STRIP) $(1)
define do_strip
$(call cmd_strip,$(1));

> [...]
> > > > > ++CFLAGS += -DUSE_CRT_MALLOC
> > >
> > > Can you reference documentation about the option USE_CRT_MALLOC? I can't
> > > find any in the vkquake files, nor on a quick web search.
> >
> > No, I just receive segmentation fault on my arm64 machine:
> > $ doas pkg_add vkquake
> > quirks-6.116 signed on 2023-03-09T01:36:51Z
> > vkquake-1.20.3: ok
> > New and changed readme(s):
> > /usr/local/share/doc/pkg-readmes/vkquake
> > $ vkquake
> > Command line: ./vkquake
> > Found SDL version 2.24.1
> > Detected 8 CPUs.
> > Initializing vkQuake v1.20.3
> > Built with Clang 13.0.0
> > Host_Init
> > Segmentation fault
> >
> > And it was about a NULL-dereferencing after a failed memory allocation.
> > I tried to find the problem, but its memory management was so complex.
> > I found this option on Quake/mem.c file.
> >
> > Even after applying my patch it is still not working on my system, but
> > I don't think it is related to this port:
> > $ vkquake
> > Command line: ./vkquake
> > Found SDL version 2.24.1
> > Detected 8 CPUs.
> > Initializing vkQuake v1.20.3
> > Built with Clang 13.0.0
> > Host_Init
> > Playing registered version.
> > Console initialized.
> > UDP4_Init: gethostbyname failed (Host name lookup failure)
> > UDP4 Initialized
> > UDPv6 Initialized
> > Server using protocol 999+ (FTE-RMQ)
> > Exe: 21:30:40 Mar 10 2023
> >
> > Vulkan Initialization
> > Using Vulkan 1.1
> > Instance extensions:
> > VK_KHR_surface
> > VK_KHR_xlib_surface
> > VK_KHR_get_surface_capabilities2
> > VK_KHR_get_physical_device_properties2
> >
> >
> > ERROR-OUT BEGIN
> >
> >
> > QUAKE ERROR: Couldn't find any Vulkan devices
> >
> > > > > ifneq ($(DEBUG),0)
> > > > > DFLAGS += -D_DEBUG
> > > > > -@@ -59,7 +59,6 @@ CFLAGS += -g
> > > > > + CFLAGS += -g
> > > > > do_strip=
> > > > > else
> > > > > DFLAGS += -DNDEBUG
> > > > >
> >
>
> I don't get an error like yours. Do vulkaninfo and vkcube work?

No, they don't work too:
$ vulkaninfo
ERROR: [Loader Message] Code 0 : remove_all_non_valid_override_layers: Failed to get executable path and name
ERROR: [Loader Message] Code 0 : setup_loader_term_phys_devs: Failed to detect any valid GPUs in the current config
ERROR at /usr/obj/ports/vulkan-tools-1.3.239.0/Vulkan-Tools-sdk-1.3.239.0/vulkaninfo/vulkaninfo.h:237:vkEnumeratePhysicalDevices failed with ERROR_INITIALIZATION_FAILED
$ vkcube
vkEnumeratePhysicalDevices reported zero accessible devices.

Do you have a compatible Vulkan installable client driver (ICD) installed?
Please look at the Getting Started guide for additional information.

No comments:

Post a Comment