bakkeby / dwm-flexipatch

A dwm build with preprocessor directives to decide which patches to include during build time
MIT License
1.15k stars 233 forks source link

Errors while applying SWALLOW patch #72

Closed har5ha closed 3 years ago

har5ha commented 3 years ago
make
dwm build options:
CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/X11R6/include -I/usr/include/freetype2  -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION="6.2" -DXINERAMA
LDFLAGS  = -L/usr/X11R6/lib -lX11 -lXinerama -lfontconfig -lXft
CC       = cc
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/X11R6/include -I/usr/include/freetype2  -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"6.2\" -DXINERAMA drw.c
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/X11R6/include -I/usr/include/freetype2  -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"6.2\" -DXINERAMA dwm.c
In file included from dwm.c:679:
config.h:520:4: warning: initialization of ‘int’ from ‘void *’ makes integer from pointer without a cast
-Wint-conversion]
  520 |  { NULL }
      |    ^~~~
config.h:520:4: note: (near initialization for ‘barrules[4].monitor’)
In file included from patch/include.c:33,
                 from dwm.c:681:
patch/bar_status.c:30:1: warning: ‘click_status’ defined but not used [-Wunused-function]
   30 | click_status(Bar *bar, Arg *arg, BarClickArg *a)
      | ^~~~~~~~~~~~
patch/bar_status.c:16:1: warning: ‘draw_status’ defined but not used [-Wunused-function]
   16 | draw_status(Bar *bar, BarDrawArg *a)
      | ^~~~~~~~~~~
patch/bar_status.c:2:1: warning: ‘width_status’ defined but not used [-Wunused-function]
    2 | width_status(Bar *bar, BarWidthArg *a)
      | ^~~~~~~~~~~~
cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/X11R6/include -I/usr/include/freetype2  -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"6.2\" -DXINERAMA util.c
cc -o dwm drw.o dwm.o util.o -L/usr/X11R6/lib -lX11 -lXinerama -lfontconfig -lXft
/usr/bin/ld: dwm.o: in function `manage':
dwm.c:(.text+0x41b8): undefined reference to `xcb_res_query_client_ids'
/usr/bin/ld: dwm.c:(.text+0x41cb): undefined reference to `xcb_res_query_client_ids_reply'
/usr/bin/ld: dwm.c:(.text+0x41db): undefined reference to `xcb_res_query_client_ids_ids_iterator'
/usr/bin/ld: dwm.c:(.text+0x4208): undefined reference to `xcb_res_client_id_value_value'
/usr/bin/ld: dwm.c:(.text+0x4215): undefined reference to `xcb_res_client_id_value_next'
/usr/bin/ld: dwm.o: in function `main':
dwm.c:(.text.startup+0xa0): undefined reference to `XGetXCBConnection'
collect2: error: ld returned 1 exit status
make: *** [Makefile:29: dwm] Error 1

How ever I am able to successfully apply the patch (dwm-swallow-20200522-7accbcf.diff from https://dwm.suckless.org/patches/swallow/ ) to dwm 6.2 (26kb) (20190203) from https://dwm.suckless.org/ without any errors.

Can you please look into it. Thanks in advance.

har5ha commented 3 years ago

I changed config.mk file

From : LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${PANGOLIB}

To: LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ${XRENDER} ${MPDCLIENT} ${XEXTLIB} ${XCBLIBS} ${PANGOLIB} -lX11-xcb -lxcb -lxcb-res

And now 'make' returns no errors.

So -lX11-xcb -lxcb -lxcb-res needed to be added to config.mk file as a part of the patch.

bakkeby commented 3 years ago

Yes, that being this line in config.mk

# Uncomment this for the swallow patch / SWALLOW_PATCH
XCBLIBS = -lX11-xcb -lxcb -lxcb-res
har5ha commented 3 years ago

Yes, that being this line in config.mk

# Uncomment this for the swallow patch / SWALLOW_PATCH
XCBLIBS = -lX11-xcb -lxcb -lxcb-res

Okay.. My mistake.. never thought I also have to edit/look at "config.mk" along with "config.def.h" and "patches.def.h" when building.

Thanks! for your help.

This can be closed.

bakkeby commented 3 years ago

Yes it is a bit annoying, but I haven't found a good way using such pre-processor directives for the Makefile.

There should actually be a note about making changes to config.mk in the short description for the swallow patch (as with the alpha patch and others), but I see it is not there.

I'll add that now.

har5ha commented 3 years ago

That would definitely help. Thanks!

har5ha commented 3 years ago

Actual patch involves setting the noswallow to be set to 0

* class     instance  title           tags mask  isfloating  isterminal  noswallow  monitor */
+   { "Gimp",    NULL,     NULL,           0,         1,          0,           0,        -1 },
+   { "Firefox", NULL,     NULL,           1 << 8,    0,          0,          -1,        -1 },
+   { "St",      NULL,     NULL,           0,         0,          1,           0,        -1 },
+   { NULL,      NULL,     "Event Tester", 0,         0,          0,           1,        -1 }, /* xev */

How do I go about setting this in the "config.def.h" with this patch?

RULE(.class = "St", .noswallow = 0)

bakkeby commented 3 years ago

You have a choice. Either you set up a traditional table like the above based on the available fields in the Rule struct (depends on what patches you enable), or you use the RULE() method that is set by default with dwm-flexipatch.

Either is fine. It is just that by using such a table you have to add columns to it if you enable a patch that adds something to the rule section. I used to have such a table with preprocessor directives, but needless to say it was unmaintainable: https://github.com/bakkeby/dwm-flexipatch/blob/ae5c96c2177a5a79a441f1eaa0d20e4d852afee3/config.def.h#L299-L439

As for your proposal:

RULE(.class = "St", .noswallow = 0)

This is perfectly valid, except that it doesn't actually make any diffference as you are setting the value to 0. When you use the RULE() method then all values are 0 or NULL by default* unless you specify that a certain column should have a specific value.

Including this makes more sense if you want to set noswallow to 1. If you look in dwm.c there are also some helper macros, e.g. NOSWALLOW and TERMINAL that sets .noswallow and .isterminal to 1 respectively.

E.g. in my build I have

RULE(.title = "Event Tester" NOSWALLOW)
RULE(.class = "st-256color" TERMINAL)

I could just as well have added .noswallow = 1 here, but the reasoning for using these helper macros is merely so that if I happen to disable the swallow patch (for testing purposes or otherwise) then dwm will still compile fine without complaining that there is no .noswallow field in the Rule struct. The macros simply translate to empty strings if the swallow patch is not enabled.

* (an exception to this is the monitor which defaults to -1 as per the RULE definition in dwm.c)

har5ha commented 3 years ago

Thanks for a wonderful explanation.

The following change in config.def.h did the trick for me. RULE(.class = "St" TERMINAL) instead of RULE(.class = "st-256color" TERMINAL)