DaemonForums  

Go Back   DaemonForums > NetBSD > NetBSD Package System (pkgsrc)

NetBSD Package System (pkgsrc) Installation and upgrading of packages on NetBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 27th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 80
Unhappy pkgsrc optimization flags ignored

Hello all,

I gain the impression my optimization flags are ignored. This is from my /etc/mk.conf

Code:
CPUFLAGS+=           -march=native DDDDDD1
COPTS+=              -g -O2 -pipe CCCCCC1
I would expect the compilation to fail due to the Ds and Cs. It does not. I also tried setting bogus CFLAGS.

A grep for these flags does not show up in the build directory, either.

Code:
# grep -R DDDDDD1 /var/tmp/pkgsrc/graphics/xli/work/
# grep -R CCCCCC1 /var/tmp/pkgsrc/graphics/xli/work/
I tried graphics/xli as pkgsrc's xli Makefile is quite simple making it unlikely to overwrite mk.conf variables.
Reply With Quote
  #2   (View Single Post)  
Old 27th July 2020
thirdm thirdm is offline
Spam Deminer
 
Join Date: May 2009
Posts: 248
Default

I'm using the cpuflags package:

Code:
$ make show-var VARNAME=COPTS    
-pipe 
$ make show-var VARNAME=CPUFLAGS

$ make show-var VARNAME=CPU_FLAGS
-mfpmath=sse -msse3 -march=native
Maybe you should be setting CPU_FLAGS instead of CPUFLAGS. But that doesn't explain how your COPTS isn't getting through, unless xmi happens not to use it.
Reply With Quote
  #3   (View Single Post)  
Old 27th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 80
Default

About CFLAGS, vs COPTS, CPUFLAGS, CPU_FLAGS:

My original /etc/mk.conf file from many years ago used CFLAGS only. This document still recommends it https://www.netbsd.org/docs/pkgsrc/configuring.html

I then found COPTS and CPUFLAGS in man mk.conf. It's not clear to me if that is only used for building the kernel and userland or also for pkgsrc. Sensucht94 also uses CPUFLAGS in his fancy /etc/mk.conf file http://daemonforums.org/showthread.php?t=11326


My ultimate goal is to rebuild pkgsrc with debug symbols so I can analyze core files.

What I have now in /etc/mk.conf

Code:
CPUFLAGS+=              -march=native
COPTS+=                 -g -O2 -pipe
CFLAGS+=                -g
This results in

Code:
/usr/pkgsrc/graphics/xli# make show-var VARNAME=COPTS
-g -O2 -pipe
/usr/pkgsrc/graphics/xli# make show-var VARNAME=CFLAGS
-O2 -g -D_FORTIFY_SOURCE=2
/usr/pkgsrc/graphics/xli# make show-var VARNAME=CPUFLAGS
-march=native

/usr/pkgsrc/graphics/xli# make clean; make

/usr/pkgsrc/graphics/xli# gdb /var/tmp/pkgsrc/graphics/xli/work/xli-2005-02-27/xli
...
Reading symbols from /var/tmp/pkgsrc/graphics/xli/work/xli-2005-02-27/xli...
(No debugging symbols found in /var/tmp/pkgsrc/graphics/xli/work/xli-2005-02-27/xli)
Reply With Quote
  #4   (View Single Post)  
Old 27th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 80
Default

Quote:
COPTS isn't getting through, unless xmi happens not to use it.
Yesterday, I tried several packages with the same result.

I just tried a package based on ./configure and there my flags are passed through and debugging symbols are found.

Code:
Reading symbols from /var/tmp/pkgsrc/devel/yasm/work/yasm-1.3.0/yasm...
Disappointing that I can not build debugging symbols for all packages.
Reply With Quote
  #5   (View Single Post)  
Old 28th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 80
Default

I experimented with CFLAGS, COPTS, CPUFLAGS, CPU_FLAGS adding -g.

I only find debugging symbols in the binary when -g is passed via CFLAGS.

Sensucht94 and thirdm, I recommend you double-checking your optimization flags. You may find I'm right and only CFLAGS (and CXXFLAGS for g++) are passed the compiler.
Reply With Quote
  #6   (View Single Post)  
Old 28th July 2020
bashrules's Avatar
bashrules bashrules is offline
Aspiring Unix Greybeard
 
Join Date: Mar 2010
Location: Here
Posts: 80
Default

What seems to work for all tested packages is creating this wrapper

