Re: noopt not working
On Saturday, April 23, 2016 22:16:50 Jakub Wilk wrote:
> * Shawn Sörbom <shawn@sorbom.com>, 2016-04-23, 12:47:
> >In a debian/rules file, I have the variable
> >export DEB_BUILD_OPTIONS=noopt
>
> You should never do that in debian/rules.
> DEB_BUILD_OPTIONS is supposed to be set by the user who builds the
> package.
>
> >but dpkg-buildflags --get CFLAGS returns
> >-g -O2 -fstack-protector-strong -Wformat -Werror=format-security
> >
> >What am I doing wrong?
>
> You didn't show us your debian/rules, so I'll have to guess:
> If you use dpkg-buildflags within $(shell) then that's not affected by
> environment variables set in the same makefile.
>
> >btw, the makefile in question has "-02" set in CFLAGS.
> >Do I need to patch it? I'm assuming no, but setting DEB_CFLAGS_STRIP =
> >-02
>
> I think you meant "-O2", not "-02".
>
> But again, DEB_<flag>_STRIP is supposed to be set by the user who builds
> the package. You can use DEB_<flag>_MAINT_STRIP in debian/rules if you
> really want to.
The problem is that optimization appears to cause a segfault during runtime.
I fixed the DEB_CFLAGSS_MAINT_STRIP and the DEB_BUILD_MAINT_OPTIONS issue.
I also included the makefile.
Here's the project link:
https://github.com/devshane/zork
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1
# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all noopt
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -g
export DEB_CFLAGS_MAINT_STRIP = -O2
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
# main packaging script based on dh7 syntax
%:
dh $@
# debmake generated override targets
# This is example for Cmake (See http://bugs.debian.org/641051 )
#override_dh_auto_configure:
# dh_auto_configure -- \
# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
# Makefile for dungeon
# Where to install the program
BINDIR = /usr/games
# Where to install the data file
LIBDIR = /usr/games/lib
# The dungeon program provides a ``more'' facility which tries to
# figure out how many rows the terminal has. Several mechanisms are
# supported for determining this; the most common one has been left
# uncommented. If you have trouble, especially when linking, you may
# have to select a different option.
# more option 1: use the termcap routines. On some systems the LIBS
# variable may need to be set to -lcurses. On some it may need to
# be /usr/lib/termcap.o. These options are commented out below.
LIBS = -ltermcap
TERMFLAG =
# LIBS = -lcurses
# LIBS = /usr/lib/termcap.o
# more option 2: use the terminfo routines. On some systems the LIBS
# variable needs to be -lcursesX, but probably all such systems support
# the termcap routines (option 1) anyhow.
# LIBS = -lcurses
# TERMFLAG = -DMORE_TERMINFO
# more option 3: assume all terminals have 24 rows
# LIBS =
# TERMFLAG = -DMORE_24
# more option 4: don't use the more facility at all
# LIBS =
# TERMFLAG = -DMORE_NONE
# End of more options
# Uncomment the following line if you want to have access to the game
# debugging tool. This is invoked by typing "gdt". It is not much
# use except for debugging.
GDTFLAG = -DALLOW_GDT
# Compilation flags
CFLAGS = -O2 #-static
# On SCO Unix Development System 3.2.2a, the const type qualifier does
# not work correctly when using cc. The following line will cause it
# to not be used and should be uncommented.
# CFLAGS= -O -Dconst=
##################################################################
# Source files
CSRC = actors.c ballop.c clockr.c demons.c dgame.c dinit.c dmain.c\
dso1.c dso2.c dso3.c dso4.c dso5.c dso6.c dso7.c dsub.c dverb1.c\
dverb2.c gdt.c lightp.c local.c nobjs.c np.c np1.c np2.c np3.c\
nrooms.c objcts.c rooms.c sobjs.c supp.c sverbs.c verbs.c villns.c
# Object files
OBJS = actors.o ballop.o clockr.o demons.o dgame.o dinit.o dmain.o\
dso1.o dso2.o dso3.o dso4.o dso5.o dso6.o dso7.o dsub.o dverb1.o\
dverb2.o gdt.o lightp.o local.o nobjs.o np.o np1.o np2.o np3.o\
nrooms.o objcts.o rooms.o sobjs.o supp.o sverbs.o verbs.o villns.o
dungeon: $(OBJS) dtextc.dat
$(CC) $(CFLAGS) -o zork $(OBJS) $(LIBS)
install: zork dtextc.dat
cp zork $(BINDIR)
cp dtextc.dat $(LIBDIR)
clean:
rm -f $(OBJS) zork core dsave.dat *~
dtextc.dat:
cat dtextc.uu1 dtextc.uu2 dtextc.uu3 dtextc.uu4 | uudecode
dinit.o: dinit.c funcs.h vars.h
$(CC) $(CFLAGS) $(GDTFLAG) -DTEXTFILE=\"$(LIBDIR)/dtextc.dat\" -c dinit.c
dgame.o: dgame.c funcs.h vars.h
$(CC) $(CFLAGS) $(GDTFLAG) -c dgame.c
gdt.o: gdt.c funcs.h vars.h
$(CC) $(CFLAGS) $(GDTFLAG) -c gdt.c
local.o: local.c funcs.h vars.h
$(CC) $(CFLAGS) $(GDTFLAG) -c local.c
supp.o: supp.c funcs.h vars.h
$(CC) $(CFLAGS) $(TERMFLAG) -c supp.c
actors.o: funcs.h vars.h
ballop.o: funcs.h vars.h
clockr.o: funcs.h vars.h
demons.o: funcs.h vars.h
dmain.o: funcs.h vars.h
dso1.o: funcs.h vars.h
dso2.o: funcs.h vars.h
dso3.o: funcs.h vars.h
dso4.o: funcs.h vars.h
dso5.o: funcs.h vars.h
dso6.o: funcs.h vars.h
dso7.o: funcs.h vars.h
dsub.o: funcs.h vars.h
dverb1.o: funcs.h vars.h
dverb2.o: funcs.h vars.h
lightp.o: funcs.h vars.h
nobjs.o: funcs.h vars.h
np.o: funcs.h vars.h
np1.o: funcs.h vars.h parse.h
np2.o: funcs.h vars.h parse.h
np3.o: funcs.h vars.h parse.h
nrooms.o: funcs.h vars.h
objcts.o: funcs.h vars.h
rooms.o: funcs.h vars.h
sobjs.o: funcs.h vars.h
sverbs.o: funcs.h vars.h
verbs.o: funcs.h vars.h
villns.o: funcs.h vars.h
Reply to: