You are not logged in.

#1 2024-01-18 07:06:15

lquidfire
Member
From: South Africa
Registered: 2017-07-26
Posts: 53

PKGBUILD libcs50(,-git) Makefile patch help requested

Edit: I apologise, this belongs in "Creating & Modifying Packages" rather... If a mod could please move this I'd be grateful. Sorry for using your time!


Hi all,

I took over the AUR packages libcs50 and libcs50-git, and am here to ask for some assistance to make them better.

Any tips are welcome, of course.

In the upstream Makefile, CFLAGS and LDFLAGS ("LINKER_FLAGS") are set: see lines 12 and 30 and 39-40, if I am not mistaken. This, I gather, bypasses the CFLAGS and LDFLAGS on the machine that you're building the package on. This results in namcap spewing warnings about no RELRO.

I have no background in software or building software. Still, I poked around the Makefile a bit after searching on these forums, and came up with the following patch ("diff -u Makefile Makefile.old > Makefile-FLAGS.patch"):

--- Makefile	2024-01-17 16:45:50.820032476 +0200
+++ Makefile.old	2024-01-17 16:50:35.989535760 +0200
@@ -9,7 +9,7 @@
 INCLUDE := src/cs50.h
 MANS := $(wildcard docs/*.3.gz)
 
-CFLAGS=-Wall -Wextra -Werror -pedantic -std=c11
+CFLAGS+=-Wall -Wextra -Werror -pedantic -std=c11
 BASENAME=libcs50
 LIB_STATIC=$(BASENAME).a
 LIB_OBJ=$(BASENAME).o
@@ -36,8 +36,8 @@
 all: $(LIBS) $(MANS)
 
 $(LIBS): $(SRC) $(INCLUDE) Makefile
-	$(CC) $(CFLAGS) -fPIC -shared $(LINKER_FLAGS) -o $(LIB_VERSION) $(SRC)
-	$(CC) $(CFLAGS) -c -o $(LIB_OBJ) $(SRC)
+	$(CC) $(CFLAGS) -fPIC -shared $(LINKER_FLAGS) -o $(LIB_VERSION) $(SRC) ${LDFLAGS}
+	$(CC) $(CFLAGS) -c -o $(LIB_OBJ) $(SRC) $(LDFLAGS)
 	ar rcs $(LIB_STATIC) $(LIB_OBJ)
 	chmod 644 $(LIB_STATIC)
 	rm -f $(LIB_OBJ)

Is this a correct way to add the build-system's CFLAGS and LDFLAGS for building libcs50(,-git)?

Next question: If so, would this be something to suggest to upstream, or is it good practice to bypass the build system's flags, and to impose your own? I just ran with namcap's warnings and things I read on the forum, which heavily suggest that this should be reported upstream. Still, being a complete noob, I rather check before bother upstream.

Thank you for your time and for teaching me!

Last edited by lquidfire (2024-01-18 07:16:06)

Offline

#2 2024-01-18 09:26:43

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,958

Re: PKGBUILD libcs50(,-git) Makefile patch help requested

see lines 12 and 30 and 39-40, if I am not mistaken.

line 30 is used on mac systems, line 24 is what's used on linux.

This, I gather, bypasses the CFLAGS and LDFLAGS on the machine that you're building the package on

yup, those in the makefile override the local settings .

There may be specific reasons why upstream uses their own set flags, and this library appears to have a very specific usecase.

The cnrdrvcups-lb aur package I maintain has a similar issue.
its upstream doesn't accept tickets for unsupported distros and as far as I know the supported distros do not change the upstream flags.
So my package also doesn't change the flags.

I suggest asking upstream about those flags and not changing them unless there's confirmation archlinux distro flags don't impact functionality of the library.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2024-01-19 08:45:22

lquidfire
Member
From: South Africa
Registered: 2017-07-26
Posts: 53

Re: PKGBUILD libcs50(,-git) Makefile patch help requested

Dank je for your reply, Lone_Wolf.

I have contacted upstream to find out of RELRO would inhibit the software's functionality, and what they think of adding their flags to local flags, instead of replacing local ones.

Offline

Board footer

Powered by FluxBB