Code:
$ cat /opt/bin/gcc 
/usr/bin/gcc -g $*
and adding /opt/bin to the front of the PATH for pkgsrc builds.

Same for g++.

Not elegant, but hey.

I hesitate putting my fancy CFLAGS into this wrapper so that also xli and other non-configure based packages benefit from custom CFLAGS, because some package Makefiles do magic transformations of CLFAGS.
Reply With Quote
  #7   (View Single Post)  
Old 1st August 2020
thirdm thirdm is offline
Spam Deminer
 
Join Date: May 2009
Posts: 248
Default

For myself I don't want to add any custom wrappers around gcc. pkgsrc does more than enough wrapping itself for my taste.

I'm new to pkgsrc and NetBSD, but my guess is that this is one of those things that we cannot expect pkgsrc itself to solve. Maybe xli (and others you've tried?) is one of those packages made to ignore custom flags and needs to be patched. See section 10.15 of the pkgsrc guide.
Reply With Quote
  #8   (View Single Post)  
Old 22nd November 2022
Sehnsucht94's Avatar
Sehnsucht94 Sehnsucht94 is offline
Real Name: Paolo Vincenzo Olivo
Package Pilot
 
Join Date: Oct 2017
Location: Rome
Posts: 169
Default

Sorry, for replying after so much time, but I noticed you tagged me in this thread while skipping through past discussions. I don't know if this is still relevant, anyway:
Quote:
Originally Posted by bashrules View Post
I hesitate putting my fancy CFLAGS into this wrapper so that also xli and other non-configure based packages benefit from custom CFLAGS, because some package Makefiles do magic transformations of CLFAGS.
Quote:
Originally Posted by thirdm View Post
For myself I don't want to add any custom wrappers around gcc. pkgsrc does more than enough wrapping itself for my taste.

I'm new to pkgsrc and NetBSD, but my guess is that this is one of those things that we cannot expect pkgsrc itself to solve. Maybe xli (and others you've tried?) is one of those packages made to ignore custom flags and needs to be patched. See section 10.15 of the pkgsrc guide.

Projects sometimes set their own CFLAGS and it's not good practice to patch their Makefiles to hard-code specific flags, since pkgsrc is cross-platform and what may work on NetBSD may not work elsewhere.
The proper way to do this is to pass pkgsrc's CFLAGS (set dynamically and platform-dependent) to the 'internal' make (the package's own build system) before building.
Looking at graphics/xli Makefile, you can see that CFLAGS are not explicitly passed to the internal make (via MAKE_FLAGS+), while the package itself resets CFLAGS within its own Makefile.std.

Since xli uses imake, here's a diff to apply standard CFLAGS (and add debug symbols):
Code:
--- Makefile.orig       2022-11-22 12:29:32.838470167 +0000
+++ Makefile
@@ -12,6 +12,11 @@ COMMENT=     X11 Image Loading Utility
 
 USE_IMAKE=             YES
 
+CFLAGS+=       -g
+
+MAKE_FLAGS+=           CCOPTIONS=${CFLAGS:Q}
+MAKE_FLAGS+=           LOCAL_LDFLAGS=${LDFLAGS:Q}
+
 INSTALLATION_DIRS+=    lib/X11/app-defaults
If you have `CFLAGS+= -g' already set in mk.conf, then it doesn't need to be added to the Makefile. For packages using standard Makefiles (GNU or BSD), CFLAGS/LDFLAGS can be passed with:
Code:
MAKE_FLAGS+=    CFLAGS=${CFLAGS:Q}
MAKE_FLAGS+=    LDFLAGS=${LDFLAGS:Q}
Same applies to LIBS and what else. Hope this helps.
__________________
“Mi casa tendrá dos piernas y mis sueños no tendrán fronteras„
Reply With Quote
Reply

Tags
cflags, pkgsrc

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New to OpenBSD, could use some help on some issues and possible optimization options therue OpenBSD General 27 17th November 2019 02:11 PM
flags in vi's man page attilio OpenBSD Packages and Ports 4 13th December 2016 12:34 PM
openbsd server optimization barti OpenBSD General 18 30th July 2012 02:52 PM
Which is the significance about pkgsrc-2009Q2 and pkgsrc-2009Q3? aleunix NetBSD Package System (pkgsrc) 3 16th December 2009 07:19 AM
FreeBSD Kernel Optimization komodo FreeBSD General 5 22nd June 2009 07:15 AM


All times are GMT. The time now is 04:01 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick